When scrolling up, detecting strange behavior
I am trying to animate a menu bar (fixed position) when its scroll down the opacity should change to 0.6, and when the scrollTop () returns 0, its opacity should be 1.
It works fine when I scroll down, but when I scroll up, sometimes the code works multiple times, its opacity stays 0.6.
$(document).ready(function(){
$(window).scroll(function(){
if($(window).scrollTop() > 0){
$('.navbar').animate({opacity:0.6});
}
if($(window).scrollTop() <= 0){
$('.navbar').css('opacity','1');
}
});
});
+3
source to share