You can capture a touch event using 'touchstart' instead of 'click', because the click event sometimes does not fire until the pulse scrolls. Try this jQuery solution:
$('#yourTrigger').on('touchstart', function () { var $div = $('.yourScrollableDiv'); if ($div.scrollTop() === 0) { return false; //if no scroll needed, do nothing. } $div.addClass('scrolling'); //apply the overflow:hidden style with a class $div.animate({ scrollTop: 0 }, 600, function () { $div.removeClass('scrolling'); //scrolling has finished, remove overflow:hidden }); }
where the scroll class simply has the CSS property, overflow: hidden, which, as Patrick-Rudolph said, will stop the scroll scroll.
.scrolling { overflow: hidden; }
Note. It is best to use the callback function to indicate when the scroll animation ends, rather than setting the timer function.
anthony
source share