How to use the dom-helpers/query/scrollLeft 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 / index.js View on Github external
scrollToTarget(element, target) {
    if (typeof target === 'string') {
      const targetElement =
        document.getElementById(target) ||
        document.getElementsByName(target)[0];
      if (targetElement) {
        targetElement.scrollIntoView();
        return;
      }

      // Fallback to scrolling to top when target fragment doesn't exist.
      target = [0, 0]; // eslint-disable-line no-param-reassign
    }

    const [left, top] = target;
    scrollLeft(element, left);
    scrollTop(element, top);
  }
}
github taion / scroll-behavior / src / ScrollBehavior.js View on Github external
_updateElementScroll(key, prevContext, context) {
    const { element, shouldUpdateScroll } = this._scrollElements[key];

    const scrollTarget = this._getScrollTarget(
      key, shouldUpdateScroll, prevContext, context
    );
    if (!scrollTarget) {
      return;
    }

    // Unlike with the window, there shouldn't be any flakiness to deal with
    // here.
    const [x, y] = scrollTarget;
    scrollLeft(element, x);
    scrollTop(element, y);
  }
github taion / scroll-behavior / src / ScrollBehavior.js View on Github external
_savePosition(key, element) {
    // 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(
      this._getKey(this._getCurrentLocation(), key),
      [scrollLeft(element), scrollTop(element)]
    );
  }
github taion / scroll-behavior / src / ScrollBehavior.js View on Github external
_onWindowScroll = () => {
    // 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.
    if (this._saveWindowPositionHandle === null) {
      this._saveWindowPositionHandle =
        requestAnimationFrame(this._saveWindowPosition);
    }

    if (this._windowScrollTarget) {
      const [xTarget, yTarget] = this._windowScrollTarget;
      const x = scrollLeft(window);
      const y = scrollTop(window);

      if (x === xTarget && y === yTarget) {
        this._windowScrollTarget = null;
        this._cancelCheckWindowScroll();
      }
    }
  };
github taion / react-router-scroll / test / useScroll.spec.js View on Github external
() => {
                expect(prevPosition).to.eql([10, 15000]);
                expect(position).to.not.exist;

                expect(scrollLeft(window)).to.not.equal(0);
                expect(scrollTop(window)).to.not.equal(0);

                scrollLeft(window, 0);
                scrollTop(window, 0);

                delay(() => history.goBack());
              },
              () => {
github taion / react-router-scroll / test / useScroll.spec.js View on Github external
() => {
                expect(prevPosition).to.eql([10, 15000]);
                expect(position).to.not.exist;

                expect(scrollLeft(window)).to.not.equal(0);
                expect(scrollTop(window)).to.not.equal(0);

                scrollLeft(window, 0);
                scrollTop(window, 0);

                delay(() => history.goBack());
              },
              () => {
github taion / scroll-behavior / src / index.js View on Github external
_savePosition(key, element) {
    this._stateStorage.save(this._getCurrentLocation(), key, [
      scrollLeft(element),
      scrollTop(element),
    ]);
  }