Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
swaraj-das authored Oct 13, 2024
1 parent f6ba698 commit 3849733
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ function toggleMenu() {
}
}

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!");
});

// Show or hide the scroll-top button based on scroll position
window.addEventListener('scroll', function() {
const scrollTopButton = document.querySelector('.scroll-top');
Expand Down

0 comments on commit 3849733

Please sign in to comment.