From 21124f50c940b2e893e0d70ea13449ac82213739 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 24 Oct 2025 21:22:40 +0800 Subject: [PATCH] fix(entry-content): scroll to top on content animation start, fixed #4599 - Added functionality to scroll to the top of the EntryContent when the animation starts, utilizing the springScrollTo utility. - Removed unused zenMode method from the RenderGlobalContext interface to clean up the code. These changes enhance the user experience by ensuring the content is visible upon entry and streamline the codebase by removing unnecessary methods. Signed-off-by: Innei --- .../renderer/src/modules/entry-content/EntryContent.tsx | 8 +++++++- packages/internal/shared/src/bridge.ts | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/EntryContent.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/EntryContent.tsx index 907962282..3b0eab1f7 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/EntryContent.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/EntryContent.tsx @@ -12,6 +12,7 @@ import { useSubscriptionByFeedId } from "@follow/store/subscription/hooks" import { thenable } from "@follow/utils" import { stopPropagation } from "@follow/utils/dom" import { EventBus } from "@follow/utils/event-bus" +import { springScrollTo } from "@follow/utils/scroller" import { cn } from "@follow/utils/utils" import type { JSAnimation } from "motion/react" import { useAnimationControls } from "motion/react" @@ -104,11 +105,16 @@ const EntryContentImpl: Component = ({ useEffect(() => { animationController.set(contentVariants.exit) animationController.start(contentVariants.animate) + + // Scroll to top + if (scrollerRef) { + springScrollTo(0, scrollerRef) + } focusableRef.current?.focus() return () => { animationController.stop() } - }, [animationController, entryId]) + }, [animationController, entryId, scrollerRef]) useEffect(() => { setEntryContentScrollToTop(true) diff --git a/packages/internal/shared/src/bridge.ts b/packages/internal/shared/src/bridge.ts index 875b080e2..9709bc2b7 100644 --- a/packages/internal/shared/src/bridge.ts +++ b/packages/internal/shared/src/bridge.ts @@ -64,9 +64,6 @@ interface RenderGlobalContext { getWebUrl: () => string getApiUrl: () => string - // View - zenMode: () => void - // Utils invalidateQuery: (queryKey: string | string[]) => void navigateEntry: (options: { feedId: string; entryId: string; view: number }) => void