swiper
swiper copied to clipboard
slideTo animation gets cancelled when resizing browser window
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
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
slideToanimation 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
slideToanimations are not interrupted by resizing the browser window.
Fixes #<7579>
Any updates? @nolimits4web
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