From 8db3bead13441a5882d8689dfc6a9f09c82375d9 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 25 Mar 2026 16:47:22 +0100 Subject: feat: masks, properties refactor, shaders, storage migrations, and more --- .../editor/panels/timeline/timeline-playhead.tsx | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'apps/web/src/components/editor/panels/timeline/timeline-playhead.tsx') diff --git a/apps/web/src/components/editor/panels/timeline/timeline-playhead.tsx b/apps/web/src/components/editor/panels/timeline/timeline-playhead.tsx index e290259e..1abe65bd 100644 --- a/apps/web/src/components/editor/panels/timeline/timeline-playhead.tsx +++ b/apps/web/src/components/editor/panels/timeline/timeline-playhead.tsx @@ -8,9 +8,14 @@ import { } from "@/lib/timeline"; import { useTimelinePlayhead } from "@/hooks/timeline/use-timeline-playhead"; import { useEditor } from "@/hooks/use-editor"; +import { + TIMELINE_LAYERS, + TIMELINE_SCROLLBAR_SIZE_PX, +} from "@/constants/timeline-constants"; interface TimelinePlayheadProps { zoomLevel: number; + hasHorizontalScrollbar: boolean; rulerRef: React.RefObject; rulerScrollRef: React.RefObject; tracksScrollRef: React.RefObject; @@ -21,6 +26,7 @@ interface TimelinePlayheadProps { export function TimelinePlayhead({ zoomLevel, + hasHorizontalScrollbar, rulerRef, rulerScrollRef, tracksScrollRef, @@ -33,7 +39,7 @@ export function TimelinePlayhead({ const internalPlayheadRef = useRef(null); const playheadRef = externalPlayheadRef || internalPlayheadRef; - const { playheadPosition, handlePlayheadMouseDown } = useTimelinePlayhead({ + const { handlePlayheadMouseDown } = useTimelinePlayhead({ zoomLevel, rulerRef, rulerScrollRef, @@ -42,16 +48,23 @@ export function TimelinePlayhead({ }); const timelineContainerHeight = - tracksScrollRef.current?.clientHeight ?? timelineRef.current?.clientHeight ?? + tracksScrollRef.current?.clientHeight ?? 400; - const totalHeight = Math.max(0, timelineContainerHeight - 4); + const totalHeight = Math.max( + 0, + timelineContainerHeight - + (hasHorizontalScrollbar ? TIMELINE_SCROLLBAR_SIZE_PX - 5 : 0), + ); + const currentTime = editor.playback.getCurrentTime(); const centerPosition = timelineTimeToSnappedPixels({ - time: playheadPosition, + time: currentTime, zoomLevel, }); - const leftPosition = getCenteredLineLeft({ centerPixel: centerPosition }); + const scrollLeft = tracksScrollRef.current?.scrollLeft ?? 0; + const leftPosition = + getCenteredLineLeft({ centerPixel: centerPosition }) - scrollLeft; const handlePlayheadKeyDown = ( event: React.KeyboardEvent, @@ -61,10 +74,8 @@ export function TimelinePlayhead({ event.preventDefault(); const step = 1 / Math.max(1, editor.project.getActive().settings.fps); const direction = event.key === "ArrowRight" ? 1 : -1; - const nextTime = Math.max( - 0, - Math.min(duration, playheadPosition + direction * step), - ); + const now = editor.playback.getCurrentTime(); + const nextTime = Math.max(0, Math.min(duration, now + direction * step)); editor.playback.seek({ time: nextTime }); }; @@ -76,23 +87,24 @@ export function TimelinePlayhead({ aria-label="Timeline playhead" aria-valuemin={0} aria-valuemax={duration} - aria-valuenow={playheadPosition} + aria-valuenow={currentTime} tabIndex={0} - className="pointer-events-none absolute z-5" + className="pointer-events-none absolute" style={{ left: `${leftPosition}px`, top: 0, height: `${totalHeight}px`, width: `${TIMELINE_INDICATOR_LINE_WIDTH_PX}px`, + zIndex: TIMELINE_LAYERS.playhead, }} onKeyDown={handlePlayheadKeyDown} > -
+
-- cgit v1.3.1