Answer the question
In order to leave comments, you need to log in
How to make the scroll event not fire?
Good afternoon. I have a header that adds the header--fixed class when scrolling.
const header = document.querySelector('.header');
window.addEventListener('scroll', () => {
if (window.pageYOffset >= 1) {
header.classList.add('header--fixed');
} else {
header.classList.remove('header--fixed');
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question