Make the navbar sticky effect smoother

This commit is contained in:
Helen Chong 2024-04-18 13:22:55 +08:00
parent 4180752d42
commit 4208fd5e32
1 changed files with 1 additions and 1 deletions

View File

@ -67,7 +67,7 @@
window.addEventListener("scroll", () => { window.addEventListener("scroll", () => {
const scrollPosition = window.scrollY || document.documentElement.scrollTop; const scrollPosition = window.scrollY || document.documentElement.scrollTop;
const stickyLine = hero.scrollHeight - navbar.scrollHeight; const stickyLine = hero.scrollHeight - navbar.scrollHeight;
if (scrollPosition > stickyLine) { if (scrollPosition > stickyLine + 55) {
navbar.classList.add("nav--sticky"); navbar.classList.add("nav--sticky");
} else { } else {
navbar.classList.remove("nav--sticky"); navbar.classList.remove("nav--sticky");