Skip to content

Instantly share code, notes, and snippets.

@brianswisher
Last active December 7, 2015 15:42
Show Gist options
  • Save brianswisher/a9edf8357c6e90a82977 to your computer and use it in GitHub Desktop.
Save brianswisher/a9edf8357c6e90a82977 to your computer and use it in GitHub Desktop.
Get scroll max return the current right & bottom scroll values; {right: number, bottom: number}
(()=>{
function getScrollAmount(){
const doc = document.documentElement;
return {
left: (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0),
top: (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
};
}
function getScrollMax(){
const scrollAmount = getScrollAmount();
return {
right: window.innerWidth + scrollAmount.left,
bottom: window.innerHeight + getScrollAmount().top
};
}
return getScrollMax();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment