Created
October 13, 2016 17:17
-
-
Save qubyte/a8e259e2d6ce85ce5a29bd64bcf4896f to your computer and use it in GitHub Desktop.
Little function to get the amount a document has been scrolled by.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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