这个问题很久以前就已在这里提出过:
但它从来没有得到最终的回答(或者我可能根本无法正确搜索).
是否可以检测scroll用户或jQuery animate函数是否触发了事件?
我正在尝试阻止scroll事件触发自己,同时做这样的事情:
$(document).scroll(function(){
$("html").stop(true);
var number = 400; //some other stuff is happening here
clearTimeout(tout);
tout = setTimeout(function(){
if(top == $(document).scrollTop()){
$("html").animate({
scrollTop: (number),
easing: "easeInQuad",
duration: 110
});
}
},120);
});
Run Code Online (Sandbox Code Playgroud)
这段代码似乎很合适:
$('#scroller').scroll(function(e) {
if (e.originalEvent) {
console.log('scroll happen manual scroll');
} else {
console.log('scroll happen by call');
}
});
Run Code Online (Sandbox Code Playgroud)
但是该originalEvent对象无法正确检测动画触发器.
有没有其他方法可以做到这一点?