I currently am using the following code to auto-scroll to the top on a callback from a swipe detect script. I want to add the ability to cancel the animation when the user clicks the screen during the animation.
$('body,html').animate({
scrollTop: 0
}, 300);
How would I accomplish this cancelation?
Use the
stopmethod to stop the animation. Make sure to passfalsefor thejumpToEndparameter so the user isn’t automatically taken to the top of the screen.Live example – http://jsfiddle.net/FcLbH/2/
Edit – Removed the parameters to
stopper @AvL’s comment.