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

TypeError when Swiper instance is destroyed right after zooming #7722

Closed
6 tasks done
Heptonius opened this issue Sep 5, 2024 · 1 comment
Closed
6 tasks done

TypeError when Swiper instance is destroyed right after zooming #7722

Heptonius opened this issue Sep 5, 2024 · 1 comment

Comments

@Heptonius
Copy link
Contributor

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/swiper-react-zoom-pqy2gq

Bug description

On a project we have an image gallery build on top of Swiper. We have the zoom functionality enabled. On mobile we have a functionality in place that checks whether or not you have swiped the image in the vertical direction (gallery set to horizontal mode) and we close the gallery when this happens. However, both things - zooming + swiping (onTouchStart - onTouchEnd) - can happen at the same time. This means there are cases in which the swiper gallery is closed right after the zoom happens.

During zooming, there is a setTimeout call with callback that invokes the allowTouchMove

allowTouchMoveTimeout = setTimeout(() => {

However, the asynchronous nature of setTimeout in our use case makes it happen after the instance is destroyed. Which leads to TypeErrors:

../../node_modules/swiper/modules/zoom.mjs in allowTouchMove at line 216:1

TypeError
Cannot set properties of undefined (setting 'preventTouchMoveFromPointerMove')

Reproduction link note: Our setup to reproduce this issue is quite complex and unreliable, but I think the issue is hopefully described/obvious enough. If not, I can try to setup a proper repro sandbox.

Expected Behavior

No errors are thrown after the Swiper instance is destroyed right after zooming.

Actual Behavior

Unreliably the error is thrown after the Swiper instance is destroyed right after zooming.

Swiper version

11.1.4

Platform/Target and Browser Versions

Android Chrome 128

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
@nolimits4web
Copy link
Owner

Fixed by #7723

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

No branches or pull requests

2 participants