Skip to content

Commit

Permalink
Merge pull request #206 from shashankgoud18/feature/scroll-progress-bar
Browse files Browse the repository at this point in the history
Added Scroll Progress Bar
  • Loading branch information
swaraj-das authored Oct 8, 2024
2 parents 4da66ee + a97d149 commit 8e3dc1b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"liveServer.settings.port": 5501
"liveServer.settings.port": 5502
}
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
</head>

<body>
<div id="progressBarContainer">
<div id="progressBar"></div>
</div>

<div class="container">

<div class="navbar">
Expand Down
16 changes: 15 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ function toggleMenu() {
menuList.style.maxHeight = "0px";
}
}

window.onscroll = function() {
updateProgressBar();
};


function updateProgressBar() {
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
var scrollHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrollPercent = (scrollTop / scrollHeight) * 100;

document.getElementById("progressBar").style.width = scrollPercent + "%";
}

document.addEventListener('DOMContentLoaded', () => {
console.log("Website loaded successfully!");
});
Expand Down Expand Up @@ -53,3 +65,5 @@ window.onload = () => {
themeToggle.checked = true;
}
};


16 changes: 16 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ button[type="submit"]:hover {
font-family: sans-serif;
}

#progressBarContainer {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 7px;
background-color: whitesmoke;
z-index: 9999;
}

#progressBar {
height: 100%;
width: 0%;
background: linear-gradient(to right, #fb5283, #ff3527);;
transition: width 0.2s ease;
}
*.dark-mode{
background-color: #493d3d;
color:#f1f1f1;
Expand Down

0 comments on commit 8e3dc1b

Please sign in to comment.