Skip to content

Instantly share code, notes, and snippets.

@brianswisher
Created December 7, 2015 15:18
Show Gist options
  • Save brianswisher/e43dc602ebda29e4d79e to your computer and use it in GitHub Desktop.
Save brianswisher/e43dc602ebda29e4d79e to your computer and use it in GitHub Desktop.
Get Scroll Amount; returns {left:NUM, top:NUM}
(()=>{
function getScrollAmount(){
const doc = document.documentElement;
return {
left: (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0),
top: (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0)
};
}
return getScrollAmount();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment