Skip to content
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

Closed
3 of 4 tasks
rbalet opened this issue Apr 18, 2023 · 5 comments
Closed
3 of 4 tasks

Enable loop even on items.lenth < slidesPerView * 2 #6600

rbalet opened this issue Apr 18, 2023 · 5 comments

Comments

@rbalet
Copy link

rbalet commented Apr 18, 2023

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

  • 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.

Would you like to open a PR for this feature?

  • I'm willing to open a PR
@smerriman
Copy link

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.

@NathanBeddoeWebDev
Copy link

NathanBeddoeWebDev commented Apr 27, 2023

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.

@trieu-hphuc96
Copy link

Hope this will be fixed, it's really painful to custom loop mode

@serhumanos
Copy link

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
time1: s2 s3 s4 s1
time2: s3 s4 s1 s2
time3: s4 s1 s2 s3
time4: s1 s2 s3 s4

and now nothing moves

@milbau
Copy link

milbau commented Jun 7, 2023

I'm also looking forward to fixing this issue because I'm having trouble with this in several projects.

Repository owner locked and limited conversation to collaborators Jun 7, 2023
@nolimits4web nolimits4web closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants