-
-
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
Enable loop even on items.lenth < slidesPerView * 2 #6600
Comments
I agree this needs fixing. I disagree with a couple of your suggested approaches. Consider this from a client's perspective, who wants a carousel with 6 visible items, which is set to loop like every other carousel they've seen online (and remembering the origin of the word carousel; something circular that rotates). They add 10 items, swipe, and the carousel breaks entirely. Telling them this is intended by the developers makes zero sense to them; they want it to work. Changing the carousel to not loop, or to display a different number of items, equally aren't valid responses. The only option actually involves it loopping properly like it always used to / like requested. |
Just to try and fill this issue out a bit more. https://codesandbox.io/p/sandbox/swiper-infinite-loop-forked-nrs9fc?file=%2Findex.html is an example of where this happens. It works in version 8, but it is a massive blocker in version 9. The carousel just completely stops when going next slide, and then previous slide just goes straight back to the start, I'm guessing the issue is somewhere in loopFix.js where the next slides aren't being appended properly to that list. |
Hope this will be fixed, it's really painful to custom loop mode |
I recently migrate from Swiper 4 to 9 and my 4 slides slider ( and 4 slides per view) is not working as usual: time0: s1 s2 s3 s4 and now nothing moves |
I'm also looking forward to fixing this issue because I'm having trouble with this in several projects. |
Clear and concise description of the problem
Actually, when the total number of slides is < slidesPerView * 2, the swiper container will show blank slides after it crashed.
Because it cannot move the slides the way it would have liked to
Suggested solution
We could, if we have to few slides, just stay at the last slide, so ignoring the loop entirely.
Or slide a the beginning back again, in case of AutoPlay.
Alternative
Duplicate slides
Doing as before, meaning if we do not have enough slides, replicating the slides to get exactly slidesPerView * 2
Limit the slidesPerView
The slides per view could also be updated based on the number of slides
Additional context
For what I saw over on the internet, this break a lot of application.
The first proposed suggestion is what I found over on stack overflow
Validations
Would you like to open a PR for this feature?
The text was updated successfully, but these errors were encountered: