website/assets/js/nav-scroll.js

18 lines
600 B
JavaScript
Raw Normal View History

2024-03-06 14:19:33 +00:00
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');
});
}
});