Skip to content

Commit c34a4c1

Browse files
committed
Fix
1 parent fbd578f commit c34a4c1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/static/script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)