Skip to content

[Help]: Simple Sveltekit + Typescript question #944

Closed Answered by davidjerleke
theRolento asked this question in Help
Discussion options

You must be logged in to vote

Hi @theRolento and thanks for your question.

The type can be found here, so this should do it:

<script>
  import emblaCarouselSvelte from 'embla-carousel-svelte'
  import { EmblaCarouselType } from 'embla-carousel'

  let emblaApi: EmblaCarouselType

  function onInit(event: CustomEvent<EmblaCarouselType>) {
    emblaApi = event.detail
    console.log(emblaApi.slideNodes()) // Access API
  }
</script>

<div
  class="embla"
  use:emblaCarouselSvelte
  on:emblaInit="{onInit}"
>
  <div class="embla__container">
    <div class="embla__slide">Slide 1</div>
    <div class="embla__slide">Slide 2</div>
    <div class="embla__slide">Slide 3</div>
  </div>
</div>

Let me know if it’s what you’re loo…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@theRolento
Comment options

Answer selected by theRolento
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 svelte Issue is related to Svelte
2 participants