我创建了一个事件,以便在用户使用鼠标滚轮向下滚动时触发。但是,用户通过拖动滚动条向下滚动会发生什么?确定用户何时滚动使用滚动条向下滚动
我想通过拖动滚动条向下滚动时触发相同的事件,就好像他正在使用鼠标滚轮向下滚动一样。
这是我在搬运东西,现在的方式:
var mousewheelevt = (/Firefox/i.test(navigator.userAgent)) ? "DOMMouseScroll" : "mousewheel"
$(window).bind(mousewheelevt, function(e){
var evt = window.event || e
evt = evt.originalEvent ? evt.originalEvent : evt;
var delta = evt.detail ? evt.detail*(-40) : evt.wheelDelta
if(delta > 0) {
// some code in the future if it's up
}
else{
// some code if it's down (would like this block of code to be executed
when the user draggs down the scrollbar)
}
});
有什么建议?
谢谢ina advance!
你为什么不只是将它绑定到'$(window).on('scroll')'?我错过了什么吗? – Sunyatasattva
不知道,我没有使用过,因为我无法找到一种方法来确定每当我向下滚动。但现在我看到了一种方法,感谢minitech – kfirba