Jquery .animate() stop scrolling when user scrolls manually?

前端 未结 4 560
半阙折子戏
半阙折子戏 2020-12-04 14:21

I have set up a snippet that scrolls a page section into view when it\'s clicked, the problem is that if the user wants to scroll in the middle of the animation the scroll k

4条回答
  •  无人及你
    2020-12-04 14:51

    Try this

    $('html,body').scroll(function() {
        $(this).stop(true, false);
    });
    

    It will also remove all other animations from the element's queue, but it won't "jump" to the end of the current scroll animation.

提交回复
热议问题