[Help]: How do I add navigation buttons? #868
-
SummaryHow do i add navigation buttons to the carousel?
to scroll to a image in the carousel. If applicable, which variants of Embla Carousel are relevant to this question?
Additional informationNo response CodeSandbox exampleNo response |
Beta Was this translation helpful? Give feedback.
Answered by
davidjerleke
May 11, 2024
Replies: 1 comment 5 replies
-
Hi @ItsTerm1n4l, Thanks for your question. Use the <script>
import emblaCarouselSvelte from 'embla-carousel-svelte'
let emblaApi
let options = { loop: false }
// Attach this where you want and pass an index
function scrollTo(index) {
emblaApi?.scrollTo(index)
}
function onInit(event) {
emblaApi = event.detail
}
</script>
<div
class="embla"
use:emblaCarouselSvelte="{{ options }}"
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> Here’s a get started guide for the Svelte package. And on a side note, you might want to vote here: |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
ItsTerm1n4l
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @ItsTerm1n4l,
Thanks for your question. Use the
scrollTo
method:Here’s a get started guide for the Svelte package.
And on…