diff --git a/src/deck/useDeck.ts b/src/deck/useDeck.ts index d5c3328..6cf2e17 100644 --- a/src/deck/useDeck.ts +++ b/src/deck/useDeck.ts @@ -12,7 +12,9 @@ export function useDeck(total: number) { return m ? clamp(parseInt(m[1], 10) - 1) : 0 } - const index = ref(0) + // seed from the hash synchronously so deep links (…/#/7) land on the right + // slide at first paint — no flash of slide 1 and no on-load transition. + const index = ref(readHash()) const direction = ref<1 | -1>(1) function goto(n: number) { @@ -43,7 +45,6 @@ export function useDeck(total: number) { } onMounted(() => { - index.value = readHash() if (!window.location.hash) window.location.hash = '#/1' window.addEventListener('keydown', onKey) window.addEventListener('hashchange', onHash)