🐛 (scroll) fix first scroll
This commit is contained in:
@@ -3,8 +3,10 @@ import { computed, nextTick } from 'vue'
|
|||||||
|
|
||||||
import { NOTE_WIDTH } from '@/constants/note-width'
|
import { NOTE_WIDTH } from '@/constants/note-width'
|
||||||
import { useOverlay } from '@/hooks/useOverlay.hook'
|
import { useOverlay } from '@/hooks/useOverlay.hook'
|
||||||
|
import { useWindowSize } from '@vueuse/core'
|
||||||
|
|
||||||
export const useFocus = () => {
|
export const useFocus = () => {
|
||||||
|
const { height } = useWindowSize()
|
||||||
const { scrollToNote, isMobile } = useOverlay(false)
|
const { scrollToNote, isMobile } = useOverlay(false)
|
||||||
const { query } = useRoute()
|
const { query } = useRoute()
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ export const useFocus = () => {
|
|||||||
const index = stackedNotes.findIndex((noteSHA) => noteSHA === sha)
|
const index = stackedNotes.findIndex((noteSHA) => noteSHA === sha)
|
||||||
if (isMobile.value) {
|
if (isMobile.value) {
|
||||||
const element = document.querySelector(`.note-${sha}`) as HTMLElement
|
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)
|
scrollToNote(top)
|
||||||
} else {
|
} else {
|
||||||
const left = index * NOTE_WIDTH
|
const left = index * NOTE_WIDTH
|
||||||
|
|||||||
Reference in New Issue
Block a user