我有一个脚本,它在滚动的HTML5应用程序中触发各种淡出/菜单显示--脚本是通过IScroll的滚动高度触发的,如下所示-
onScrollMove: function() {
var thisScrol = myScroll.getScrollY()
if (thisScrol < -70 ){
bgfadeToggle('on');
notifToggle('on');
}
if (thisScrol > -70){
bgfadeToggle('off');
notifToggle('off');
}
},供参考之用如下:
function notifToggle(whichOne){
if (whichOne == "on" && fifth == "yes"){
setTimeout(function() {fifth="no";}, 10)
$('.notificationArea .notif').animate({
opacity: 0
}, 1500);
}
if (whichOne == "off" && fifth == "no"){
setTimeout(function() {fifth="yes";}, 10)
$('.notificationArea .notif').animate({
opacity:1
}, 2500);
}
}
//Move footer ul depending on scroll position
function bgfadeToggle(which){
if (which == "on" && first == "yes"){
setTimeout(function() {first="no";$('#wrapper').addClass('hov'); }, 10)
$('.appearLate').fadeIn('1000');
$('.footer ul ').animate({
bottom: [ "-40", "linear" ],
opacity: "0"
}, 100, "linear");
$( ".appearLate" ).animate({
top: [ "-1", "swing" ],
opacity: "1"
}, 500, "linear");
}剧本写得很好除非..。你快速地上下滚动--这同时触发了两个脚本--这意味着事情在错误的时间消失并再次出现--有什么方法可以阻止脚本这样的反应--即在另一个运行的时候禁用一个函数?
有什么想法吗?
发布于 2013-09-03 09:11:51
使用stop()停止当前运行的动画
$('.notificationArea .notif').stop().animate({
opacity: 0
}, 1500);或
stop(true,true)在参数中为true时,队列中的其余动画将被删除,在这种情况下永远不会使用run.Usually stop(true,true)。
https://stackoverflow.com/questions/18588262
复制相似问题