Skip to content

Commit

Permalink
fix double tap zoom on iOS 13 (#9757)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ansis authored Jun 8, 2020
1 parent 00ceca1 commit 25cc7a9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ui/handler_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ class HandlerManager {
const el = this._el;

this._listeners = [
// Bind touchstart and touchmove with passive: false because, even though
// they only fire a map events and therefore could theoretically be
// passive, binding with passive: true causes iOS not to respect
// e.preventDefault() in _other_ handlers, even if they are non-passive
// (see https://bugs.webkit.org/show_bug.cgi?id=184251)
[el, 'touchstart', {passive: false}],
// This needs to be `passive: true` so that a double tap fires two
// pairs of touchstart/end events in iOS Safari 13. If this is set to
// `passive: false` then the second pair of events is only fired if
// preventDefault() is called on the first touchstart. Calling preventDefault()
// undesirably prevents click events.
[el, 'touchstart', {passive: true}],
// This needs to be `passive: false` so that scrolls and pinches can be
// prevented in browsers that don't support `touch-actions: none`, for example iOS Safari 12.
[el, 'touchmove', {passive: false}],
[el, 'touchend', undefined],
[el, 'touchcancel', undefined],
Expand Down

0 comments on commit 25cc7a9

Please sign in to comment.