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();
});
Ifvisible. js is a crossbrowser lightweight solution that does just that. It can detect when the user switches to another tab and back to the current tab. It can also detect when the user goes idle and becomes active again.
Bellow is the function on how to check user if user is active or inactive using Javascript. On these events trigger, resetTime() function will trigger and time will be cleared. So if none of these event happen, then alertUser() function will be trigger. You can set any action in alertUser() method, that you want to do.
The change() is an inbuilt method in jQuery that is used to detect the change in value of input fields. This method works only on the “<input>, <textarea> and <select>” elements.
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');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With