swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Loop mode not work correctly

Open dqhuy78 opened this issue 6 months ago • 1 comments

Check that this is really a bug

  • [x] I confirm

Reproduction link

https://codesandbox.io/p/sandbox/swiper-infinite-loop-forked-4fjjyl?file=%2Findex.html%3A87%2C26

Bug description

The issue happen in loop mode with the following config:

slidesPerView: 7,
spaceBetween: 10,
loop: true,

The next/previous slide navigation works fine, but when I try to jump directly to a specific slide with an index ≥ 5 (1-based), it always goes to slide 4 instead.

For example, if I start from the first slide and click the dot for the last slide, it first jumps to slide 4. Then, if I keep clicking the last slide’s dot, it moves one slide at a time, just like pressing "next."

While debugging, I found that Swiper’s loopFix function re-arranges the DOM to match the final slide position. After that, it triggers a slideTo with speed 0 to instantly move to the active slide, and then calls slideTo again in requestAnimationFrame for the actual target slide with transition. However, the re-arrangement and instant move don’t seem to work as expected, which causes this incorrect behavior.

Expected Behavior

Move to the slide that matches the clicked dot.

Actual Behavior

Moves to a different, unexpected slide.

Swiper version

11.2.0

Platform/Target and Browser Versions

macOS Sequoia 15.6.1

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

dqhuy78 avatar Sep 07 '25 14:09 dqhuy78

have you tried using slideToLoop instead?

eballeste avatar Dec 09 '25 08:12 eballeste