Skip to content

Commit ea34d83

Browse files
authored
Merge pull request #808 from maiieul/fix-toc
fix(toc): add rootMargin
2 parents f38c876 + 8f85b8f commit ea34d83

File tree

1 file changed

+10
-7
lines changed
  • apps/website/src/components/toc

1 file changed

+10
-7
lines changed

apps/website/src/components/toc/toc.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ const useActiveItem = (itemIds: string[]) => {
3030
const activeId = useSignal<string>();
3131

3232
useVisibleTask$(({ cleanup }) => {
33-
const observer = new IntersectionObserver((entries) => {
34-
entries.forEach((entry) => {
35-
if (entry.isIntersecting) {
36-
activeId.value = entry.target.id;
37-
}
38-
});
39-
});
33+
const observer = new IntersectionObserver(
34+
(entries) => {
35+
entries.forEach((entry) => {
36+
if (entry.isIntersecting) {
37+
activeId.value = entry.target.id;
38+
}
39+
});
40+
},
41+
{ rootMargin: `0% 0% -90% 0%` },
42+
);
4043

4144
itemIds.forEach((id) => {
4245
const element = document.getElementById(id);

0 commit comments

Comments
 (0)