How to use the raf function in raf

To help you get started, we’ve selected a few raf 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 malte-wessel / react-custom-scrollbars / src / Scrollbars / index.js View on Github external
raf(callback) {
        if (this.requestFrame) raf.cancel(this.requestFrame);
        this.requestFrame = raf(() => {
            this.requestFrame = undefined;
            callback();
        });
    }
github wuhao000 / antd-mobile-vue / src / packages / sticky / container.tsx View on Github external
public notifySubscribers(evt) {
    if (!this.framePending) {
      const {currentTarget} = evt;

      this.rafHandle = raf(() => {
        this.framePending = false;
        const {top, bottom} = this.node.getBoundingClientRect();

        this.subscribers.forEach(handler =>
          handler({
            distanceFromTop: top,
            distanceFromBottom: bottom,
            eventSource: currentTarget === window ? document.body : this.node
          })
        );
      });
      this.framePending = true;
    }
  }
github mobkits / images-preview / src / index.js View on Github external
function animate() {
      raf(animate)
      tween.update()
    }
github phil303 / react-touch / src / Touchable.js View on Github external
handleTouchMove(e) {
    e.preventDefault();
    if (!this._updatingPosition) {
      const { clientX: x, clientY: y } = e.touches[0];
      raf(() => this._updatePosition({x, y}));
    }
    this._updatingPosition = true;
    this._clearHoldTimers();
  }
github ameyms / react-animated-number / src / AnimatedNumber.jsx View on Github external
prepareTween() {
        this.tweenHandle = raf((timestamp) => {
            this.tweenValue(timestamp, true);
        });

    }
github jonataswalker / scroll-watcher / src / internal.js View on Github external
runLoop() {
    this.rafId = raf(this.loopBound);
  }
github devgeeks / react-animated-views / src / animations / SlideLeft.js View on Github external
function slideLeftOut(action, component, done) {
  if (action === 'push') {
    raf(() => {
      component.setState({
        style: {
          transform: 'translate3d(0, 0, 0)',
          WebkitTransform: 'translate3d(0, 0, 0)',
          opacity: 1,
          zIndex: 1,
        },
      });
      raf(() => {
        component.setState({
          style: {
            transform: 'translate3d(-20%, 0, 0)',
            WebkitTransform: 'translate3d(-20%, 0, 0)',
            transition: 'all .4s cubic-bezier(.2, .7, .1, 1)',
            transitionProperty: 'transform, opacity',
            WebkitTransition: 'all .4s cubic-bezier(.2, .7, .1, 1)',
github wdfe / weweb / src / service / lib / sdk / scrollable.js View on Github external
function animate () {
      raf(animate)
      tween.update()
    }
github chemzqm / wept / src / component / toast.js View on Github external
function animate() {
    raf(animate)
    if (tween) tween.update()
  }
  animate()
github NSFI / ppfish-components / es / components / Anchor / Anchor.js View on Github external
var frameFunc = function frameFunc() {
    var timestamp = Date.now();
    var time = timestamp - startTime;
    var nextScrollTop = easeInOutCubic(time, scrollTop, targetScrollTop, 450);

    if (container === window) {
      window.scrollTo(window.pageXOffset, nextScrollTop);
    } else {
      container.scrollTop = nextScrollTop;
    }

    if (time < 450) {
      raf(frameFunc);
    } else {
      callback();
    }
  };

raf

requestAnimationFrame polyfill for node and the browser

MIT
Latest version published 6 years ago

Package Health Score

74 / 100
Full package analysis