Splidejs / splide

Splide is a lightweight, flexible and accessible slider/carousel written in TypeScript. No dependencies, no Lighthouse errors.
https://splidejs.com
MIT License
4.88k stars 420 forks source link

perMove option not working properly with pagination #1119

Open daGUY opened 1 year ago

daGUY commented 1 year ago

Checks

Version

v4.1.4

Description

I’m trying to use Splide to display a carousel with different perMove and perPage values for different breakpoints; however, the perMove value doesn’t seem to have any effect. Here’s my code:

var splide = new Splide(".component-video-gallery .splide", {
    arrows: false,
    breakpoints: {
        576: {
            perMove: 2,
            perPage: 2
        },
        768: {
            perMove: 3,
            perPage: 3
        },
        992: {
            perMove: 4,
            perPage: 4
        }
    },
    focus: 0,
    mediaQuery: "min",
    pagination: true,
    trimSpace: false,
    type: "slide"
});

splide.on("overflow", function (isOverflow) {
    splide.options = {
        drag: isOverflow,
        pagination: isOverflow
    }
});

splide.mount();

Reproduction Link

No response

Steps to Reproduce

Configure different breakpoints and define unique perMove and perPage values for each:

breakpoints: {
  576: {
      perMove: 2,
      perPage: 2
  },
  768: {
      perMove: 3,
      perPage: 3
  },
  992: {
      perMove: 4,
      perPage: 4
  }
}

Expected Behaviour

I have six items in my carousel, so on mobile (below 576px) I see one item at a time with six pagination dots. So far, so good.

However, at the different breakpoints I’ve defined, the perMove option doesn’t seem to have any effect. For example, at the 576px breakpoint, I would expect to see two items at a time with only three pagination dots (since there are two items per page). At 768px, three items at a time with two pagination dots, etc. But what actually happens is that every breakpoint still shows six pagination dots, even though the number of items shown per page is changing.

I don’t see anything in the documentation that indicates the pagination doesn’t respond to different perMove values, so this seems like a bug.

karlshea commented 1 year ago

Also running into this, I would expect the same number of dots as pages.