From eb3f9f2676b129b4594a71f8c3325f225f903cf0 Mon Sep 17 00:00:00 2001 From: saicaca Date: Fri, 6 Dec 2024 20:53:24 +0800 Subject: [PATCH] fix: fix incorrect position of TOC indicator --- src/components/widget/TOC.astro | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/widget/TOC.astro b/src/components/widget/TOC.astro index 9549115..a9bac48 100644 --- a/src/components/widget/TOC.astro +++ b/src/components/widget/TOC.astro @@ -52,7 +52,7 @@ const maxLevel = siteConfig.toc.depth; }]}>{removeTailingHash(heading.text)} )} -
@@ -198,6 +198,13 @@ class TableOfContents extends HTMLElement { } connectedCallback() { + // wait for the onload animation to finish, which makes the `getBoundingClientRect` return correct values + setTimeout(() => { + this.init(); + }, 250); + } + + init() { this.tocEl = document.getElementById( "toc-inner-wrapper" );