-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swiper incorrectly calculates last slide as activeSlide on load. #7216
Swiper incorrectly calculates last slide as activeSlide on load. #7216
Comments
+1. We using the following modules and the following props.
|
@huggie1984 yea I've been doing more testing and getting the result at odd ranges of slide widths. I'm setting slide width in % and spaceBetween is 16. The following percent values cause last slide to render first. Seeing this behavior in swiper studio as well. |
Fixed behavior where the combination of 'initialSlide:0' and 'slidesPerView:auto' would shift the first slide position
Facing same issue. Did you find any solution |
Hi @kirtikadam, it was a while since I worked with this. For me it may have been related to the number of slides. Try having a minimum of 3+ slides when you init the carousel or enough slides off screen , duplicate slides if you need to. another solution was to tap into the onAfterInit method and manually force the position. good luck. |
I found this same issue and my solution was to do a ".slideTo()" within the onInit function, not ideal but was the only way I found for my use case
|
…idesPerView:auto' would shift the first slide position * fix: initialSlide #7216 Fixed behavior where the combination of 'initialSlide:0' and 'slidesPerView:auto' would shift the first slide position * remove debug --------- Co-authored-by: Vladimir Kharlampidi <nolimits4web@gmail.com>
Check that this is really a bug
Reproduction link
https://codesandbox.io/s/swiper-bug-loop-centered-auto-width-kwj8ls?file=/index.html
Bug description
a slider with slidesPerView set to 'auto' in loop mode and centeredSlides set to true calculates the last slide as the active slide on load. In the demo you'll see that the first slide shown is slide 7, not slide 1.
changing the slide width in CSS from 20% to 21% causes the first slide to show.
can also play with initialSlide value to correct it.
My guess is some sort of math error when calculating the first slide when combo of slidesPerView 'auto', centeredSlides true, and loop mode are all in play.
Expected Behavior
Actual Behavior
The last slide in the html is calculated to be the active slide on load.
Swiper version
11.0.5
Platform/Target and Browser Versions
Chrome, Safari
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: