Rename scroll position variable

This commit is contained in:
Leilukin 2024-04-18 13:19:33 +08:00 committed by Helen Chong
parent 70adf44cff
commit 470904c0a5

View File

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