Skip to content

Commit 1990db7

Browse files
committed
Page Scroll Indicator
1 parent f85b2ed commit 1990db7

3 files changed

Lines changed: 195 additions & 0 deletions

File tree

13. Page Scroll Indicator/app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let indicator = document.querySelector(".scroll-indicator .progress");
2+
let scrollHeight =
3+
document.documentElement.scrollHeight - document.documentElement.clientHeight;
4+
5+
window.addEventListener("scroll", scroll);
6+
7+
function scroll() {
8+
let scrollTop = document.documentElement.scrollTop;
9+
let scrolled = (scrollTop / scrollHeight) * 100;
10+
indicator.style.width = `${scrolled}%`;
11+
}

0 commit comments

Comments
 (0)