Skip to content

[Help]: Limit number of scroll snaps at any screen size #731

Closed Answered by davidjerleke
alexandra-lim asked this question in Help
Discussion options

You must be logged in to vote

Hi @alexandra-lim,

Say we have 30 carousel items. With slidesToScroll set to auto, the number of groups increases as the width of the carousel shrinks. Is there a way to always have only 5 groups shown regardless of the number of carousel items, and disregard the remaining carousel items even if they exist?

I see. No, there's no built-in way to do this. You have to add that logic yourself. One thing that comes to mind is that you can add a class name to all "wanted" slides and then select them with the slides option:

const [emblaRef, emblaApi] = useEmblaCarousel({
  slides: '.wanted-slides-class-name-here'
})

This way, "unwanted" slides won't be included when Embla calculates stuff. I h…

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@alexandra-lim
Comment options

@davidjerleke
Comment options

Answer selected by alexandra-lim
@alexandra-lim
Comment options

@alexandra-lim
Comment options

@sarussss
Comment options

@davidjerleke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
resolved This issue is resolved question Question about how to achieve something
3 participants