Jquery 如何判断页面是否一直滚动到一侧

Jquery 如何判断页面是否一直滚动到一侧,jquery,scroll,Jquery,Scroll,我有一个页面溢出了视口。用户可以滚动或滑动查看整个页面。我想根据用户滚动的距离将消息从“向右滑动”更改为“向左滑动”,但我遇到了问题。我如何知道何时已横向滚动到末尾?有人能帮忙吗 var totalWidth=$('.container').width(); $(窗口)。滚动(函数(){ var documentScrollLeft=$(document.scrollLeft(); //switch命令根据用户滚动到的点向左或向右滑动 如果(documentScrollLeft>=宽度){ $

我有一个页面溢出了视口。用户可以滚动或滑动查看整个页面。我想根据用户滚动的距离将消息从“向右滑动”更改为“向左滑动”,但我遇到了问题。我如何知道何时已横向滚动到末尾?有人能帮忙吗

var totalWidth=$('.container').width();
$(窗口)。滚动(函数(){
var documentScrollLeft=$(document.scrollLeft();
//switch命令根据用户滚动到的点向左或向右滑动
如果(documentScrollLeft>=宽度){
$('.swipe').html(“向左滑动”);
}否则{
$('.swipe').html(“向右滑动”);
}
});
.container{
显示器:flex;
/*对齐项目:居中*/
/*宽度:100%*/
位置:绝对位置;
排名:0;
左:0;
/*高度:100vh*/
边际上限:0px;
}
@仅介质屏幕和(最大宽度:1024px){
.集装箱{
顶部:32px;
}
}
.小组{
高度:100vh;
/*宽度:25%*/
}

向右滑动

这是您的起点,只需设置逻辑即可

var lastScrollLeft = 0;
$(window).scroll(function() {
    var documentScrollLeft = $(document).scrollLeft();
    if (lastScrollLeft != documentScrollLeft) {
        console.log('horizontal scroll x');
        lastScrollLeft = documentScrollLeft;
    }
});
我正在使用此代码(请参阅)。当页面接近向右滚动时,它会起作用:

if ($(window).scrollLeft() + $(window).width() > $(document).width() - 100) {
 //code here
}

是的,但我如何知道何时以响应的方式更改右/左标志?