jQuery向左和向右滚动事件处理程序

jQuery向左和向右滚动事件处理程序,jquery,event-handling,Jquery,Event Handling,jQuery中是否有监视左右滚动的事件处理程序 我想做点像 $('document').ScrolledLeft(function() { console.log('user scrolled left!'); }) $('document').ScrolledRight(function() { console.log('user scrolled right!'); }) 有什么建议吗?来自另一个问题 查找jQuery滚动事件和$(document).scrollLef

jQuery中是否有监视左右滚动的事件处理程序

我想做点像

$('document').ScrolledLeft(function() {
    console.log('user scrolled left!');
})

$('document').ScrolledRight(function() {
    console.log('user scrolled right!');
})
有什么建议吗?

来自另一个问题


查找jQuery滚动事件和
$(document).scrollLeft()另一个问题只是捕获水平事件,并没有指定它是左滚动事件还是右滚动事件。我修改它来捕捉左右滚动。
var prevLeft = 0;
$(document).scroll( function(evt) {
    var currentLeft = $(this).scrollLeft();
    if(prevLeft != currentLeft) {
        prevLeft = currentLeft;
        console.log("I scrolled vertically.");
    }
});