mirror of
https://github.com/jackyzha0/quartz.git
synced 2026-03-21 21:45:42 -05:00
Merge 9d1fae876b into 59b5807601
This commit is contained in:
commit
06b5f040af
@ -227,8 +227,18 @@ async function setupExplorer(currentSlug: FullSlug) {
|
|||||||
} else {
|
} else {
|
||||||
// try to scroll to the active element if it exists
|
// try to scroll to the active element if it exists
|
||||||
const activeElement = explorerUl.querySelector(".active")
|
const activeElement = explorerUl.querySelector(".active")
|
||||||
if (activeElement) {
|
const scrollContainer = explorer.querySelector(".explorer-content ul")
|
||||||
activeElement.scrollIntoView({ behavior: "smooth" })
|
|
||||||
|
if (activeElement && scrollContainer) {
|
||||||
|
const offset =
|
||||||
|
activeElement.getBoundingClientRect().top -
|
||||||
|
scrollContainer.getBoundingClientRect().top +
|
||||||
|
scrollContainer.scrollTop
|
||||||
|
|
||||||
|
scrollContainer.scrollTo({
|
||||||
|
top: offset,
|
||||||
|
behavior: "smooth"
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user