From 49ad78360ab0cd5edbfe1fdba652a220cbf90c97 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Fri, 31 Jul 2026 18:06:56 +0200 Subject: [PATCH] fix(deck): deep links land on the right slide without a flash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Seed the slide index from the URL hash synchronously at setup instead of after mount, so opening …/#/7 renders slide 7 immediately (no flash of slide 1 and no on-load transition). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/deck/useDeck.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)