【发布时间】:2013-06-04 17:22:40
【问题描述】:
我正在尝试在使用mCustomScollbar 滚动时制作动画
我能够获取当前的scrollTop 并使用以下代码使其在特定高度上进行动画处理:
$("#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'});
}
但如果我尝试使用这段代码使动画倒退:
if(top < 180){
$('#topbar').animate({opacity:'1'});
}
这部分失败了,一旦添加,animate({opacity:0}) 不知何故需要很长时间才能开始动画。
预览:
【问题讨论】:
标签: jquery html css scroller mcustomscrollbar