swiper icon indicating copy to clipboard operation
swiper copied to clipboard

slideTo animation gets cancelled when resizing browser window

Open michalpawlowski34 opened this issue 1 year ago • 1 comments
trafficstars

Check that this is really a bug

  • [x] 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

  • [X] Follow our Code of Conduct
  • [X] Read the docs.
  • [X] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • [X] 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

michalpawlowski34 avatar Jun 18 '24 15:06 michalpawlowski34

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>

akhileshverma92 avatar Jun 19 '24 07:06 akhileshverma92

Any updates? @nolimits4web

michalpawlowski34 avatar Jul 15 '24 16:07 michalpawlowski34

It is by design as it is impossible to transition and resize to the new position during transition, otherwise it will transition to the wrong position

nolimits4web avatar Aug 28 '24 13:08 nolimits4web