Scrolling pulse force stop on iphone / ipad in javascript

Is it possible to scroll momentum with forced stop on iphone / ipad in javascript?

Additionally: Iโ€™m pretty sure that this is a pie in the sky, but for bonus points (honor and prestige), after manipulating the domino and applying scrollTo, resume scrolling with the same impulse before forcibly stopping. How?

+7
source share
2 answers

This is really possible using fastclick.js . Lib removes the 300 ms delay delay on mobile devices and allows you to capture events during inertia / impulse scrolling.

After enabling fastclick and attaching it to the body element, my code to stop scrolling and jump to the beginning looks like this:

scrollElement.style.overflow = 'hidden'; scrollElement.scrollTop = 0; setTimeout(function() { scrollElement.style.overflow = ''; }, 10); 

The trick is to set overflow: hidden , which stops the inertia / impulse scrolling. Please see My script for the full implementation of stopping scroll during inertia / impulse .

+7
source

Here is my code using jQuery animation (works like an onclick event)

 var obj=$('html, body'); // your element if(!obj.is(':animated')) { obj.css('overflow', 'hidden').animate({ scrollTop: 0 }, function(){ obj.css('overflow', ''); }); } 

Tested on iPhone 6

0
source

All Articles