Jquery检测用户交互

Geo*_*rge 5 html javascript jquery scroll jquery-animate

我有这段代码可以自动滚动页面并在用户与页面交互时停止动画。这在桌面设备上正常工作,但在 iphone 上不能正常工作。当用户尝试用手指滚动页面时,动画不会停止,直到到达页面底部。我能为此做什么?谢谢!

$("html,body").stop().animate({scrollTop: $(document).height()}, 2000);

// Stop the animation if the user scrolls. Defaults on .stop() should be fine
$("body,html").bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(e){
    $("html,body").stop();
});  
Run Code Online (Sandbox Code Playgroud)

Geo*_*rge 6

我在绑定区域中添加了它,它可以“touchstart touchmove”

$("body,html").bind("touchstart touchmove scroll mousedown DOMMouseScroll mousewheel keyup", function(e){
    $("html,body").stop();
});  
Run Code Online (Sandbox Code Playgroud)