javascript - Stop ScrollTop function when user scrolls jquery - Stack Overflow

How can i stop the scrollTop function when the user scrolls himself? If i scroll now while the scrollTo

How can i stop the scrollTop function when the user scrolls himself? If i scroll now while the scrollTop function the whole scrolling glitches out.

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

I tried this so far but the alert scrolling isnt showing up for me and i can't find a solution on google so im asking it here.

I hope someone knows how to fix this thanks!

How can i stop the scrollTop function when the user scrolls himself? If i scroll now while the scrollTop function the whole scrolling glitches out.

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

I tried this so far but the alert scrolling isnt showing up for me and i can't find a solution on google so im asking it here.

I hope someone knows how to fix this thanks!

Share Improve this question asked Oct 15, 2014 at 9:37 StefanStefan 1,9057 gold badges25 silver badges38 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

you need to unbind or stop the animation when user scrolls, sth like

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

Hey I just wrote that code today for a project I'm working on:

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743958048a4536151.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信