Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zoom.in function with a custom ratio causes the position to jump if we have previously clicked on the photo #7300

Closed
6 tasks done
dkacperski97 opened this issue Feb 9, 2024 · 0 comments · Fixed by #7663
Closed
6 tasks done

Comments

@dkacperski97
Copy link
Contributor

dkacperski97 commented Feb 9, 2024

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-zoom-forked-87sdhv

Bug description

  1. call zoom.in with a custom ratio
  2. double-click the photo to zoom out
  3. then, when the initial zoom scale is set to 1, the first call of zoom.in with a custom ratio, zooms to the center of the photo
  4. the second call of zoom.in with a custom ratio zooms to the position of the last click, which causes the position to jump, because the previous call zooms to different position

The bug is caused by these lines:

if (currentScale === 1 && forceZoomRatio) {
touchX = undefined;
touchY = undefined;
}

Swiper only zooms to the center of photo if currentScale === 1. Instead, swiper should clear image.touchesStart after currentScale is set to 1.

I couldn't reproduce the bug without calling zoom.in before clicking on the photo, not sure why.

Expected Behavior

zoom.in should zoom to the same spot as the previous call

Actual Behavior

The second call of zoom.in zooms to the position of the last click/touch.

Swiper version

11.0.6

Platform/Target and Browser Versions

macOS Firefox 122.0

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant