Scroll Progress (get)
See original GitHub issue👉 Conclusion / Feature Specification
The discussion in this issue has resulted in a decision to implement the following API method:
// get scroll progress
// returns a number representing % scrolled of scrollable distance.
// 0 is start position and 1 is end position
embla.scrollProgress()
Example Usage
embla.on('scroll', () => {
console.log(`Current progress is: ${embla.scrollProgress() * 100}%`)
}
CodeSandbox
See example usage.
Special thanks
@xiel for discussing this and sharing your thoughts and ideas. @welteki for the nice demonstration.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:11 (10 by maintainers)
Top Results From Across the Web
How To Create a Scroll Indicator - W3Schools
We have created a "progress bar" to show how far a page has been scrolled. It also works when you scroll back up....
Read more >Scroll progress indicator | Webflow University
Create a horizontal progress indicator that scales as visitors scroll down the page.
Read more >Page scroll progress with JavaScript | by Moin Uddin - Medium
I'll just define another function to be called whenever progress is updated. ... progress = (document.body.scrollTop / ( document.body.scrollHeight - window.
Read more >javascript - Scroll progress bar in an element - Stack Overflow
I am trying to make a scroll progress indicator on a div element. It works, but it only detects window scrolls and not...
Read more >How to Add a Page Scroll Progress Bar at the Top of Your ...
Let's add some additional styling to the indicator. First, find the link to the css/style.min.css CSS file in index.html and remove min from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @xiel and @welteki,
I’m happy to announce that the first part of this, the scroll progress getter has been released with version 2.5.0 🚀.
Read more here or check this CodeSandbox out.
Enjoy!
Yes, I would expect it to be an instant setter by default.