I'm trying to make an animation while scrolling with mCustomScollbar
I'm able to get the current scrollTop
and make it animate on a specific height with the following code:
$("#content").mCustomScrollbar({
scrollButtons:{
enable:true
},
advanced:{
updateOnContentResize: true,
updateOnBrowserResize: true,
},
callbacks:{
onScrollStart:function(){ onScrollStart(); },
whileScrolling:function(){ WhileScrolling(); }
}
});
function WhileScrolling(){
var top = Math.abs(mcs.top);
if(top > 180){
$('#topbar').animate({opacity:'0'});
}
But if I try to make the animation backwards with this code:
if(top < 180){
$('#topbar').animate({opacity:'1'});
}
This part fails, and once added, the animate({opacity:0})
somehow takes a long time before it starts the animation.
preview: