Skip to content

Instantly share code, notes, and snippets.

@elinwibe
Created December 25, 2017 17:25
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 elinwibe/18e0cb30cbcf51723ba23e64ee79f221 to your computer and use it in GitHub Desktop.
Save elinwibe/18e0cb30cbcf51723ba23e64ee79f221 to your computer and use it in GitHub Desktop.
Scroll Progress Bar by %
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