diff --git a/src/app/[lang]/Header.tsx b/src/app/[lang]/Header.tsx index 1e46f3e..5d59916 100644 --- a/src/app/[lang]/Header.tsx +++ b/src/app/[lang]/Header.tsx @@ -35,10 +35,12 @@ function Header({ avatar, children, scrollThreshold = 100 }: HeaderProps) { ); const handleScrollUp = useCallback( - (scrollY: number) => { + (scrollY: number, deltaScrollY: number) => { const newHeaderTranslateY = scrollY - scrollThreshold * 2; - if (newHeaderTranslateY > headerTranslateY) { + if (deltaScrollY < scrollThreshold / -4) { + setHeaderFixed(true); + } else if (newHeaderTranslateY > headerTranslateY) { setHeaderTranslateY(newHeaderTranslateY); } else if (scrollY - scrollThreshold < headerTranslateY) { setHeaderFixed(true); @@ -72,7 +74,7 @@ function Header({ avatar, children, scrollThreshold = 100 }: HeaderProps) { if (isScrollingDown) { handleScrollDown(currentScrollY); } else { - handleScrollUp(currentScrollY); + handleScrollUp(currentScrollY, deltaScrollY); } handleAvatarScale(currentScrollY); diff --git a/src/app/[lang]/posts/[postId]/page.tsx b/src/app/[lang]/posts/[postId]/page.tsx index 25641e2..f94ee8d 100644 --- a/src/app/[lang]/posts/[postId]/page.tsx +++ b/src/app/[lang]/posts/[postId]/page.tsx @@ -45,19 +45,23 @@ async function PostPage({ params: { postId } }: PostParams) { - -
- {content} -
- 回首頁 - + + +
+
+ {content} +
+ 回首頁 + +
- ); } diff --git a/src/app/css/globals.css b/src/app/css/globals.css index 89d6c38..e7dfdb6 100644 --- a/src/app/css/globals.css +++ b/src/app/css/globals.css @@ -6,5 +6,6 @@ @import "./prism-vsc-dark-plus.css"; :root { - scroll-padding-top: 2rem; + --header-height: 100px; + scroll-padding-top: var(--header-height); } diff --git a/src/components/TableOfContents/TableOfContents.tsx b/src/components/TableOfContents/TableOfContents.tsx index 19e80c3..2376680 100644 --- a/src/components/TableOfContents/TableOfContents.tsx +++ b/src/components/TableOfContents/TableOfContents.tsx @@ -51,10 +51,11 @@ function TableOfContents({ source }: TableOfContentsProps) {