The open-source AI voice studio. Clone, dictate, create.
Implement auto-scroll feature in StoryTrackEditor to keep playhead centered during playback
Jamie Pine341d71470c61
diff --git a/app/src/components/StoriesTab/StoryTrackEditor.tsx b/app/src/components/StoriesTab/StoryTrackEditor.tsxindex 16ff2da4..bc3758dd 100644--- a/app/src/components/StoriesTab/StoryTrackEditor.tsx+++ b/app/src/components/StoriesTab/StoryTrackEditor.tsx@@ -679,6 +679,22 @@ export function StoryTrackEditor({ storyId, items }: StoryTrackEditorProps) {// Playhead positionconst playheadLeft = msToPixels(currentTimeMs);+ // Auto-scroll timeline to follow playhead during playback+ useEffect(() => {+ if (!isCurrentlyPlaying || !tracksRef.current) return;++ const container = tracksRef.current;+ const containerWidth = container.clientWidth;+ const scrollLeft = container.scrollLeft;+ const halfwayPoint = scrollLeft + containerWidth / 2;++ // If playhead is past the halfway point, scroll to keep it centered+ if (playheadLeft > halfwayPoint) {+ const targetScroll = playheadLeft - containerWidth / 2;+ container.scrollLeft = targetScroll;+ }+ }, [isCurrentlyPlaying, playheadLeft]);+// Calculate tracks area heightconst tracksAreaHeight = tracks.length * TRACK_HEIGHT;const timelineContainerHeight = editorHeight - 40; // Subtract toolbar height