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

Expose plugin API:s from the Embla API #327

Closed davidjerleke closed 2 years ago

davidjerleke commented 2 years ago

Feature request is related to

Describe the solution you'd like

I'd like to access plugin API:s from the Embla API. It would make it convenient to have all API:s gathered in one instance. Example:

✅ How to access a plugin API:

import EmblaCarousel from 'embla-carousel'
import Autoplay from 'embla-carousel-autoplay'

const options = { loop: false }

const embla = EmblaCarousel(emblaNode, options, [Autoplay()])

embla.plugins().autoplay.reset() // Access the plugin API like this

❌ How not to access a plugin API:

import EmblaCarousel from 'embla-carousel'
import Autoplay from 'embla-carousel-autoplay'

const options = { loop: false }
const autoplay = Autoplay()

const embla = EmblaCarousel(emblaNode, options, [autoplay])

autoplay.reset() // Don't do this
davidjerleke commented 2 years ago

Released with v7.