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 all commits
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: 2 additions & 0 deletions assets/about/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>

<!-- Navigation bar section start -->
<header>
<nav class="navbar">
Expand Down
2 changes: 2 additions & 0 deletions assets/contact/contact.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>

<header>
<nav class="navbar">
<div class="image-logo">
Expand Down
2 changes: 2 additions & 0 deletions assets/contributors/contributor.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>

<header>
<nav class="navbar">
<div class="image-logo">
Expand Down
11 changes: 11 additions & 0 deletions assets/contributors/contributor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// Progress bar
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);

const hamBurger = document.querySelector(".hamburger");
const nMenu = document.querySelector(".nav-menu");

Expand Down
2 changes: 2 additions & 0 deletions assets/faq/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>

<!-- Navigation bar section start -->
<header style="position: fixed;font-family: 'Montserrat', sans-serif; width: 100%;">
<nav class="navbar">
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
<div class="loader-section section-right"></div>
</div>

<div id="progress-bar"></div>

<!-- Navigation bar section start -->
<header>
<nav class="navbar">
Expand Down
11 changes: 11 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// Progress Bar
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: 10 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,16 @@ html {
scroll-behavior: smooth;
}

#progress-bar {
--progress: 0;
position: fixed;
height: 8px;
width: var(--progress);
background: linear-gradient(45deg, rgb(68, 49, 161), rgb(36, 15, 141));
z-index: 1000;
border-radius: 4px;
}

header {
position: sticky;
top: 0;
Expand Down