davidjerleke / embla-carousel

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

`emblaApi.slidesInView()` should use IntersectionObserver #558

Closed davidjerleke closed 10 months ago

davidjerleke commented 10 months ago

Feature request is related to

Is your feature request related to an issue?

Describe the solution you'd like

⚠️ The slidesInView option will be replaced with the IntersectionObserver threshold so it will accept both a single number or an array of numbers:

Setup

const options = {
  slidesInView: IntersectionObserverInit['threshold'] // Which is --> number | number[] 
}

Usage

emblaApi.on('slidesInView', (emblaApi) => {
  console.log(emblaApi.slidesInView())
})
davidjerleke commented 10 months ago

Released with v8.0.0-rc12.