mirror of
https://github.com/RSSNext/Folo.git
synced 2026-10-17 05:08:13 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user