How to use the @rmwc/base.debounce function in @rmwc/base

To help you get started, we’ve selected a few @rmwc/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 jamesmfriedman / rmwc / src / slider / index.tsx View on Github external
getDefaultFoundation() {
    return new MDCSliderFoundation({
      hasClass: (className: string) => this.root.hasClass(className),
      addClass: (className: string) => this.root.addClass(className),
      removeClass: (className: string) => this.root.removeClass(className),
      getAttribute: (name: string) =>
        this.root.getProp(name as any) as string | null,
      setAttribute: debounce(
        (name: string, value: any) => this.root.setProp(name as any, value),
        300
      ),
      removeAttribute: (name: string) => this.root.removeProp(name as any),
      computeBoundingRect: () =>
        this.root.ref
          ? this.root.ref.getBoundingClientRect()
          : ({} as ClientRect),
      getTabIndex: () => (this.root.ref ? this.root.ref.tabIndex : 0),
      registerInteractionHandler: (
        evtType: K,
        handler: SpecificEventListener
      ): void => {
        this.root.addEventListener(evtType, handler);
      },
      deregisterInteractionHandler: (
github jamesmfriedman / rmwc / src / slider / foundation.tsx View on Github external
foundation: ({ rootEl, thumbContainerEl, sliderPinEl, emit }) => {
      return new MDCSliderFoundation({
        hasClass: (className: string) => rootEl.hasClass(className),
        addClass: (className: string) => rootEl.addClass(className),
        removeClass: (className: string) => rootEl.removeClass(className),
        getAttribute: (name: string) =>
          rootEl.getProp(name as any) as string | null,
        setAttribute: debounce(
          (name: string, value: any) => rootEl.setProp(name as any, value),
          300
        ),
        removeAttribute: (name: string) => rootEl.removeProp(name as any),
        computeBoundingRect: () =>
          rootEl.ref ? rootEl.ref.getBoundingClientRect() : emptyClientRect,
        getTabIndex: () => (rootEl.ref ? rootEl.ref.tabIndex : 0),
        registerInteractionHandler: (
          evtType: K,
          handler: SpecificEventListener
        ): void => {
          rootEl.addEventListener(evtType, handler);
        },
        deregisterInteractionHandler: (
          evtType: K,
          handler: SpecificEventListener