fix: changed "Jump to" so it scrolls only the page's own scroll container
This commit is contained in:
1 parent
a0fdf03be0
commit
a8fea8d900
1 file changed
+9
-1
@@ -126,7 +126,15 @@ function sectionElement(id: string) {
|
|||||||
|
|
||||||
function goTo(id: string) {
|
function goTo(id: string) {
|
||||||
activeSection.value = id
|
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() {
|
function updateActive() {
|
||||||
|
|||||||
Reference in new issue
Block a user