Issue with decimal perPage
Hi,
I tried to use perPage: 2.5 in my slider. Visually, it works very well and arrows works perfectly. But the issue starts when dragging the slider. For a reason I can't understand, the slider rewind to the first slide when the drag/touch starts (but rewind is not true in my config).
Here's my config:
new Splide('.splide', {
pagination: false,
perPage: 2.5,
perMove: 1,
rewind: false,
breakpoints: {
900: {
perPage: 1.3,
}
}
}).mount();
Could you point me to the general direction of the code that might cause this issue?
Thank you
Alright, I found the culprit in the getSlide function which returns undefined when given a decimal number.
Flooring the index do the trick but any reason you're not simply doing return Slides[index] instead of a .filter()?
Just out of curiosity, why do you want two and a half slides to appear per page?
To show users there is more content (my arrows are hidden)
You might be best using the padding option which allows some of the next slide to be seen.
https://splidejs.com/options/#padding
Close the issue due to the major version update. Feel free to create a new issue or open a new discussion.
As habitualshaker says (thanks!), use the padding option.
The perPage option must be an integer, otherwise the slider will be broken.
You might be best using the padding option which allows some of the next slide to be seen.
https://splidejs.com/options/#padding
the link should be https://splidejs.com/guides/options/#padding
@NaotoshiFujita the problem I'm having with this solution is that the padding shows once you reach the end of the slider. Ideally, in the attached screenshot, the last slide would sit flush against the right side of the container, with no padding.
The goal of this use case is to peek the next slide, not to add padding to the slider. Is there a cleaner solution to this? Thanks
@NaotoshiFujita the problem I'm having with this solution is that the padding shows once you reach the end of the slider. Ideally, in the attached screenshot, the last slide would sit flush against the right side of the container, with no padding.
The goal of this use case is to peek the next slide, not to add padding to the slider. Is there a cleaner solution to this? Thanks
![]()
Would also like to know a great solution for this. Also to centre the slides would be great.
<Splide
options={{
type: "slide",
perPage: 2,
gap: "2rem",
pagination: false,
arrows: true,
padding: { right: "15%" },
}}>
Use Padding right on .splide__track not on splide__slide
@jclarkdev did you find a solution to this? i'm struggling to figure this out now.
@jclarkdev did you find a solution to this? i'm struggling to figure this out now.
@wheeleran I use a different slider library now. Without a proper fix for this issue, it requires you to do a lot of reworking/hacky CSS to achieve the intended outcome.