How to use the @material/floating-label.MDCFloatingLabelFoundation function in @material/floating-label

To help you get started, we’ve selected a few @material/floating-label 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 / floating-label / mdc.floating-label.directive.ts View on Github external
},
        getWidth:() => this._elm.nativeElement.offsetWidth,
        registerInteractionHandler: (type: string, handler: EventListener) => {
            this.registry.listen(this._rndr, type, handler, this._elm);
        },
        deregisterInteractionHandler: (type: string, handler: EventListener) => {
            this.registry.unlisten(type, handler);
        }
    };
    _foundation: {
        init: Function,
        destroy: Function,
        float: (should: boolean) => void,
        shake: (should: boolean) => void,
        getWidth: () => number
    } = new MDCFloatingLabelFoundation(this._mdcAdapter);

    constructor(private _rndr: Renderer2, public _elm: ElementRef, private registry: MdcEventRegistry) {
        super();
    }

    ngAfterContentInit() {
        this._foundation.init();
        this._initialized = true;
    }

    ngOnDestroy() {
        this._foundation.init();
        this._initialized = false;
    }
}
github jamesmfriedman / rmwc / src / floating-label / index.tsx View on Github external
getDefaultFoundation() {
    return new MDCFloatingLabelFoundation({
      addClass: (className: string) => this.root.addClass(className),
      removeClass: (className: string) => this.root.removeClass(className),
      getWidth: () => (this.root.ref ? this.root.ref.scrollWidth : 0),
      registerInteractionHandler: (
        evtType: K,
        handler: SpecificEventListener
      ): void => this.root.addEventListener(evtType, handler),
      deregisterInteractionHandler: (
        evtType: K,
        handler: SpecificEventListener
      ): void => this.root.removeEventListener(evtType, handler)
    });
  }
github trimox / angular-mdc-web / packages / floating-label / floating-label.ts View on Github external
getDefaultFoundation() {
    const adapter: MDCFloatingLabelAdapter = {
      addClass: (className: string) => this._getHostElement().classList.add(className),
      removeClass: (className: string) => this._getHostElement().classList.remove(className),
      getWidth: () => this._getHostElement().scrollWidth,
      registerInteractionHandler: () => { },
      deregisterInteractionHandler: () => { }
    };
    return new MDCFloatingLabelFoundation(adapter);
  }