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

#153 resolved #156

Merged
merged 2 commits into from
Oct 18, 2024
Merged
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
23 changes: 20 additions & 3 deletions scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@
overlay.style.display = "none";
});

const close = document.querySelectorAll(".navclose");

document.getElementById("openMenu").addEventListener("click", function () {
document.getElementById("menuContainer").style.display = "flex";
});

document.getElementById("closeMenu").addEventListener("click", function () {
document.getElementById("menuContainer").style.display = "none";
});
document.querySelectorAll(".close").addEventListener("click", function () {
document.getElementById("menuContainer").style.display = "none";

// Ensure all elements with the class 'close' close the menu
document.querySelectorAll(".close").forEach((closeButton) => {
closeButton.addEventListener("click", function () {
document.getElementById("menuContainer").style.display = "none";
});
});

function handleClose() {
Expand All @@ -47,8 +51,11 @@
const nav = document.querySelector('nav');
const whereWePlantSection = document.querySelector('.locations');

let lastScrollTop = 0; // To track the last scroll position

// Function to add/remove dark background
function handleScroll() {
const currentScrollTop = window.pageYOffset || document.documentElement.scrollTop;
const sectionTop = whereWePlantSection.getBoundingClientRect().top;
const threshold = window.innerHeight * 0.1;

Expand All @@ -57,6 +64,16 @@
} else {
nav.classList.remove('dark');
}

if (currentScrollTop > lastScrollTop) {
// User is scrolling down, hide the navbar
nav.style.top = "-100px"; // Adjust based on navbar height
} else {
// User is scrolling up, show the navbar
nav.style.top = "0";
}

lastScrollTop = currentScrollTop;
}

window.addEventListener('scroll', handleScroll);