Skip to content

Instantly share code, notes, and snippets.

@qubyte
Created October 13, 2016 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qubyte/a8e259e2d6ce85ce5a29bd64bcf4896f to your computer and use it in GitHub Desktop.
Save qubyte/a8e259e2d6ce85ce5a29bd64bcf4896f to your computer and use it in GitHub Desktop.
Little function to get the amount a document has been scrolled by.
function getScrollAmount() {
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
return scrollTop / (scrollHeight - document.documentElement.clientHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment