How to use the @material/mwc-base/base-element.addHasRemoveClass function in @material/mwc-base

To help you get started, we’ve selected a few @material/mwc-base 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 material-components / material-components-web-components / packages / tab-scroller / src / mwc-tab-scroller-base.ts View on Github external
protected createAdapter(): MDCTabScrollerAdapter {
    return {
      ...addHasRemoveClass(this.mdcRoot),
      eventTargetMatchesSelector: (evtTarget: EventTarget, selector: string) =>
          matches(evtTarget as Element, selector),
      addScrollAreaClass: (className: string) =>
          this.scrollAreaElement.classList.add(className),
      setScrollAreaStyleProperty: (prop: string, value: string) =>
          this.scrollAreaElement.style.setProperty(prop, value),
      setScrollContentStyleProperty: (prop: string, value: string) =>
          this.scrollContentElement.style.setProperty(prop, value),
      getScrollContentStyleValue: (propName: string) =>
          window.getComputedStyle(this.scrollContentElement)
              .getPropertyValue(propName),
      setScrollAreaScrollLeft: (scrollX: number) =>
          this.scrollAreaElement.scrollLeft = scrollX,
      getScrollAreaScrollLeft: () => this.scrollAreaElement.scrollLeft,
      getScrollContentOffsetWidth: () => this.scrollContentElement.offsetWidth,
      getScrollAreaOffsetWidth: () => this.scrollAreaElement.offsetWidth,
github material-components / material-components-web-components / packages / top-app-bar / src / mwc-top-app-bar-base-base.ts View on Github external
protected createAdapter(): MDCTopAppBarAdapter {
    return {
      ...addHasRemoveClass(this.mdcRoot),
      setStyle: (property: string, value: string) =>
          this.mdcRoot.style.setProperty(property, value),
      getTopAppBarHeight: () => this.mdcRoot.clientHeight,
      notifyNavigationIconClicked: () => {
        this.dispatchEvent(new Event(
            strings.NAVIGATION_EVENT, {bubbles: true, cancelable: true}));
      },
      getViewportScrollY: () => this.scrollTarget instanceof Window ?
          this.scrollTarget.pageYOffset :
          this.scrollTarget.scrollTop,
      getTotalActionItems: () => (this._actionItemsSlot as HTMLSlotElement)
                                     .assignedNodes({flatten: true})
                                     .length,
    };
  }