Answer the question
In order to leave comments, you need to log in
Add/remove class after 200px scroll?
var oldScrollY = 0;
var div = document.querySelector('.site-header');
window.onscroll = function() {
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
var dY = scrolled - oldScrollY;
if ( dY > 0 ){
div.className = 'site-header site-header-top';
} else {
div.className = 'site-header site-header-bottom';
}
oldScrollY = scrolled;
}
Answer the question
In order to leave comments, you need to log in
Hanging an event on onscroll is a bad habit and outdated practice. Today there is an Intersection Observer for this .
The problem is that /?abrakadabra123 there is such a page, and it is the DirectoryIndex page defined in .htaccess.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question