Skip to content

Commit c8cca1e

Browse files
authored
Merge pull request #776 from Shariq2003/AdditionOfProgressBar
Addition of Progress Bar | Issue #748
2 parents b31df64 + 86669c6 commit c8cca1e

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<script src="https://unpkg.com/scrollreveal"></script>
2121
</head>
2222
<body>
23+
<div id="progressBarContainer">
24+
<div id="progressBar"></div>
25+
</div>
2326
<nav class="navbar">
2427
<div class="navbar-left" onclick="window.location.href=`index.html`">
2528
<img src="assets/recode-hive.png" alt="Recode Hive Icon" class="navbar-icon">

scripts/ScrollToTop.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,16 @@ function scrollToTop() {
3939

4040
requestAnimationFrame(animation); // Start the animation
4141
}
42+
43+
window.onscroll = function () {
44+
updateProgressBar();
45+
};
46+
47+
48+
function updateProgressBar() {
49+
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
50+
var scrollHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
51+
var scrollPercent = (scrollTop / scrollHeight) * 100;
52+
53+
document.getElementById("progressBar").style.width = scrollPercent + "%";
54+
}

styles/styles.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,3 +1391,20 @@ a {
13911391
right: 10px;
13921392
cursor: pointer;
13931393
}
1394+
1395+
#progressBarContainer {
1396+
position: fixed;
1397+
top: 0;
1398+
left: 0;
1399+
width: 100%;
1400+
height: 7px;
1401+
background-color: #333;
1402+
z-index: 9999;
1403+
}
1404+
1405+
#progressBar {
1406+
height: 100%;
1407+
width: 0%;
1408+
background: white;
1409+
transition: width 0.2s ease;
1410+
}

0 commit comments

Comments
 (0)