splide
                                
                                 splide copied to clipboard
                                
                                    splide copied to clipboard
                            
                            
                            
                        Slider goes from 1st slide directly to 3th slide instead of 2nd
Checks
- [X] Not a duplicate.
- [X] Not a question, feature request, or anything other than a bug report directly related to Splide. Use Discussions for these topics: https://github.com/Splidejs/splide/discussions
Version
v4.0.7
Description
In our configuration we want to show always 3 slides. The centered slide is the "selected" one. The problem appears only when slider has 3 slides - slider is going directly from first to last slide after pressing the "next" button.
Splide configuration: const splide = new Splide(".splide", { trimSpace: false, perPage: 3, perMove: 1, focus: "center" }).mount();
Reproduction Link
https://codesandbox.io/s/elated-shadow-90s0jg
Steps to Reproduce
- Click the next (right arrow) button.
- The last element is selected.
Expected Behaviour
Expected is that after clicking next btn the slider will go to the second slide.
Hi @all,
same problem here with v4.0.7 and this config: { "type":"slide", "perPage":5, "perMove": 1, "focus":"center", "trimSpace": false, "updateOnMove": true, "pagination":false, "breakpoints":{ "800": { "perPage": 3 } } }
When changing screenwidth to a width less than the breakpoint (800px), the arrow buttons work exactly as expected.
Perhaps this information helps troubleshooting.
Regards, Alex
EDIT: Just tried changing the "type": works as expected with type: "loop".
After a little more research I found out, that the problem depends on the number of splide__slides:
In my case: I had 5 slides and perPage was set to 5. Normally (with trimSpace true) this five Slides would fit on one page. Because trimSpace was set to false, slide 4 and 5 were on the second page. This seems to be the problem.
After adding a 6th slide everything worked like a charm.
Same with the example above: https://codesandbox.io/s/elated-shadow-90s0jg If you add another slide (from 3 to 4 slides), it works like it should.
The number of slides has to be bigger than the "perPage" variable.
I hope this information helps fixing the bug.
Cheers, Alex