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

Initial slide indexes producing inconsistent slides

alexrichardsweb opened this issue · comments

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/swiper-vue-default-forked-w6nq9d?file=%2Fsrc%2FApp.vue%3A7%2C28

Bug description

I have utilised Swiper to create a date slider, where each slide is a day of the current month, and the initial slide is set to today. So today I should expect to see 10th May.

As seen in the reproduction, when I set the initial slide to 10, it displays the 11th slide, which seems correct as the 11th slide would be at index 10 - however if the initial slide is set to 11 it is also sets slide 11 as active, and when I set it to 9 it’s the 9th slide, and 8 to the 8th slide etc…

The same issue occurs when the initial slide is set to 20, it sets slide 21 as active. It seems that any initial slide index ending with 0, including 0 itself, sets the index to itself + 1

Expected Behavior

The initial slide indexes should be set consistently

Actual Behavior

Initial slide indexes ending with 0 produce behaviour inconsistent with those not ending with 0

Swiper version

10.5.0

Platform/Target and Browser Versions

MacOS Chrome, also occurs in Firefox

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

t0ggles-create swiper

Task nolimits4web/SWIPER-132 was created

t0ggles task SWIPER-132

It is because you use slidesPerGroup, as active index must be even to slidesPerGroup

Task nolimits4web/SWIPER-132 status changed to Done