🐛 (focus) wait 100 for first stacked note
This commit is contained in:
@@ -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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,15 +25,25 @@ export const useOverlay = (listen = true) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToNote = (to: number) => {
|
const scrollToNote = (to: number, wait = false) => {
|
||||||
if (isMobile.value) {
|
const go = () => {
|
||||||
body.scroll({
|
if (isMobile.value) {
|
||||||
top: to
|
body.scroll({
|
||||||
})
|
top: to
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
body.scroll({
|
||||||
|
left: to
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wait) {
|
||||||
|
setTimeout(() => {
|
||||||
|
go()
|
||||||
|
}, 100)
|
||||||
} else {
|
} else {
|
||||||
body.scroll({
|
go()
|
||||||
left: to
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user