Skip to content

Handy cross-browser utilities to get scrollTop and scrollHeight of the whole document

License

Notifications You must be signed in to change notification settings

shuboc/window-scroll-util

Repository files navigation

Window Scroll Utility

Handy cross-browser utilities to get scrollTop and scrollHeight of the whole document

Why?

document.documentElement.scrollHeight and document.documentElement.scrollTop don't work in all browsers.

For more information, see: Window sizes and scrolling

Installation

npm:

npm install window-scroll-util --save

Yarn:

yarn add window-scroll-util

Usage

import {
  getDocumentScrollHeight,
  getDocumentScrollTop,
  getDocumentClientHeight,
  getDocumentScrollBottom,
} from 'window-scroll-util';

const scrollHeight = getDocumentScrollHeight();
const scrollTop = getDocumentScrollTop();
const clientHeight = getDocumentClientHeight();
const scrollBottom = getDocumentScrollBottom(); // scrollHeight - scrollTop - clientHeight

License

MIT

About

Handy cross-browser utilities to get scrollTop and scrollHeight of the whole document

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published