ismail9k / vue3-carousel

Vue 3 carousel component
https://ismail9k.github.io/vue3-carousel/
MIT License
653 stars 162 forks source link

Update slides data on window resize #354

Closed RickRosendaal closed 4 months ago

RickRosendaal commented 5 months ago

Ensures the slides data gets updated when the window resizes to avoid the minSlideIndex and maxSlideIndex to be outdated when itemsToShow is overridden for a breakpoint.

Reproduceable example:

<Carousel
  snap-align="center"
  :items-to-show="1"
  :breakpoints="{
    1024: {
      itemsToShow: 2,
      snapAlign: 'start',
    },
  }"
>
  <!--  Insert 3 slides -->
</Carousel>

Note how the maxSlideIndex doesn't get adjusted from 2 to 1 when increasing the window size to above 1024px.

After this fix, the maxSlideIndex will be adjusted accordingly.