Bug 145214 - Pinch-to-zoom has no JavaScript event and cannot be prevented, unlike Chrome
Summary: Pinch-to-zoom has no JavaScript event and cannot be prevented, unlike Chrome
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-20 11:12 PDT by evan.exe
Modified: 2017-03-10 00:39 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description evan.exe 2015-05-20 11:12:49 PDT
The trackpad pinch-to-zoom gesture currently zooms into the page, even on OS X. This is frustrating for web applications because it's often not what the user wants and there's no way for the developer to override this. For example, when a user pinches on https://www.google.com/maps they surely mean to zoom the map, not the page.

Chrome has recently copied this feature but they allow it to be overridden. Pinch gestures get mapped to wheel events with the control key pressed, and calling preventDefault() will prevent the page from zooming. This allows web applications to have custom handling for pinch gestures.

I'm currently working on a vector content editor for the web and this feature makes the Safari experience so broken for our users that we're considering just blocking Safari entirely and telling people to use Chrome instead. Is there any way to prevent WebKit from doing this on OS X? Maybe the "user-scalable=no" meta tag? Even better, is there a way to get the actual scale values from the pinch gesture?
Comment 1 thesmart 2015-05-20 13:43:43 PDT
I'd like to pile on that this feature is incredibly confusing to end-users.  Here are some grievances:

(1) pinch gesture is very sensitive, too easy to do by accident
(2) does not show zoom-level-% to inform the user of their zoom level
(3) zooming and then refreshing the page leaves the window zoomed, leading end-users to believe the site or their computer is broken (seriously!)
(4) ignores the Viewport meta tag "standard"
(5) no good way to detect zoom level or zoom events in JavaScript
(6) Apple Touchpad acts like a touch device, but does not trigger proper touch events

Giving Macbook TrackPad more touch-device-like capabilities is laudable, but failing to properly hook it up to existing touch APIs is hurting the end-user experience.
Comment 2 evan.exe 2015-05-20 17:57:47 PDT
Those are good points. However, the trackpad is a bit of an odd beast and doesn't map well to touch events. The touches are indirect and don't have screen-space positions. I'm much more in favor of something like the approach OS X takes where the gesture recognition has already been performed and you get separate pinch and rotate events. This could easily be added to the web platform either as new events or using existing events as Chrome has done. One easy way to introduce pinch-to-zoom that's less hacky than Chrome's approach could be to emit wheel events with the scale factor change in the deltaZ value.