Created
December 25, 2017 17:25
-
-
Save elinwibe/18e0cb30cbcf51723ba23e64ee79f221 to your computer and use it in GitHub Desktop.
Scroll Progress Bar 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
window.onscroll = function() {myFunction()}; | |
function myFunction() { | |
var winScroll = document.documentElement.scrollTop; | |
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight; | |
var scrolled = (winScroll / height) * 100; | |
document.getElementById("#").style.width = scrolled + "%"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment