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

Adding progress bar to index and about page #169

Merged
merged 1 commit into from
Oct 20, 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
6 changes: 6 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
</head>

<body>
<div class="header">
<div class="progress-container">
<div class="progress-bar" id="myBar"></div>
</div>
</div>

<div class="banner section">
<nav>
<div class="logo">
Expand Down
21 changes: 21 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
scroll-behavior: smooth;
}

/* progress bar: fixed position (always stay at the bottom) */
.header {
position: fixed;
bottom: 0;
z-index: 1;
width: 100%;
background-color: #f1f1f1;
}

/* The progress container (grey background) */
.progress-container {
width: 100%;
height: 8px;
background: #ccc;
}

.progress-bar {
height: 8px;
background: #04AA6D;
width: 0%;
}
/*scroll to top button*/
#scrollToTopBtn {
display: none;
Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
</head>

<body>
<div class="header">
<div class="progress-container">
<div class="progress-bar" id="myBar"></div>
</div>
</div>
<button id="scrollToTopBtn" title="Go to top">
<i class="fa fa-arrow-up"></i>
</button>
Expand Down
9 changes: 9 additions & 0 deletions scripts/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ closePopupButton.addEventListener("click", function () {
overlay.style.display = "none";
});

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

function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}

const close = document.querySelectorAll(".navclose");
document.getElementById("openMenu").addEventListener("click", function () {
document.getElementById("menuContainer").style.display = "flex";
Expand Down
8 changes: 8 additions & 0 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@

window.addEventListener('scroll', handleScroll);

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

function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("myBar").style.width = scrolled + "%";
}