website/assets/js/nav-scroll.js
2024-03-06 15:19:33 +01:00

17 lines
600 B
JavaScript

window.addEventListener('scroll', function() {
const navbar = document.getElementById('navbar');
const buttons = document.querySelectorAll('#navButton'); // Select all nav buttons
if (window.scrollY > 0) {
navbar.classList.add('scrolled');
buttons.forEach(button => {
button.classList.remove('light');
button.classList.add('dark');
});
} else {
navbar.classList.remove('scrolled');
buttons.forEach(button => {
button.classList.remove('dark');
button.classList.add('light');
});
}
});