javascript - Jquery detect user interaction - Stack Overflow

I have this code that scrolls the page automatically and stops the animation when the user interacts wi

I have this code that scrolls the page automatically and stops the animation when the user interacts with the page. THis working properly on desktop devices but not on iphone. When the user try to scroll the page with his finger the animation doesn't stop until reach the bottom of the page. What can i do for this? Thanks!

$("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();
});  

I have this code that scrolls the page automatically and stops the animation when the user interacts with the page. THis working properly on desktop devices but not on iphone. When the user try to scroll the page with his finger the animation doesn't stop until reach the bottom of the page. What can i do for this? Thanks!

$("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();
});  
Share Improve this question asked Jun 15, 2013 at 9:22 GeorgeGeorge 2955 silver badges11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

I add this in the bind area and it works "touchstart touchmove"

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

If you need only to detect it once, you can use

$("body,html").one("touchstart touchmove scroll mousemove mousedown DOMMouseScroll mousewheel keyup", function(e){
    console.log('Detected');
});

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

相关推荐

  • javascript - Jquery detect user interaction - Stack Overflow

    I have this code that scrolls the page automatically and stops the animation when the user interacts wi

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信