How to use the dom-helpers/query/scrollTop 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 react-bootstrap / react-overlays / src / Affix.js View on Github external
onUpdate = () => {
    if (!this._isMounted) {
      return
    }

    const { offsetTop, viewportOffsetTop } = this.props
    const scrollTop = getScrollTop(ownerWindow(this))
    const positionTopMin = scrollTop + (viewportOffsetTop || 0)

    if (positionTopMin <= offsetTop) {
      this.updateState('top', null, null)
      return
    }

    if (positionTopMin > this.getPositionTopMax()) {
      if (this.state.affixed === 'bottom') {
        this.updateStateAtBottom()
      } else {
        // Setting position away from `fixed` can change the offset parent of
        // the affix, so we can't calculate the correct position until after
        // we've updated its position.
        this.setState(
          {
github taion / scroll-behavior / src / index.js View on Github external
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 / react-router-scroll / test / useScroll.spec.js View on Github external
() => {
                expect(scrollTop(window)).to.equal(15000);
                done();
              },
            ];
github taion / react-router-scroll / test / useScroll.spec.js View on Github external
() => {
                scrollTop(window, 15000);
                delay(() => history.push('/page2'));
              },
              () => {
github react-bootstrap / react-overlays / src / utils / calculatePosition.js View on Github external
function getContainerDimensions(containerNode) {
  let width, height, scroll;

  if (containerNode.tagName === 'BODY') {
    width = window.innerWidth;
    height = window.innerHeight;

    scroll =
      getScrollTop(ownerDocument(containerNode).documentElement) ||
      getScrollTop(containerNode);
  } else {
    ({ width, height } = getOffset(containerNode));
    scroll = getScrollTop(containerNode);
  }

  return { width, height, scroll};
}
github taion / scroll-behavior / src / index.js View on Github external
_savePosition(key, element) {
    this._stateStorage.save(this._getCurrentLocation(), key, [
      scrollLeft(element),
      scrollTop(element),
    ]);
  }
github taion / scroll-behavior / modules / utils / withScroll.js View on Github external
function onScroll() {
    if (!scrollTarget) {
      return
    }

    const [ xTarget, yTarget ] = scrollTarget
    const x = scrollLeft(window)
    const y = scrollTop(window)

    if (x === xTarget && y === yTarget) {
      scrollTarget = null
      cancelCheckScroll()
    }
  }
github react-bootstrap / react-overlays / src / utils / calculatePosition.js View on Github external
function getContainerDimensions(containerNode) {
  let width, height, scroll;

  if (containerNode.tagName === 'BODY') {
    width = window.innerWidth;
    height = window.innerHeight;

    scroll =
      getScrollTop(ownerDocument(containerNode).documentElement) ||
      getScrollTop(containerNode);
  } else {
    ({ width, height } = getOffset(containerNode));
    scroll = getScrollTop(containerNode);
  }

  return { width, height, scroll};
}