Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 867 Bytes

README.md

File metadata and controls

43 lines (29 loc) · 867 Bytes

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