$(window).scroll(function() {
if ($(this).scrollTop() > 0) {
$(".header-menu-layout").css("background-color", "white");
$(".header-menu-layout").animate({
backgroundColor: "white"
}, 300);
}
if ($(this).scrollTop() == 0) {
$(".header-menu-layout").css("background-color", "transparent");
$(".header-menu-layout").stop().animate({
backgroundColor: "transparent"
}, 300);
}
});
when the height is greater than 1px and above,
will run animate, and the background will turn white.
but find a fatal problem
is that he will run the first paragraph of fucntion
which causes the scrolling event to stop before he can produce animation.
because you monitor every time you scroll?
the method I refer to is
https://www.spectacles.com/
, but it doesn"t seem to be the case.