Skip to content

Commit

Permalink
fix: toc
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Jun 12, 2023
1 parent 8c9b062 commit 1f3fa9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/widgets/toc/Toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ function useActiveId($headings: HTMLHeadingElement[]) {
entries.forEach((entry) => {
if (entry.isIntersecting) {
const state = history.state

console.log(entry.target.id, 'id')
history.replaceState({ ...state }, '', `#${entry.target.id}`)
setActiveId(entry.target.id)
}
})
},
{ rootMargin: `0% 0% 50% 0%` },
{ rootMargin: `-100px 0px -100px 0px` },
)
$headings.forEach(($heading) => {
observer.observe($heading)
Expand Down
2 changes: 1 addition & 1 deletion src/components/widgets/toc/TocItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const TocItem: FC<{
) as any as HTMLElement

if ($el) {
springScrollToElement($el, -(window.innerHeight / 2))
springScrollToElement($el, -100)
}
},
[onClick, index, $article, anchorId],
Expand Down

1 comment on commit 1f3fa9c

@vercel
Copy link

@vercel vercel bot commented on 1f3fa9c Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

springtide – ./

springtide.vercel.app
springtide-git-main-innei.vercel.app
springtide-innei.vercel.app

Please sign in to comment.