diff --git a/src/hooks/useFocus.hook.ts b/src/hooks/useFocus.hook.ts index d639e57..68e215d 100644 --- a/src/hooks/useFocus.hook.ts +++ b/src/hooks/useFocus.hook.ts @@ -3,8 +3,10 @@ import { computed, nextTick } from 'vue' import { NOTE_WIDTH } from '@/constants/note-width' import { useOverlay } from '@/hooks/useOverlay.hook' +import { useWindowSize } from '@vueuse/core' export const useFocus = () => { + const { height } = useWindowSize() const { scrollToNote, isMobile } = useOverlay(false) const { query } = useRoute() @@ -27,7 +29,7 @@ export const useFocus = () => { const index = stackedNotes.findIndex((noteSHA) => noteSHA === sha) if (isMobile.value) { const element = document.querySelector(`.note-${sha}`) as HTMLElement - const top = (index + 1) * (element?.clientHeight ?? 0) + const top = (index + 1) * (element?.clientHeight ?? height.value) scrollToNote(top) } else { const left = index * NOTE_WIDTH