fix: scroll to note

This commit is contained in:
Julien Calixte
2026-02-19 17:36:44 +01:00
parent efd2a2a99b
commit 5bad66884f
3 changed files with 11 additions and 8 deletions

View File

@@ -1,12 +1,10 @@
import { computed, onMounted, Ref, ref, toValue } from "vue"
import { BOOKMARK_WIDTH_REM, getBookmarkWidthPx } from "@/constants/bookmark-width"
import { getNoteWidth } from "@/constants/note-width"
import { useOverlay } from "@/hooks/useOverlay.hook"
import { useRouteQueryStackedNotes } from "@/hooks/useRouteQueryStackedNotes.hook"
const BOOKMARK_WIDTH = 2
const OFFSET = 32 // stacked-note padding
export const useNoteOverlay = (
className: string,
index: Ref<number> | number,
@@ -20,7 +18,7 @@ export const useNoteOverlay = (
if (isMobile.value) {
return y.value > valueIndex * noteHeight.value
} else {
return x.value > valueIndex * getNoteWidth() - valueIndex * OFFSET
return x.value > valueIndex * getNoteWidth() - valueIndex * getBookmarkWidthPx()
}
})
@@ -39,7 +37,7 @@ export const useNoteOverlay = (
if (isMobile.value) {
noteElement.style.top = `0`
} else {
noteElement.style.left = `${(toValue(index) + 1) * BOOKMARK_WIDTH}rem`
noteElement.style.left = `${(toValue(index) + 1) * BOOKMARK_WIDTH_REM}rem`
const stackedNoteContainers = document.querySelectorAll(
".stacked-note",
@@ -47,7 +45,7 @@ export const useNoteOverlay = (
stackedNoteContainers.forEach((stackedNote, ind) => {
stackedNote.style.right = `calc(-${getNoteWidth()}px + ${
(stackedNotes.value.length - ind) * BOOKMARK_WIDTH
(stackedNotes.value.length - ind) * BOOKMARK_WIDTH_REM
}rem)`
})
}

View File

@@ -2,6 +2,7 @@ import { useWindowSize } from "@vueuse/core"
import { useRouteQuery } from "@vueuse/router"
import { nextTick, readonly } from "vue"
import { getBookmarkWidthPx } from "@/constants/bookmark-width"
import { getNoteWidth } from "@/constants/note-width"
import { useOverlay } from "@/hooks/useOverlay.hook"
@@ -39,8 +40,7 @@ export const useRouteQueryStackedNotes = () => {
}
} else {
if (noteId) {
const margin = index * 44
const left = (index + 1) * getNoteWidth() - margin
const left = (index + 1) * (getNoteWidth() - getBookmarkWidthPx())
scrollToNote(left)
} else {
scrollToNote(0)