Add goTo method

This commit is contained in:
Vadim
2021-06-29 11:16:34 +03:00
parent c4d426e03d
commit cad8e729b5

View File

@@ -72,6 +72,14 @@
*/ */
export let dots = true 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 store = createStore()
let currentPageIndex = 0 let currentPageIndex = 0
$: originalCurrentPageIndex = currentPageIndex - Number(infinite); $: originalCurrentPageIndex = currentPageIndex - Number(infinite);