嘿,我有代码,每次执行后都必须延迟。但是,即使用户正在滚动,执行代码也不必工作。现在只有一次延迟
function delayf(){
delay = false;
return delay;
}
var delay = true;
$('.window').on('mousewheel', function (event) {
var elemId = $(this).attr('id'),
scrollDir = event.deltaY;
var indicatorL = $(".indicator_main").data("counter");
if (elemId == 'steps' && scrollDir < 0 && delay === false) {
if(indicatorL != "4"){
indicatorL = indicatorL + 1;
$(".indicator_main").data("counter", indicatorL);
$(".indicator_main").animate({ "left": "+=25%" }, "slow" );
$(".indicator_num").text("0" + indicatorL);
}
}
if(elemId == 'scen_wraper1' || elemId == 'scen_wraper2' || elemId == 'steps'){
event.preventDefault();
}
console.log(delay);
delay = true;
delay = setTimeout(delayf, 2000);
});