Skip to content

Commit

Permalink
Fix zoomIn after currentScale is set to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
dkacperski97 committed Aug 1, 2024
1 parent eb1286b commit 65d2a3b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/modules/zoom/zoom.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,6 @@ export default function Zoom({ swiper, extendParams, on, emit }) {
}

const forceZoomRatio = typeof e === 'number' ? e : null;
if (currentScale === 1 && forceZoomRatio) {
touchX = undefined;
touchY = undefined;
}

const maxRatio = getMaxRatio();
zoom.scale = forceZoomRatio || maxRatio;
Expand Down Expand Up @@ -551,6 +547,10 @@ 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';
Expand Down Expand Up @@ -584,6 +584,8 @@ export default function Zoom({ swiper, extendParams, on, emit }) {
}
zoom.scale = 1;
currentScale = 1;
image.touchesStart.x = undefined;
image.touchesStart.y = undefined;
gesture.imageWrapEl.style.transitionDuration = '300ms';
gesture.imageWrapEl.style.transform = 'translate3d(0,0,0)';
gesture.imageEl.style.transitionDuration = '300ms';
Expand Down

0 comments on commit 65d2a3b

Please sign in to comment.