-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix double tap zoom on iOS 13 #9757
Conversation
fix #9756 iOS 13 does not fire the second touchstart/end events in a double tap if the touchstart listener is non-passive. This fix makes it passive. Calling preventDefault() allows the second event to be fired but suppresses other events like `click`. `touchmove` needs to remain non-passive so that it can be used to prevent touches from scrolling or scaling the page on some versions of iOS Safari.
Note: changing the listener to passive means that this won't prevent a click event from being fired anymore:
This might be considered a breaking change but:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this in iOS 13 Chrome and Safari and both worked as expected while 1.10.1 did not. I'd approve this but I think the fact that map.on('touchstart', e => e.originalEvent.preventDefault());
no longer works may deserve some discussion. It's not officially supported but preventing the original event seems to be a fairly common use case and we do point it out as a possible solution. Vlad did so on a ticket today #9755 (comment) albeit for touchmove
. It also seems weird that this workaround would be available for every event except for touchstart
.
The linked example uses I see no other way of working around this browser bug |
fix #9756 iOS 13 does not fire the second touchstart/end events in a double tap if the touchstart listener is non-passive. This fix makes it passive. Calling preventDefault() allows the second event to be fired but suppresses other events like `click`. `touchmove` needs to remain non-passive so that it can be used to prevent touches from scrolling or scaling the page on some versions of iOS Safari.
fix #9756 iOS 13 does not fire the second touchstart/end events in a double tap if the touchstart listener is non-passive. This fix makes it passive. Calling preventDefault() allows the second event to be fired but suppresses other events like `click`. `touchmove` needs to remain non-passive so that it can be used to prevent touches from scrolling or scaling the page on some versions of iOS Safari.
* Cherry pick (mapbox/mapbox-gl-js#9757) to release-erie * Cherry pick (mapbox/mapbox-gl-js#9753) to release-erie * Cherry pick (mapbox/mapbox-gl-js#9749) to release-erie * Cherry pick (mapbox/mapbox-gl-js#9748) to release-erie
fix #9756
iOS 13 does not fire the second touchstart/end events in a double tap if the touchstart listener is non-passive. This fix makes it passive.
Calling preventDefault() allows the second event to be fired but suppresses other events like
click
.touchmove
needs to remain non-passive so that it can be used to prevent touches from scrolling or scaling the page on some versions of iOS Safari.This fix does NOT work if a parent of the canvas (including the window/document/body) has a non-passive touchstart listener that doesn't call
preventDefault()
. I don't know of a fix for this that doesn't suppress all click dom events as well.Launch Checklist
mapbox-gl-js
changelog:<changelog>Fix zooming with a double tap on iOS SafarI 13.</changelog>
I have done initial testing on iOS safari v12 and v13 but these needs to be tested more thoroughly on other touch devices.