From 1720ebb674bc760d56709231aefd7d13ba4906af Mon Sep 17 00:00:00 2001 From: DIYgod Date: Fri, 24 Oct 2025 22:18:30 +0800 Subject: [PATCH] feat: entry details column width animation --- .../AIEnhancedTimelineLayout.tsx | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx index 7a3b415ab..582e409f4 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/ai-enhanced-timeline/AIEnhancedTimelineLayout.tsx @@ -5,7 +5,8 @@ import { defaultUISettings } from "@follow/shared/settings/defaults" import { cn } from "@follow/utils" import { isSafari } from "@follow/utils/utils" import { AnimatePresence } from "motion/react" -import { memo, startTransition, useCallback, useEffect, useMemo, useRef } from "react" +import type { TransitionEvent } from "react" +import { memo, startTransition, useCallback, useEffect, useMemo, useRef, useState } from "react" import { useResizable } from "react-resizable-layout" import { AIChatPanelStyle, useAIChatPanelStyle, useAIPanelVisibility } from "~/atoms/settings/ai" @@ -71,6 +72,9 @@ const AIEnhancedTimelineLayoutImpl = () => { const showEntryDetailsColumn = useShowEntryDetailsColumn() const layoutContainerRef = useRef(null) + const hasMountedRef = useRef(false) + // Delay the details column until the timeline width animation finishes + const [shouldRenderDetailsColumn, setShouldRenderDetailsColumn] = useState(showEntryDetailsColumn) const feedColumnWidth = useUISettingKey("feedColWidth") // Timeline column resizable configuration (used when entry details column is visible) @@ -160,6 +164,31 @@ const AIEnhancedTimelineLayoutImpl = () => { window.dispatchEvent(new Event("resize")) }, [resolvePreferredWidth]) + const handleTimelineTransitionEnd = useCallback( + (event: TransitionEvent) => { + if ( + event.propertyName !== "width" || + event.target !== event.currentTarget || + !showEntryDetailsColumn + ) { + return + } + setShouldRenderDetailsColumn(true) + }, + [showEntryDetailsColumn], + ) + + useEffect(() => { + if (!hasMountedRef.current) { + hasMountedRef.current = true + setShouldRenderDetailsColumn(showEntryDetailsColumn) + return + } + + // Defer rendering until the width transition signals completion + setShouldRenderDetailsColumn(false) + }, [showEntryDetailsColumn]) + const showCompactTimelineColumn = useGeneralSettingKey("showCompactTimelineInSub") return (
@@ -168,11 +197,13 @@ const AIEnhancedTimelineLayoutImpl = () => {
{/* Entry list - always rendered to prevent animation */} @@ -214,7 +245,7 @@ const AIEnhancedTimelineLayoutImpl = () => {
- {showEntryDetailsColumn && ( + {showEntryDetailsColumn && shouldRenderDetailsColumn && ( <>