fix(stream): smooth scroll to linked post cards

Route resource card clicks to /browse?post=<id> instead of relying on hash
anchors, then manually calculate the sticky filter offset when scrolling to
the target bubble. Start from the top and smooth-scroll to the card for a
clear transition, with delayed auto realignments after media above the target
settles.
This commit is contained in:
TerryM
2026-05-30 03:11:03 +08:00
parent 6798e90708
commit a8fd540ef5
2 changed files with 67 additions and 16 deletions

View File

@@ -19,9 +19,12 @@ export function PostRedirect() {
if (POST_STREAM_USES_MOCK) {
const post = MOCK_POSTS.find((p) => p.id === id);
navigate(post ? `/browse#post-${post.id}` : "/browse", {
replace: true,
});
navigate(
post ? `/browse?post=${encodeURIComponent(post.id)}` : "/browse",
{
replace: true,
},
);
return;
}
@@ -29,7 +32,7 @@ export function PostRedirect() {
`/api/posts/${id}?lang=${encodeURIComponent(langQuery(lang))}`,
)
.then((post) => {
navigate(`/browse#post-${post.id}`, {
navigate(`/browse?post=${encodeURIComponent(post.id)}`, {
replace: true,
});
})