I am making some plugin and I need to get maximum scrollTop
value of the document.
Maximum scrollTop
value is 2001
, but $(docum
In vanilla Javascript I'm currently doing this:
getScrollTopMax = function () {
var ref;
return (ref = document.scrollingElement.scrollTopMax) != null
? ref
: (document.scrollingElement.scrollHeight - document.documentElement.clientHeight);
};
This returns Gecko's non-standard scrollTopMax if it exists, otherwise calculates it. I'm using document.scrollingElement
here, which only exists on particular browsers, but it's easy to polyfill.