mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 10:54:06 -06:00
Merge 9d1fae876b into bacd19c4ea
This commit is contained in:
commit
23b4c11cb5
@ -223,8 +223,18 @@ async function setupExplorer(currentSlug: FullSlug) {
|
||||
} else {
|
||||
// try to scroll to the active element if it exists
|
||||
const activeElement = explorerUl.querySelector(".active")
|
||||
if (activeElement) {
|
||||
activeElement.scrollIntoView({ behavior: "smooth" })
|
||||
const scrollContainer = explorer.querySelector(".explorer-content ul")
|
||||
|
||||
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