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 <tukon479@gmail.com>
This commit is contained in:
Innei
2025-10-24 21:22:40 +08:00
parent 00f7b0c2be
commit 21124f50c9
2 changed files with 7 additions and 4 deletions
@@ -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<EntryContentProps> = ({
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)
-3
View File
@@ -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