Skip to content

Commit

Permalink
Fixed navbar bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GazdagB committed Feb 21, 2024
1 parent 0543be2 commit d91d2c5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,21 @@ function openMobileNav(){




document.addEventListener("scroll", ()=>{

let scrollTimeout;
document.addEventListener("scroll", () => {
const visibility = primaryNav.getAttribute('data-visible');

if(visibility === 'false'){
if(window.scrollY > 0){
setTimeout(() => {
header.classList.add("scrolled");
}, 400);
}else{
header.classList.remove("scrolled");
}
// Töröld az előző timeout-ot, ha van
clearTimeout(scrollTimeout);

if (visibility === 'false' && window.scrollY > 0) {
// Állíts be egy új timeout-ot
scrollTimeout = setTimeout(() => {
header.classList.add("scrolled");
}, 200);
} else {
// Ha felfelé görgetsz, vagy a mobile-nav nyitva van, akkor azonnal töröld a "scrolled" class-t
header.classList.remove("scrolled");
}
});

Expand Down

0 comments on commit d91d2c5

Please sign in to comment.