`loop` doesn't work when displaying three slides out of four total slides
See original GitHub issueHi,
When the total number of slides is set to 4, slidesToShow: 3
, and slidesToScroll: 1
, the loop
option stops working. This was mentioned in the docs, which is probably what’s happening
loop
... Automatically falls back to false if slide content isn't enough to loop.
This can be reproduced in the sandbox: https://codesandbox.io/s/embla-carousel-loop-react-forked-7200i?file=/src/js/index.js
Two questions:
- What’s the reasoning for this restriction? There’s definitely enough slide content to loop. I was expecting to see [1,2,3] on initial render, [2,3,4] on next click, and [3,4,1] on next click.
- Is there a workaround for this?
Thanks, Patrick
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
loop doesn't work when displaying three slides out of four total ...
Hi, When the total number of slides is set to 4, slidesToShow: 3, and slidesToScroll: 1, the loop option stops working.
Read more >How to Loop a PowerPoint in 5 Simple Steps - G2 Learning Hub
1. Click Slide Show · 2. Click Set Up Slide Show · 3. Click Loop continuously · 4. Select all slides and click...
Read more >How to add a looping introduction to a PowerPoint presentation
Enter the number of seconds you want to pause between slides—3 (Figure B). Click the Slide Show tab, and then click Set Up...
Read more >Swiper js showing 3 identical slides when there is one slide
Simply change the loop parameter from true to false.
Read more >How to Make PowerPoint Loop | PowerPoint Repeat Slideshow
When you setup a PowerPoint loop slideshow, it runs by itself from the first to the last slide, rewinds itself, and runs again....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello Patrick (@patrickhuang94),
Thank you for your question and the CodeSandbox. The documentation is correct, Embla Carousel will check if there is enough slide content to make the loop effect work without any flickering (white space showing).
Now, assuming you have 4 slides, you would think that setting the CSS like this:
…would result in enough content to make the loop effect work. But this isn’t the case. Because the viewport is 100%. And the slide content for 3 slides (we subtract 1 slide because it’s needed to flip around for the loop effect to work) will be 33.33333 * 3 = 99.99999%. Additionally, when I log the slide sizes calculated from the boundingClientRect, the browser gives 33.331691216316074, which isn’t even 33.33333%.
I hope this explanation makes sense.
There’s no workaround for this other than writing your own fallback logic. For example, you can duplicate the slides yourself.
Best, David
@patrickhuang94 I’m closing this as resolved. You’re welcome to open this issue again if you don’t agree.
Best, David