🐛 (focus) wait 100 for first stacked note

This commit is contained in:
2021-04-10 12:33:44 +02:00
parent 896d0233c5
commit 35503601f3
2 changed files with 22 additions and 10 deletions

View File

@@ -22,13 +22,15 @@ export const useFocus = () => {
nextTick(() => { nextTick(() => {
const index = stackedNotes.value.findIndex((noteSHA) => noteSHA === sha) const index = stackedNotes.value.findIndex((noteSHA) => noteSHA === sha)
const hasOneStackedNote = stackedNotes.value.length === 1
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 ?? height.value) const top = (index + 1) * (element?.clientHeight ?? height.value)
scrollToNote(top) scrollToNote(top, hasOneStackedNote)
} else { } else {
const left = (index + 1) * NOTE_WIDTH const left = (index + 1) * NOTE_WIDTH
scrollToNote(left) scrollToNote(left, hasOneStackedNote)
} }
}) })
} }

View File

@@ -25,7 +25,8 @@ export const useOverlay = (listen = true) => {
) )
} }
const scrollToNote = (to: number) => { const scrollToNote = (to: number, wait = false) => {
const go = () => {
if (isMobile.value) { if (isMobile.value) {
body.scroll({ body.scroll({
top: to top: to
@@ -37,6 +38,15 @@ export const useOverlay = (listen = true) => {
} }
} }
if (wait) {
setTimeout(() => {
go()
}, 100)
} else {
go()
}
}
return { return {
x, x,
y, y,