fix: changed "Jump to" so it scrolls only the page's own scroll container

This commit is contained in:
Florian Sylvain committed 2026-10-25 20:26:52 +01:00
1 parent a0fdf03be0
commit a8fea8d900
1 file changed
+9 -1
+9 -1
View File
@@ -126,7 +126,15 @@ function sectionElement(id: string) {
function goTo(id: string) {
activeSection.value = id
sectionElement(id)?.scrollIntoView?.({ block: 'start' })
const element = sectionElement(id)
const parent = element ? scrollParent(element) : null
if (!element || !parent) {
element?.scrollIntoView?.({ block: 'start' })
return
}
const margin = parseFloat(getComputedStyle(element).scrollMarginTop) || 0
const offset = element.getBoundingClientRect().top - parent.getBoundingClientRect().top
parent.scrollTo({ top: parent.scrollTop + offset - margin })
}
function updateActive() {