Handy cross-browser utilities to get scrollTop and scrollHeight of the whole document
document.documentElement.scrollHeight
and document.documentElement.scrollTop
don't work in all browsers.
For more information, see: Window sizes and scrolling
npm:
npm install window-scroll-util --save
Yarn:
yarn add window-scroll-util
import {
getDocumentScrollHeight,
getDocumentScrollTop,
getDocumentClientHeight,
getDocumentScrollBottom,
} from 'window-scroll-util';
const scrollHeight = getDocumentScrollHeight();
const scrollTop = getDocumentScrollTop();
const clientHeight = getDocumentClientHeight();
const scrollBottom = getDocumentScrollBottom(); // scrollHeight - scrollTop - clientHeight
MIT