From 25cc7a9775f2c37920478517bb79a6567d25dc7e Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Mon, 8 Jun 2020 16:34:07 -0400 Subject: [PATCH] fix double tap zoom on iOS 13 (#9757) 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. --- src/ui/handler_manager.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/handler_manager.js b/src/ui/handler_manager.js index e244ef1086a..6ebba919b63 100644 --- a/src/ui/handler_manager.js +++ b/src/ui/handler_manager.js @@ -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],