How to use the throttle-debounce/throttle function in throttle-debounce

To help you get started, we’ve selected a few throttle-debounce 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 ElemeFE / element / packages / backtop / src / main.vue View on Github external
mounted() {
    this.init();
    this.throttledScrollHandler = throttle(300, this.onScroll);
    this.container.addEventListener('scroll', this.throttledScrollHandler);
  },
github ElemeFE / element / packages / carousel / src / main.vue View on Github external
created() {
    this.throttledArrowClick = throttle(300, true, index => {
      this.setActiveItem(index);
    });
    this.throttledIndicatorHover = throttle(300, index => {
      this.handleIndicatorHover(index);
    });
  },
github ElemeFE / element / packages / image / src / main.vue View on Github external
if (this.$isServer) return;

        const { scrollContainer } = this;
        let _scrollContainer = null;

        if (isHtmlElement(scrollContainer)) {
          _scrollContainer = scrollContainer;
        } else if (isString(scrollContainer)) {
          _scrollContainer = document.querySelector(scrollContainer);
        } else {
          _scrollContainer = getScrollContainer(this.$el);
        }

        if (_scrollContainer) {
          this._scrollContainer = _scrollContainer;
          this._lazyLoadHandler = throttle(200, this.handleLazyLoad);
          on(_scrollContainer, 'scroll', this._lazyLoadHandler);
          this.handleLazyLoad();
        }
      },
      removeLazyLoadListener() {
github wilsonIs / vue-treeSelect / src / components / tree-select / tree.vue View on Github external
let childNodes = treeNodes[self.treeProps.children];

                for(let i=0;i{
                    child.visible = child[self.treeProps.label].toLowerCase().indexOf(self.query.toLowerCase())>-1;
                    self.treeFilterMethod(child);
                })
                if (!node.visible && childNodes.length) {
                    let allHidden = true;
github UnforbiddenYet / react-sleek-photo-gallery / src / components / scroller.js View on Github external
containerWidth,
      velocityX
    } = props;

    const [leftEdge, rightEdge] = calculateEdgeTranslateXDistances({ thumbnails, containerWidth });

    this.state = {
      leftEdge,
      rightEdge,
      scrollerTranslateX: leftEdge
    };

    this.lastTranslateX = leftEdge;
    this.VELOCITY_X = velocityX || 1;

    this.throttledHandleWheel = throttle(100, this.throttledHandleWheel);
  }
github yelog / layui-soul-table / documents / pages / zh-CN / component.vue View on Github external
mounted() {
    this.componentScrollBar = this.$refs.componentScrollBar
    this.componentScrollBox = this.componentScrollBar.$el.querySelector('.el-scrollbar__wrap')
    this.throttledScrollHandler = throttle(300, this.handleScroll)
    this.componentScrollBox.addEventListener('scroll', this.throttledScrollHandler)
    this.renderAnchorHref()
    this.goAnchor()
    document.body.classList.add('is-component')
  },
  destroyed() {
github Leopoldthecoder / Perspective / src / scroller.js View on Github external
addEventListeners() {
    this.boundHandleScroll = this.handleScroll.bind(this)
    this.throttledHandleStepChange = throttle(50, true, this.handleStepChange, true)
    document.addEventListener('wheel', this.boundHandleScroll)
  }
github poketo / poketo-reader / src / components / home-intro.js View on Github external
this.timerId = setTimeout(() => {
      this.setState({ hasRendered: true });
    }, 100);

    window.addEventListener('resize', this.handleResize, false);
    requestAnimationFrame(this.tick);
  }

  componentWillUnmount() {
    window.removeEventListener('resize', this.handleResize, false);
    if (this.timerId) {
      clearTimeout(this.timerId);
    }
  }

  handleResize = throttle(100, () => {
    if (this.resizeHandler) {
      this.resizeHandler();
    }
    this.setupGrid();
    this.setupField();
    this.setState({
      windowSizeKey: getWindowSizeKey(),
    });
    if (this.ctx) {
      this.renderField(this.ctx);
    }
  });

  setupGrid = () => {
    const canvas = this.canvas;

throttle-debounce

Throttle and debounce functions.

MIT
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis