From 5b34740fb67f08bd3ec363f05b344f48a631389f Mon Sep 17 00:00:00 2001 From: Vladimir Kharlampidi Date: Wed, 21 Aug 2024 12:08:46 +0300 Subject: [PATCH] Update zoom.mjs --- src/modules/zoom/zoom.mjs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/zoom/zoom.mjs b/src/modules/zoom/zoom.mjs index ec26924e7..1c20c03d2 100644 --- a/src/modules/zoom/zoom.mjs +++ b/src/modules/zoom/zoom.mjs @@ -500,6 +500,12 @@ export default function Zoom({ swiper, extendParams, on, emit }) { } const forceZoomRatio = typeof e === 'number' ? e : null; + if (currentScale === 1 && forceZoomRatio) { + touchX = undefined; + touchY = undefined; + image.touchesStart.x = undefined; + image.touchesStart.y = undefined; + } const maxRatio = getMaxRatio(); zoom.scale = forceZoomRatio || maxRatio; @@ -547,10 +553,6 @@ export default function Zoom({ swiper, extendParams, on, emit }) { gesture.originX = 0; gesture.originY = 0; } - if (currentScale === 1) { - image.touchesStart.x = undefined; - image.touchesStart.y = undefined; - } gesture.imageWrapEl.style.transitionDuration = '300ms'; gesture.imageWrapEl.style.transform = `translate3d(${translateX}px, ${translateY}px,0)`; gesture.imageEl.style.transitionDuration = '300ms';