From 7f5c6264c3b143d87fa939bfb54644bc1858bc27 Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Fri, 31 Mar 2023 12:48:50 +0300 Subject: [PATCH] fix(zoom): fix zoom out on double tap on sensitive touch screens --- src/modules/zoom/zoom.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/modules/zoom/zoom.js b/src/modules/zoom/zoom.js index ba997a0bc..8a3d5531b 100644 --- a/src/modules/zoom/zoom.js +++ b/src/modules/zoom/zoom.js @@ -227,7 +227,6 @@ export default function Zoom({ swiper, extendParams, on, emit }) { if (!eventWithinSlide(e) || !eventWithinZoomContainer(e)) return; const zoom = swiper.zoom; if (!gesture.imageEl) return; - swiper.allowClick = false; if (!image.isTouched || !gesture.slideEl) return; if (!image.isMoved) { @@ -252,6 +251,13 @@ export default function Zoom({ swiper, extendParams, on, emit }) { image.touchesCurrent.x = evCache.length > 0 ? evCache[0].pageX : e.pageX; image.touchesCurrent.y = evCache.length > 0 ? evCache[0].pageY : e.pageY; + const touchesDiff = Math.max( + Math.abs(image.touchesCurrent.x - image.touchesStart.x), + Math.abs(image.touchesCurrent.y - image.touchesStart.y), + ); + if (touchesDiff > 5) { + swiper.allowClick = false; + } if (!image.isMoved && !isScaling) { if (