Skip to content

Commit c613eb8

Browse files
committed
Quartz sync: Jun 9, 2025, 11:24 PM
1 parent 6804f09 commit c613eb8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

quartz/components/scripts/explorer.inline.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ function toggleFolder(evt: MouseEvent) {
4949
const folderContainer = (
5050
isSvg
5151
? // svg -> div.folder-container
52-
target.parentElement
52+
target.parentElement
5353
: // button.folder-button -> div -> div.folder-container
54-
target.parentElement?.parentElement
54+
target.parentElement?.parentElement
5555
) as MaybeHTMLElement
5656
if (!folderContainer) return
5757
const childFolderContainer = folderContainer.nextElementSibling as MaybeHTMLElement
@@ -222,9 +222,26 @@ async function setupExplorer(currentSlug: FullSlug) {
222222
explorerUl.scrollTop = parseInt(scrollTop)
223223
} else {
224224
// try to scroll to the active element if it exists
225+
// const activeElement = explorerUl.querySelector(".active")
226+
// if (activeElement) {
227+
// activeElement.scrollIntoView({
228+
// behavior: "smooth",
229+
// block: 'nearest'
230+
// })
231+
// }
225232
const activeElement = explorerUl.querySelector(".active")
226-
if (activeElement) {
227-
activeElement.scrollIntoView({ behavior: "smooth" })
233+
const scrollContainer = explorer.querySelector(".explorer-content ul")
234+
235+
if (activeElement && scrollContainer) {
236+
const offset =
237+
activeElement.getBoundingClientRect().top -
238+
scrollContainer.getBoundingClientRect().top +
239+
scrollContainer.scrollTop
240+
241+
scrollContainer.scrollTo({
242+
top: offset,
243+
behavior: "smooth"
244+
})
228245
}
229246
}
230247

0 commit comments

Comments
 (0)