Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added scroll progress indicator bar #1769

Merged
merged 10 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>
<!-- Navigation bar section start -->
<header>
<nav class="navbar">
Expand Down
6 changes: 6 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const updateProgress = () =>{
const {scrollTop,scrollHeight} = document.documentElement;
const scrollPercent = `${(scrollTop/(scrollHeight-window.innerHeight)) * 100}%`;
document.querySelector('#progress-bar').style.setProperty('--progress',scrollPercent);
}
document.addEventListener('scroll',updateProgress);
window.addEventListener('scroll', () => {
const sections = document.querySelectorAll('.containers');
const navLinks = document.querySelectorAll('.nav-links');
Expand Down
10 changes: 9 additions & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ html {
line-height: 1.4;
scroll-behavior: smooth;
}

#progress-bar{
--progress: 0;
position: fixed;
height: 8px;
width: var(--progress);
background:linear-gradient(45deg,rgb(135, 113, 243),rgb(101, 74, 240));
z-index: 1000;
border-radius: 4px;
}
header {
position: sticky;
top: 0;
Expand Down