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

Add an event for option active on breakpoints #592

Closed drewlonious closed 8 months ago

drewlonious commented 9 months ago

Feature request is related to

Is your feature request related to an issue?

Describe the solution you'd like

Describe alternatives you've considered

davidjerleke commented 8 months ago

Hi @drewlonious,

Thank you for your feature request. From now on, please always create a new discussion and discuss stuff before you create a new issue.

With that said, you can achieve what you want like so:

function doSomethingWhenActiveOrNot(emblaApi) {
  const { active } = emblaApi.internalEngine().options
  // do what you want here
}

doSomethingWhenActiveOrNot(emblaApi)
emblaApi.on('reInit', doSomethingWhenActiveOrNot)

Best, David

drewlonious commented 8 months ago

@davidjerleke Oh there it is. Thanks for this. Noted about discussion