@@ -61,7 +61,6 @@ import { SELECTED_TRACK_ROW_CLASS } from "./theme";
6161import {
6262 computeTrackExpansionHeight ,
6363 getTrackExpandedRows ,
64- getExpansionHeight ,
6564 getPropertyLabel ,
6665 type ExpandedRow ,
6766} from "./expanded-layout" ;
@@ -75,6 +74,7 @@ import { TimelineBookmarksRow } from "./bookmarks";
7574import { useBookmarkDrag } from "@/hooks/timeline/use-bookmark-drag" ;
7675import { useEdgeAutoScroll } from "@/hooks/timeline/use-edge-auto-scroll" ;
7776import { useInitialScrollBottom } from "@/hooks/timeline/use-initial-scroll-bottom" ;
77+ import { useTimelineResize } from "@/hooks/timeline/use-timeline-resize" ;
7878import { useTimelineStore } from "@/stores/timeline-store" ;
7979import { useEditor } from "@/hooks/use-editor" ;
8080import { useTimelinePlayhead } from "@/hooks/timeline/use-timeline-playhead" ;
@@ -119,7 +119,9 @@ export function Timeline() {
119119 } = useElementSelection ( ) ;
120120 const editor = useEditor ( ) ;
121121 const timeline = editor . timeline ;
122- const scene = useEditor ( ( currentEditor ) => currentEditor . scenes . getActiveSceneOrNull ( ) ) ;
122+ const scene = useEditor ( ( currentEditor ) =>
123+ currentEditor . scenes . getActiveSceneOrNull ( ) ,
124+ ) ;
123125 const tracks = useMemo < TimelineTrack [ ] > (
124126 ( ) =>
125127 scene
@@ -140,23 +142,13 @@ export function Timeline() {
140142 const playheadRef = useRef < HTMLDivElement > ( null ) ;
141143 const trackLabelsScrollRef = useRef < HTMLDivElement > ( null ) ;
142144
143- const [ isResizing , setIsResizing ] = useState ( false ) ;
144145 const [ currentSnapPoint , setCurrentSnapPoint ] = useState < SnapPoint | null > (
145146 null ,
146147 ) ;
147148
148149 const handleSnapPointChange = useCallback ( ( snapPoint : SnapPoint | null ) => {
149150 setCurrentSnapPoint ( snapPoint ) ;
150151 } , [ ] ) ;
151- const handleResizeStateChange = useCallback (
152- ( { isResizing : nextIsResizing } : { isResizing : boolean } ) => {
153- setIsResizing ( nextIsResizing ) ;
154- if ( ! nextIsResizing ) {
155- setCurrentSnapPoint ( null ) ;
156- }
157- } ,
158- [ ] ,
159- ) ;
160152
161153 const timelineDuration = timeline . getTotalDuration ( ) || 0 ;
162154 const minZoomLevel = getTimelineZoomMin ( {
@@ -176,6 +168,10 @@ export function Timeline() {
176168 tracksScrollRef,
177169 rulerScrollRef,
178170 } ) ;
171+ const { isResizing, handleResizeStart } = useTimelineResize ( {
172+ zoomLevel,
173+ onSnapPointChange : handleSnapPointChange ,
174+ } ) ;
179175
180176 const expandedElementIds = useTimelineStore ( ( s ) => s . expandedElementIds ) ;
181177
@@ -366,7 +362,10 @@ export function Timeline() {
366362
367363 const containerWidth =
368364 tracksContainerRef . current ?. clientWidth || FALLBACK_CONTAINER_WIDTH ;
369- const contentWidth = timelineTimeToPixels ( { time : timelineDuration , zoomLevel } ) ;
365+ const contentWidth = timelineTimeToPixels ( {
366+ time : timelineDuration ,
367+ zoomLevel,
368+ } ) ;
370369 const paddingPx = getTimelinePaddingPx ( {
371370 containerWidth,
372371 zoomLevel,
@@ -513,7 +512,10 @@ export function Timeline() {
513512 TRACKS_CONTAINER_HEIGHT . min ,
514513 Math . min (
515514 TRACKS_CONTAINER_HEIGHT . max ,
516- getTotalTracksHeight ( { tracks, getExtraHeight : getTrackExpansionHeight } ) ,
515+ getTotalTracksHeight ( {
516+ tracks,
517+ getExtraHeight : getTrackExpansionHeight ,
518+ } ) ,
517519 ) ,
518520 ) + TIMELINE_CONTENT_TOP_PADDING_PX
519521 } px`,
@@ -533,14 +535,13 @@ export function Timeline() {
533535 } }
534536 >
535537 { tracks . length > 0 && (
536- < TimelineTrackRows
537- mainTrackId = { mainTrackId }
538+ < TimelineTrackRows
539+ mainTrackId = { mainTrackId }
538540 zoomLevel = { zoomLevel }
539541 dragState = { dragState }
540542 tracksScrollRef = { tracksScrollRef }
541543 lastMouseXRef = { lastMouseXRef }
542- onSnapPointChange = { handleSnapPointChange }
543- onResizeStateChange = { handleResizeStateChange }
544+ onResizeStart = { handleResizeStart }
544545 onElementMouseDown = { handleElementMouseDown }
545546 onElementClick = { handleElementClick }
546547 onTrackMouseDown = { ( event ) => {
@@ -718,8 +719,7 @@ function TimelineTrackRows({
718719 dragState,
719720 tracksScrollRef,
720721 lastMouseXRef,
721- onSnapPointChange,
722- onResizeStateChange,
722+ onResizeStart,
723723 onElementMouseDown,
724724 onElementClick,
725725 onTrackMouseDown,
@@ -733,8 +733,9 @@ function TimelineTrackRows({
733733 dragState : ElementDragState ;
734734 tracksScrollRef : React . RefObject < HTMLDivElement | null > ;
735735 lastMouseXRef : React . RefObject < number > ;
736- onSnapPointChange : ( snapPoint : SnapPoint | null ) => void ;
737- onResizeStateChange : ( params : { isResizing : boolean } ) => void ;
736+ onResizeStart : React . ComponentProps <
737+ typeof TimelineTrackContent
738+ > [ "onResizeStart" ] ;
738739 onElementMouseDown : React . ComponentProps <
739740 typeof TimelineTrackContent
740741 > [ "onElementMouseDown" ] ;
@@ -798,8 +799,7 @@ function TimelineTrackRows({
798799 < div
799800 className = { cn (
800801 "absolute right-0 left-0 transition-colors" ,
801- tracksWithSelection . has ( track . id ) &&
802- SELECTED_TRACK_ROW_CLASS ,
802+ tracksWithSelection . has ( track . id ) && SELECTED_TRACK_ROW_CLASS ,
803803 ) }
804804 style = { {
805805 top : `${ TIMELINE_CONTENT_TOP_PADDING_PX + getCumulativeHeightBefore ( { tracks, trackIndex : index , getExtraHeight : getTrackExpansionHeight } ) } px` ,
@@ -813,8 +813,7 @@ function TimelineTrackRows({
813813 rulerScrollRef = { tracksScrollRef }
814814 tracksScrollRef = { tracksScrollRef }
815815 lastMouseXRef = { lastMouseXRef }
816- onSnapPointChange = { onSnapPointChange }
817- onResizeStateChange = { onResizeStateChange }
816+ onResizeStart = { onResizeStart }
818817 onElementMouseDown = { onElementMouseDown }
819818 onElementClick = { onElementClick }
820819 onTrackMouseDown = { onTrackMouseDown }
@@ -929,12 +928,10 @@ function TrackToggleIcon({
929928function PropertyTree ( { rows } : { rows : ExpandedRow [ ] } ) {
930929 return (
931930 < div className = "flex flex-col overflow-hidden" >
932- { rows . map ( ( row , index ) => (
931+ { rows . map ( ( row ) => (
933932 < div
934933 key = { row . propertyPath }
935- className = { cn (
936- "flex shrink-0 items-center px-3 bg-muted/50" ,
937- ) }
934+ className = { cn ( "flex shrink-0 items-center px-3 bg-muted/50" ) }
938935 style = { { height : `${ KEYFRAME_LANE_HEIGHT_PX } px` } }
939936 >
940937 < span className = "text-muted-foreground truncate text-xs leading-none" >
0 commit comments