From 4f6b4a498f8392924d9976d3b3e81a76b62dc4dd Mon Sep 17 00:00:00 2001 From: TerryM Date: Fri, 29 May 2026 13:22:40 +0800 Subject: [PATCH] fix: scope back-to-top to browse, speed up reveal, reset scroll on sort change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - BackToTop now only mounts on the /browse feed (covers all / latest / popular / search) instead of every route. - Reveal animation duration cut 0.4s -> 0.25s so scrolled-in content appears faster. - ScrollToTop also watches `search`, so switching between sort views on the same /browse path (e.g. 全部资料 <-> 热门资料) returns to the top. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/components/ScrollToTop.tsx | 4 ++-- src/layouts/PublicLayout.tsx | 2 +- src/motion/variants.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/ScrollToTop.tsx b/src/components/ScrollToTop.tsx index af39833..3d4ce30 100644 --- a/src/components/ScrollToTop.tsx +++ b/src/components/ScrollToTop.tsx @@ -11,12 +11,12 @@ import { useLocation } from "react-router-dom"; * anchor / deep-link targets keep their own scroll handling. */ export function ScrollToTop() { - const { pathname, hash } = useLocation(); + const { pathname, search, hash } = useLocation(); useEffect(() => { if (hash) return; window.scrollTo({ top: 0, left: 0 }); - }, [pathname, hash]); + }, [pathname, search, hash]); return null; } diff --git a/src/layouts/PublicLayout.tsx b/src/layouts/PublicLayout.tsx index ae96daa..76b0edb 100644 --- a/src/layouts/PublicLayout.tsx +++ b/src/layouts/PublicLayout.tsx @@ -669,7 +669,7 @@ export function PublicLayout() { - + {pathname === "/browse" ? : null} ); } diff --git a/src/motion/variants.ts b/src/motion/variants.ts index 002636a..34d641f 100644 --- a/src/motion/variants.ts +++ b/src/motion/variants.ts @@ -5,7 +5,7 @@ export const EASE_OUT = [0.22, 1, 0.36, 1] as const; /** Base transition for reveal-style animations. */ export const baseTransition: Transition = { - duration: 0.4, + duration: 0.25, ease: EASE_OUT, };