Remove declaration of header variable

This commit is contained in:
Helen Chong 2024-04-12 00:13:44 +08:00
parent e8841afa78
commit bd2e9cfcee
1 changed files with 1 additions and 2 deletions

View File

@ -62,12 +62,11 @@
<script webc:keep webc:bucket="defer">
// Make the navigation bar sticky
const header = document.querySelector(".main-header");
const navbar = document.querySelector("navbar");
window.addEventListener("scroll", e => {
const scrollPos = window.scrollY || document.documentElement.scrollTop;
const stickyLine = header.scrollHeight - navbar.scrollHeight;
const stickyLine = document.querySelector(".main-header").scrollHeight - navbar.scrollHeight;
if (scrollPos > stickyLine) {
navbar.classList.add("sticky-nav");
} else {