How to use the @material/drawer.MDCPersistentDrawerFoundation function in @material/drawer

To help you get started, we’ve selected a few @material/drawer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github src-zone / material / bundle / src / components / drawer / mdc.drawer.directive.ts View on Github external
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');
        }
    }
github trimox / angular-mdc-web / src / lib / drawer / persistent / drawer-persistent.ts View on Github external
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();
  }