feat(deeplink): jump from banner/rank list to the exact post in All Materials

- FigmaBanner: route same-app linkUrl through SPA navigation so the stream's
  scroll-to-post runs without a full reload; defer pointer capture until a real
  drag starts, fixing plain clicks being swallowed by setPointerCapture
- PopularRankList: rank rows navigate straight to /browse?sort=popular&post=<id>
- MessageStream: ?post= deep links jump directly to the target instead of
  resetting to the top and animating through the stream
- ScrollToTop: skip the top-reset for ?post= navigations so the target page
  handles its own alignment

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
TerryM
2026-05-30 17:52:50 +08:00
parent 0733ea8b18
commit 41299b5b65
4 changed files with 73 additions and 11 deletions

View File

@@ -121,12 +121,14 @@ export function MessageStream({ scope }: MessageStreamProps) {
"(prefers-reduced-motion: reduce)",
).matches;
// Show a deliberate "from top to target" transition when opening a card
// from Home. The later auto re-alignments are intentionally delayed so
// they don't interrupt the visible smooth scroll animation.
window.scrollTo({ top: 0, left: 0, behavior: "auto" });
// Query deep-links (`?post=<id>`) usually come from Home cards/list rows.
// Keep that navigation stable by jumping directly to the target instead
// of first resetting to the top and then animating through the stream.
// Legacy hash links can still use the visible smooth scroll.
window.requestAnimationFrame(() =>
scrollToTarget(prefersReducedMotion ? "auto" : "smooth"),
scrollToTarget(
queryTargetPostId || prefersReducedMotion ? "auto" : "smooth",
),
);
// Media above the target can finish loading after the first scroll and