(Sidebar) Mark the change detector for changes on every action so OnPush components can use the Sidebar

This commit is contained in:
Sercan Yemen 2018-06-11 12:10:04 +03:00
parent 234dec3d6a
commit d5f1fcfefa

View File

@ -1,4 +1,4 @@
import { Component, ElementRef, HostBinding, HostListener, Input, OnDestroy, OnInit, Renderer2, ViewEncapsulation } from '@angular/core'; import { ChangeDetectorRef, Component, ElementRef, HostBinding, HostListener, Input, OnDestroy, OnInit, Renderer2, ViewEncapsulation } from '@angular/core';
import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations'; import { animate, AnimationBuilder, AnimationPlayer, style } from '@angular/animations';
import { ObservableMedia } from '@angular/flex-layout'; import { ObservableMedia } from '@angular/flex-layout';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
@ -59,6 +59,7 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
* Constructor * Constructor
* *
* @param {AnimationBuilder} _animationBuilder * @param {AnimationBuilder} _animationBuilder
* @param {ChangeDetectorRef} _changeDetectorRef
* @param {ElementRef} _elementRef * @param {ElementRef} _elementRef
* @param {FuseConfigService} _fuseConfigService * @param {FuseConfigService} _fuseConfigService
* @param {FuseMatchMediaService} _fuseMatchMediaService * @param {FuseMatchMediaService} _fuseMatchMediaService
@ -68,6 +69,7 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
*/ */
constructor( constructor(
private _animationBuilder: AnimationBuilder, private _animationBuilder: AnimationBuilder,
private _changeDetectorRef: ChangeDetectorRef,
private _elementRef: ElementRef, private _elementRef: ElementRef,
private _fuseConfigService: FuseConfigService, private _fuseConfigService: FuseConfigService,
private _fuseMatchMediaService: FuseMatchMediaService, private _fuseMatchMediaService: FuseMatchMediaService,
@ -348,6 +350,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
this.close(); this.close();
} }
); );
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -383,6 +388,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
this._backdrop = null; this._backdrop = null;
} }
}); });
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -398,6 +406,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Make the sidebar invisible // Make the sidebar invisible
this._renderer.removeStyle(this._elementRef.nativeElement, 'visibility'); this._renderer.removeStyle(this._elementRef.nativeElement, 'visibility');
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -419,6 +430,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Make the sidebar invisible // Make the sidebar invisible
this._renderer.setStyle(this._elementRef.nativeElement, 'visibility', 'hidden'); this._renderer.setStyle(this._elementRef.nativeElement, 'visibility', 'hidden');
}, delayAmount); }, delayAmount);
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -436,6 +450,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Enable the animations // Enable the animations
this._animationsEnabled = true; this._animationsEnabled = true;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
// ----------------------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------------------
@ -463,6 +480,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Set the opened status // Set the opened status
this.opened = true; this.opened = true;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -486,6 +506,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Hide the sidebar // Hide the sidebar
this._hideSidebar(); this._hideSidebar();
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -520,6 +543,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Unfold the sidebar temporarily // Unfold the sidebar temporarily
this.unfolded = true; this.unfolded = true;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -539,6 +565,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Fold the sidebar back // Fold the sidebar back
this.unfolded = false; this.unfolded = false;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -557,6 +586,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Fold // Fold
this.folded = true; this.folded = true;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**
@ -575,6 +607,9 @@ export class FuseSidebarComponent implements OnInit, OnDestroy
// Unfold // Unfold
this.folded = false; this.folded = false;
// Mark for check
this._changeDetectorRef.markForCheck();
} }
/** /**