Re: preventDefault research

On Tue, Apr 26, 2011 at 7:39 PM, Matt Brubeck <mbrubeck@mozilla.com> wrote:

> I'm doing some of my own research on preventDefault behavior for touch
> events, because we are busy implementing this in Firefox.  Here's a test
> page that others might find useful:
> http://limpet.net/w3/touchevents/preventDefault.html
>
> Safari, Android WebKit, and Opera Mobile 11 all display the following
> behaviors:
>
> 1) preventDefault on the touchstart event prevents scrolling and
> mouseup/mousedown/click events.
>
> 2) preventDefault on the touchmove event prevents scrolling.
>

I can be a bit more exact for Android/iOS:
I'm fairly sure that preventDefault only prevents scrolling on android if
you call it on the very first touchmove event.
On iOS, if you call preventDefault on a single touchmove event at any point
before scroll mode is entered then scrolling will be disabled for the
duration of the touch (not necessarily the very first touchmove).

Also note that if one finger has disabled page scrolling through a
preventDefault() on touchstart / touchmove, then a second touch that occurs
at the same time will not be able to scroll the page (at least on iOS).


> 3) preventDefault on the touchend event does NOT prevent scrolling or mouse
> events.
>
I believe that it will prevent a click from firing on the latest iOS and on
the Playbook.

Received on Wednesday, 27 April 2011 01:58:51 UTC