GameExpo23/DV8-Expo/website/static/js/nav.js

15 lines
No EOL
468 B
JavaScript

window.onscroll = () => { scrollFunction() };
window.onload = () => { scrollFunction() };
function scrollFunction() {
let nav = document.querySelector("nav");
// let scrollHeight = window.innerHeight - nav.offsetHeight;
let scrollHeight = 0;
if (document.body.scrollTop > scrollHeight ||
document.documentElement.scrollTop > scrollHeight) {
nav.classList.add("scrolled");
} else {
nav.classList.remove("scrolled");
}
}