File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed
quartz/components/scripts Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments