Bug 230545 - Pinch to zoom gesture should map to mousewheel with the control key
Summary: Pinch to zoom gesture should map to mousewheel with the control key
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2021-09-21 03:57 PDT by Thomas Steiner
Modified: 2021-09-28 03:58 PDT (History)
4 users (show)

See Also:

Compat table (421.67 KB, image/png)
2021-09-21 03:57 PDT, Thomas Steiner
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Steiner 2021-09-21 03:57:54 PDT
Created attachment 438802 [details]
Compat table

Firefox [1] and Chrome [2] both map pinch-to-zoom gestures to the WheelEvent with the meta key pressed (see attached screenshot for compatibility). This makes detecting zoom gestures super easy, but it's hard to do the same in Safari. `GestureEvent` is not supported on any other browser [3], so it would be nice if Safari supported the mapping mentioned above.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1052253
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=289887
[3] https://developer.mozilla.org/en-US/docs/Web/API/GestureEvent#browser_compatibility
Comment 1 Thomas Steiner 2021-09-21 03:59:17 PDT
Addendum: The standards-based Safari way is documented in https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events/Pinch_zoom_gestures.
Comment 2 Alexey Proskuryakov 2021-09-21 09:37:44 PDT
Why do we want web pages to detect zooming? As a user, I just want the browser to zoom, and absolutely don't want the webpage to change anything as I'm doing that.
Comment 3 Thomas Steiner 2021-09-21 09:53:52 PDT
The use case here would be pinch-zooming parts of an app. Example: go to https://jakearchibald.github.io/svgomg/, click “Demo” and pinch-zoom the 🚗.
Comment 4 Simon Fraser (smfr) 2021-09-21 10:18:22 PDT
This was implemented in https://bugs.webkit.org/show_bug.cgi?id=225788

*** This bug has been marked as a duplicate of bug 225788 ***
Comment 5 Thomas Steiner 2021-09-21 10:34:41 PDT
Oh, that’s amazing and I missed this. Thanks for implementing this! Can you tell me as of which Safari release on mobile this will land? I think it’s not part of iOS 15, but I may be wrong.
Comment 6 Simon Fraser (smfr) 2021-09-21 10:47:39 PDT
The implementation was macOS-only (we only dispatch wheels events on iOS when using the Magic Keyboard, and there you have a trackpad which supports pinch-zoom already).

You can test in Safari Tech Preview on Mac.
Comment 7 Thomas Steiner 2021-09-21 11:24:50 PDT
Thanks, Simon, this explains why I wasn’t seeing it on mobile Safari. Since Firefox and Chrome on Android expose this (see https://bugs.webkit.org/attachment.cgi?id=438802), could you consider exposing this as well?
Comment 8 Simon Fraser (smfr) 2021-09-21 11:33:30 PDT
To be clear, are you expecting pinch-zoom on the iPhone/iPad screen to generate wheel events with the Ctrl key set?
Comment 9 Thomas Steiner 2021-09-21 11:59:54 PDT
Yes, since this lets developers create zoom UIs as needed in apps like the linked one above purely by listening for the `wheel` event and working with `ev.deltaY`. Here’s an example: https://developer.mozilla.org/en-US/docs/Web/API/Element/wheel_event#examples.
Comment 10 Simon Fraser (smfr) 2021-09-21 12:04:27 PDT
Not a dup then.
Comment 11 Simon Fraser (smfr) 2021-09-21 15:33:25 PDT
One reason we don't do this when users interact with the screen is that there is no pointer. You'd have to use the centroid of the fingers as the wheel event location, and that's different from what users are used to.
Comment 12 Radar WebKit Bug Importer 2021-09-28 03:58:15 PDT