Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private initDrawer() {
if (this.initialized) {
this.destroyDrawer();
if (this.hasNecessaryDom()) {
this.createAdapter();
let newFoundation = this.type === 'temporary' ?
new MDCTemporaryDrawerFoundation(this.mdcAdapter) :
new MDCPersistentDrawerFoundation(this.mdcAdapter);
// first init, then assign to this.foundation, so that
// this.openMem is used to detect the open state, instead
// of the new foundation (which would never be opened otherwise):
newFoundation.init();
this.open = this.openMem;
this.foundation = newFoundation;
} else
console.error('mdcDrawerContainer can\'t be constructed because of missing DOM elements');
}
}
notifyClose: () => this.closed.emit(),
isRtl: () => {
return getComputedStyle(this.elementRef.nativeElement).getPropertyValue('direction') === 'rtl';
},
isDrawer: (el) => {
return this.drawerNav ? el === this.drawerNav.elementRef.nativeElement : false;
}
};
private _foundation: {
init: Function,
destroy: Function,
open: Function,
close: Function,
isOpen: Function,
} = new MDCPersistentDrawerFoundation(this._mdcAdapter);
constructor(
public renderer: Renderer2,
public elementRef: ElementRef,
private _registry: EventRegistry) {
super(renderer, elementRef);
}
ngAfterViewInit(): void {
this._foundation.init();
}
ngOnDestroy(): void {
this._foundation.destroy();
}