diff --git a/src/hooks/useOverlay.hook.ts b/src/hooks/useOverlay.hook.ts index 2ae795a..c870990 100644 --- a/src/hooks/useOverlay.hook.ts +++ b/src/hooks/useOverlay.hook.ts @@ -26,26 +26,22 @@ export const useOverlay = (listen = true) => { ) } - const scrollToNote = (to: number, wait = false) => { + const scrollToNote = (to: number) => { const go = () => { - if (isMobile.value) { - body.scroll({ - top: to - }) - } else { - body.scroll({ - left: to - }) - } + const scrollOptions = isMobile.value + ? { + top: to + } + : { + left: to + } + + body.scroll(scrollOptions) } - if (wait) { - setTimeout(() => { - go() - }, 100) - } else { + setTimeout(() => { go() - } + }, 80) } return { diff --git a/src/hooks/useRouteQueryStackedNotes.hook.ts b/src/hooks/useRouteQueryStackedNotes.hook.ts index 5583405..55fc164 100644 --- a/src/hooks/useRouteQueryStackedNotes.hook.ts +++ b/src/hooks/useRouteQueryStackedNotes.hook.ts @@ -26,16 +26,14 @@ export const useRouteQueryStackedNotes = () => { nextTick(() => { const index = notes.findIndex((noteSHA) => noteSHA === sha) - const hasOneStackedNote = notes.length === 1 - if (isMobile.value) { const element = document.querySelector(`.note-${sha}`) as HTMLElement const top = (index + 1) * (element?.clientHeight ?? height.value) - scrollToNote(top, hasOneStackedNote) + scrollToNote(top) } else { const margin = index * 44 const left = (index + 1) * NOTE_WIDTH - margin - scrollToNote(left, hasOneStackedNote) + scrollToNote(left) } }) }