diff --git a/src/components/Carousel/Carousel.svelte b/src/components/Carousel/Carousel.svelte index 3b4cdef..66123ed 100644 --- a/src/components/Carousel/Carousel.svelte +++ b/src/components/Carousel/Carousel.svelte @@ -72,6 +72,14 @@ */ export let dots = true + export function goTo(pageIndex, options) { + const animated = get(options, 'animated', true) + if (typeof pageIndex !== 'number') { + throw new Error('pageIndex should be a number') + } + showPage(pageIndex + Number(infinite), { offsetDelayMs: 0, animated }) + } + let store = createStore() let currentPageIndex = 0 $: originalCurrentPageIndex = currentPageIndex - Number(infinite);