🐛 (scroll) fix first scroll

This commit is contained in:
2021-03-16 00:49:52 +01:00
parent 35436ba00f
commit 2eb6f3dce3

View File

@@ -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