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

Scrolling Header Mod v1 October 6 2023 #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3874,6 +3874,11 @@
top: 0;
width: 100%;
z-index: 10000;
transition: top 0.3s; /*Added for the Scrolling Header*/
}

#header.hide { /*Added for the Scrolling Header*/
top: -4em; /* Adjust as needed to fully hide the header */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
top: -4em; /* Adjust as needed to fully hide the header */
top: -4em; /* Adjust as needed to fully hide the header */
visibility: hidden;

Useful for making sure our site works correctly w/ screen readers and accessibility tools: https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#accessibility_concerns

}

#header h1 {
Expand Down
17 changes: 17 additions & 0 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,20 @@ window.addEventListener("hashchange", shiftWindow);
function load() {
if (window.location.hash) shiftWindow();
}

// Functionality for the scrolling header
let lastScrollTop = 0;

window.addEventListener('scroll', function() {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;

if (scrollTop > lastScrollTop){
// When scrolling down
document.getElementById('header').classList.add('hide');
} else {
// When scrolling up
document.getElementById('header').classList.remove('hide');
}

lastScrollTop = scrollTop;
});