Rename scroll position variable

This commit is contained in:
Helen Chong 2024-04-18 13:19:33 +08:00
parent 3f727a9e8e
commit 4180752d42
1 changed files with 2 additions and 2 deletions

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");