davidjerleke / embla-carousel

A lightweight carousel library with fluid motion and great swipe precision.
https://www.embla-carousel.com
MIT License
5.8k stars 175 forks source link

containScroll: Take edge spacing into account #331

Closed davidjerleke closed 2 years ago

davidjerleke commented 2 years ago

Feature request is related to

Describe the solution you'd like

When containScroll is active: Spacing (like margin) added to the first and the last slide with CSS will be accounted for, when calculating the scroll snap points. Currently, these spacings are ignored.

const embla = EmblaCarousel(rootNode, { containScroll: 'trimSnaps' })
.embla__slide:first-child {
  margin-left: 20px;
}

.embla__slide:last-child {
  margin-right: 20px;
}
davidjerleke commented 2 years ago

Released with v7.