How to use the dom-helpers/util/requestAnimationFrame function in dom-helpers

To help you get started, we’ve selected a few dom-helpers 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 taion / scroll-behavior / src / ScrollBehavior.js View on Github external
return;
    }

    const [x, y] = this._windowScrollTarget;
    window.scrollTo(x, y);

    ++this._numWindowScrollAttempts;

    /* istanbul ignore if: paranoid guard */
    if (this._numWindowScrollAttempts >= MAX_SCROLL_ATTEMPTS) {
      this._windowScrollTarget = null;
      return;
    }

    this._checkWindowScrollHandle =
      requestAnimationFrame(this._checkWindowScrollPosition);
  };
}
github marnusw / react-css-transition-replace / packages / react-css-transition-replace / src / ReactCSSTransitionReplaceChild.js View on Github external
queueClassAndNode(className, node) {
    this.classNameAndNodeQueue.push({
      className,
      node,
    })

    if (!this.rafHandle) {
      // The first animation frame is skipped when starting new transitions since
      // entering absolutely positioned elements in Chrome does not animate otherwise.
      this.rafHandle = raf(() => this.flushClassNameAndNodeQueueOnNextFrame())
    }
  }
github taion / scroll-behavior / modules / utils / withScroll.js View on Github external
if (!scrollTarget) {
      return
    }

    const [ x, y ] = scrollTarget
    window.scrollTo(x, y)

    ++numScrollAttempts

    /* istanbul ignore if: paranoid guard */
    if (numScrollAttempts >= MAX_SCROLL_ATTEMPTS) {
      scrollTarget = null
      return
    }

    checkScrollHandle = requestAnimationFrame(checkScrollPosition)
  }
github taion / scroll-behavior / modules / withStandardScroll.js View on Github external
function onScroll() {
      if (savePositionHandle !== null) {
        return
      }

      // It's possible that this scroll operation was triggered by what will be
      // a `POP` transition. Instead of updating the saved location
      // immediately, we have to enqueue the update, then potentially cancel it
      // if we observe a location update.
      savePositionHandle = requestAnimationFrame(() => {
        savePositionHandle = null

        const state = readState(currentKey)
        const scrollPosition = [ scrollLeft(window), scrollTop(window) ]

        // We have to directly update `DOMStateStorage`, because actually
        // updating the location could cause e.g. React Router to re-render the
        // entire page, which would lead to observably bad scroll performance.
        saveState(currentKey, { ...state, scrollPosition })
      })
    }
github taion / scroll-behavior / src / index.js View on Github external
return new Promise(resolve => {
      this._checkWindowScrollHandle = requestAnimationFrame(() =>
        resolve(this._checkWindowScrollPosition()),
      );
    });
  };
github reactjs / react-transition-group / src / CSSTransitionGroupChild.js View on Github external
queueClassAndNode(className, node) {
    this.classNameAndNodeQueue.push({
      className,
      node,
    });

    if (!this.rafHandle) {
      this.rafHandle = raf(() => this.flushClassNameAndNodeQueue());
    }
  }
github marnusw / react-css-transition-replace / packages / react-css-transition-replace / src / ReactCSSTransitionReplaceChild.js View on Github external
flushClassNameAndNodeQueueOnNextFrame() {
    this.rafHandle = raf(() => this.flushClassNameAndNodeQueue())
  }
github marnusw / react-css-transition-replace / packages / react-css-transition-replace / src / ReactCSSTransitionReplace.js View on Github external
enqueueHeightTransition() {
    if (!this.rafHandle) {
      this.rafHandle = raf(this.performHeightTransition)
    }
  }