nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions

Home Page:https://swiperjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slideTo animation gets cancelled when resizing browser window

michalpawlowski34 opened this issue · comments

Check that this is really a bug

  • I confirm

Reproduction link

https://jsfiddle.net/sgte3jox/27/

Bug description

After slideTo() function is triggered if user resizes the browser's window during the animation it gets cancelled and skips to given slide index.

Interestingly, the bug does not happen when triggering the slider to go backwards (previous indexes). Only when sliding 'forward'.

Swiper version

11.0.3

Platform/Target and Browser Versions

Windows 10, Firefox/Chrome

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

Fix slideTo Animation Cancellation on Browser Resize

Description

This pull request addresses the issue where the slideTo animation gets cancelled when resizing the browser window. The fix involves tracking the animation state and modifying the resize event handler to preserve ongoing animations.

Changes Made

  • Added a flag to track if slideTo animation is in progress.
  • Modified the resize event handler to check the animation state and conditionally handle the resize.

Testing

  • Tested on various browsers (Chrome, Firefox, Safari) and devices.
  • Verified that ongoing slideTo animations are not interrupted by resizing the browser window.

Fixes #<7579>