我有这段代码可以自动滚动页面并在用户与页面交互时停止动画。这在桌面设备上正常工作,但在 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();
});
最佳答案
我将它添加到绑定(bind)区域,它可以“touchstart touchmove”
$("body,html").bind("touchstart touchmove scroll mousedown DOMMouseScroll mousewheel keyup", function(e){
$("html,body").stop();
});
关于javascript - Jquery检测用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17122079/