我正在寻找一种方法来获取去抖动滚动事件的滚动方向。到目前为止,我可以消除滚动,但它不会触发我的条件上/下脚本。
var el = $(window);
lastY = el.scrollTop();
el.on('scroll', debounce(function(e) {
$('body').bind('DOMMouseScroll', function(e){
if(e.originalEvent.detail > 0) {
//scroll down
scrolldown();
console.log('Down');
}else {
//scroll up
scrollup();
console.log('Up');
}
//prevent page fom scrolling
return false;
});
//IE, Opera, Safari
$('body').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta < 0) {
//scroll down
scrolldown();
console.log('Down');
}else {
//scroll up
scrollup();
console.log('Up');
}
//prevent page fom scrolling
return false;
});
}, 200));