Last active
March 23, 2017 16:36
-
-
Save oboshto/0c0647920fe11963ba426e40d458d729 to your computer and use it in GitHub Desktop.
A little progress bar for scrolling
This file contains hidden or 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 setProgress() { | |
| let bar = document.querySelector('.js-content-bar'), | |
| content = document.body, | |
| max = content.scrollHeight - window.innerHeight, | |
| progressValue = content.scrollTop / max * 100; | |
| bar.setAttribute('value', progressValue); | |
| } | |
| window.addEventListener('scroll', setProgress); | |
| window.addEventListener('resize', setProgress); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment