File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -539,7 +539,9 @@ function initToc() {
539539 programmaticEntry = entry ;
540540 applyCurrent ( entry ) ;
541541
542- const top = entry . target . getBoundingClientRect ( ) . top + globalThis . scrollY - 20 ;
542+ setMobileTocOpen ( false ) ;
543+ const scrollPaddingTop = Number . parseFloat ( getComputedStyle ( document . documentElement ) . scrollPaddingTop ) || 0 ;
544+ const top = entry . target . getBoundingClientRect ( ) . top + globalThis . scrollY - scrollPaddingTop ;
543545 const maxScroll = document . documentElement . scrollHeight - globalThis . innerHeight ;
544546 programmaticTarget = Math . max ( 0 , Math . min ( top , maxScroll ) ) ;
545547
@@ -559,8 +561,6 @@ function initToc() {
559561 if ( globalThis . history . replaceState ) globalThis . history . replaceState ( null , "" , hash ) ;
560562 else globalThis . location . hash = hash ;
561563
562- setMobileTocOpen ( false ) ;
563-
564564 globalThis . clearTimeout ( settleTimer ) ;
565565 settleTimer = globalThis . setTimeout ( endProgrammaticScroll , 2000 ) ;
566566 }
You can’t perform that action at this time.
0 commit comments