Apply Transition effect when adding and remove class
Trying to add sliding transition effect when add and remove class. Tried to this sticky nav js below: lastScroll = 0; $(window).on('scroll',function() { var scroll = $(window).scrollTop(); if(scroll === 0){ $(".nav").removeClass("darkHeader"); } else if(lastScroll - scroll > 0) { $(".nav").addClass("darkHeader"); } else { $(".nav").removeClass("darkHeader"); } lastScroll = scroll; }); My Try: lastScroll = 0; $(window).on('scroll',function() { var scroll = $(window).scrollTop(); if(scroll === 0){ $(".nav").removeClass("darkHeader", 1000, "easeInOutQuad"); } else if(lastScroll - scroll > 0) { $(