Vue-carousel: Feature Request: Allow dynamic number of slides

Created on 20 Aug 2018  路  3Comments  路  Source: SSENSE/vue-carousel

I have a dynamic number of images I want to display in your carousel.
For large screens I want to display up to 8 slides per page. But since the number of images is dynamic I might end up having only 2 images to display. In that case the slide takes up way too much space.

Example: https://codesandbox.io/s/n3mkw7z7q0
I highlighted the background of each slide to easily see how much space it takes up.

It would be great if there was a way to deal with this problem, maybe by being able to set the flex-basis yourself?

feature good first issue help wanted

Most helpful comment

But with that setting I can only handle responsiveness right?

But I kind of found a workaround now.
https://codesandbox.io/s/ywxqywjjyj

The workaround works like this.
Condition:

  • I want 4 slides per page, but sometimes I have less items available.
  • I don't want the items to spread if I only have two items.
  • Each slide has a width of 150px.

workaround:

  • define a computed field with the slides per page. This is either 4 or, if I have less items, the length of items.
  • set the :perPage to slidesPerPage
  • set the width of the wrapper to slidesPerPage * 160 (the extra 10px to give a little space between)

This works fine by now. I had to play around a little with the image width to make it look good on all screen-sizes. But it would definitely be cool not having to do a workaround like this.

All 3 comments

Hey @SAL-MichaelZanggl, have you tried using :perPageCustom? You can find the docs here, that should solve your issue -> https://ssense.github.io/vue-carousel/api/

But with that setting I can only handle responsiveness right?

But I kind of found a workaround now.
https://codesandbox.io/s/ywxqywjjyj

The workaround works like this.
Condition:

  • I want 4 slides per page, but sometimes I have less items available.
  • I don't want the items to spread if I only have two items.
  • Each slide has a width of 150px.

workaround:

  • define a computed field with the slides per page. This is either 4 or, if I have less items, the length of items.
  • set the :perPage to slidesPerPage
  • set the width of the wrapper to slidesPerPage * 160 (the extra 10px to give a little space between)

This works fine by now. I had to play around a little with the image width to make it look good on all screen-sizes. But it would definitely be cool not having to do a workaround like this.

Flagged this as a feature request. The message above is good acceptance criteria, if anyone is interested in taking it on feel free to post here!

Was this page helpful?
0 / 5 - 0 ratings