Chapter 6: Touch and pointer events

To the main book page.

Buy it here Cover of the Mobile Web Handbook

The Mobile Web Handbook by Peter-Paul Koch. Published by Smashing Magazine GmbH.
ISBN 978-3-94454093-1

Author
Peter-Paul Koch
Design and illustrations
Stephen Hay
General editor
Vitaly Friedman
Technical editor
Stephanie Rieger
Copy editor
Owen Gregory
Further editing
Patrick Lauke, Max Firtman, Vasilis van Gemert
Production
Markus Seyfferth

Chapter 6 contains an in-depth discussion of the touch and pointer events, including philosophical questions such as whether we need separate events for separate interaction modes.

Errata

No errata found yet.

Links and additional information

Generic compatibility information for the touch events can be found in this table. The table doesn’t treat the pointer events, but at the moment they’re only supported by IE10+. I’ll update the page later.

Example scripts

A truly ancient dropdown menu script that I wrote for my 2006 book can be found on this page, about half way down.

I wrote this drag and drop script that works with both mouse and keyboard — though the keyboard interaction is not particularly smooth and frankly doesn’t make sense. Adding the touch and pointer events should be pretty easy and is left as an exercise for you.

This video of the mobile version of the Tagesschau site (the German TV news) demonstrates a click-based dropdown menu. You’ll see that it fits the mobile use case a lot better than a traditional mouseover-based one.

The Mobilism 2012 site contains the original scrolling layer script. It doesn’t work with the mouse for reasons discussed in the book, and I didn’t add pointer events, either. Should make a new version with pointer events.

The touch action event cascade

The touch events table contains detailed notes on the event cascade in a lot of browsers. It also has detailed notes on the scroll and contextmenu events. This table contains a quick overview of mobile events.

See this blog post for some more information about Safari’s cascade cancelling.

See this blog post for some more information about Safari’s event bubbling problems.

Anatomy of a click

300 milliseconds

4 to 20 pixels

Taking apart the touch events

Event coordinates; clientX/Y and pageX/Y compatibility.

Leaving the element test page

Pointer events

Chrome support for touch-action