mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 02:44:06 -06:00
Fix: scroll to .active with consistent offset logic
This commit is contained in:
parent
cdd0be2aa8
commit
9d1fae876b
@ -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