iOS 7 and javascript gestures

I recently booted up a HTML5 application that was built from the start to be iPad friendly. One of the more intricate pieces of the app draws shapes with SVG and allows the user to move, resize and rotate them via the native iOS gestures. When I left it, everything was working fine, but today when I tried it only moving worked – two finger/pinch gestures weren’t doing anything.

I tracked this down to something specific with iOS 7 – the app still worked fine in iOS 6. The fix was rather easy, though I have no idea why this changed. It all has to do with the event handlers for the gesture events. Previously, I was hooking to these events as such:

container.ongesturestart = function(e) { ... }

This doesn’t work anymore (at least on SVG elements). Instead, you must hook with addEventListener:

container.addEventListener("gesturestart", function(event) { ... }, true|false);

Not sure why this changed, but if you find your gestures not working any longer this is likely the cause.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>