-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloader.html
38 lines (35 loc) · 969 Bytes
/
loader.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<style>
body {
margin: 0;
padding: 0;
height: 2000px; /* Add enough content to enable scrolling */
}
#progress-bar {
position: fixed;
top: 0;
left: 0;
width: 0;
height: 3px;
background-color: #0077ff;
z-index: 999;
transition: width 1s ease; /* Add a smooth transition effect */
}
</style>
</head>
<body>
<div id="progress-bar"></div>
<script>
const progressBar = document.getElementById("progress-bar");
window.addEventListener("scroll", function () {
const scrollTop =
window.pageYOffset || document.documentElement.scrollTop;
const totalHeight = document.body.clientHeight - window.innerHeight;
const scrollPercentage = (scrollTop / totalHeight) * 100;
progressBar.style.width = scrollPercentage + "%";
});
</script>
</body>
</html>