// progressBar main div
const progressBar = document.querySelector("#progress-bar");
//Whichever div will work based
const mainBlogSection = document.querySelector("main");
const animateProgressBar = () => {
let scrollDistance = -mainBlogSection.getBoundingClientRect().top;
let progressWidth =
(scrollDistance /
(mainBlogSection.getBoundingClientRect().height -
document.documentElement.clientHeight)) *
100;
let value = Math.floor(progressWidth);
progressBar.style.width = value + "%";
if (value < 0) {
progressBar.style.width = "0%";
}
};
window.addEventListener("scroll", animateProgressBar);
-
Notifications
You must be signed in to change notification settings - Fork 0
Create a dynamic Reading Progress Bar with HTML, CSS, and JavaScript to visually track reading progress on web pages.
Shahriyar-Hosen/progress-bar-page-topside-animation
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Create a dynamic Reading Progress Bar with HTML, CSS, and JavaScript to visually track reading progress on web pages.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published