当用户滚动jquery时,停止ScrollTop功能

Stop ScrollTop function when user scrolls jquery

本文关键字:停止 ScrollTop 功能 用户 滚动 jquery      更新时间:2023-09-26

当用户滚动自己时,我如何停止scrollTop函数?如果我现在滚动,而滚动顶部功能,整个滚动故障。

        $(document).ready(function (){
            $(".header-arrow-down").click(function (){
                $('html, body').animate({
                    scrollTop: $(".page-1").offset().top
                }, 1000);
            });
            $("body").scroll(function() {
                alert("scrolling");
            });
        });

到目前为止,我已经尝试过了,但提醒滚动并没有显示出来,而且我在谷歌上找不到解决方案,所以我在这里问它。

我希望有人知道如何解决这个问题,谢谢!

当用户滚动时,你需要解除绑定或停止动画,比如

$("html, body").bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(){
    $('html, body').stop();
});

嘿,我今天刚刚为我正在进行的一个项目写了代码:

$('body,html').bind('scroll mousedown wheel DOMMouseScroll mousewheel keyup', function(e){
    if (e.which > 0 || e.type == "mousedown" || e.type == "mousewheel"){
    $("html,body").stop();
    }
});