diff --git a/web/src/components/timeline/EventReviewTimeline.tsx b/web/src/components/timeline/EventReviewTimeline.tsx index 725d0de3c..aeedd89a5 100644 --- a/web/src/components/timeline/EventReviewTimeline.tsx +++ b/web/src/components/timeline/EventReviewTimeline.tsx @@ -18,6 +18,7 @@ export type EventReviewTimelineProps = { timelineEnd: number; showHandlebar?: boolean; handlebarTime?: number; + setHandlebarTime?: React.Dispatch>; showMinimap?: boolean; minimapStartTime?: number; minimapEndTime?: number; @@ -33,6 +34,7 @@ export function EventReviewTimeline({ timelineEnd, showHandlebar = false, handlebarTime, + setHandlebarTime, showMinimap = false, minimapStartTime, minimapEndTime, @@ -66,6 +68,7 @@ export function EventReviewTimeline({ isDragging, setIsDragging, currentTimeRef, + setHandlebarTime, }); function handleResize() { diff --git a/web/src/hooks/use-handle-dragging.ts b/web/src/hooks/use-handle-dragging.ts index c63d4e2d0..23f808b75 100644 --- a/web/src/hooks/use-handle-dragging.ts +++ b/web/src/hooks/use-handle-dragging.ts @@ -12,6 +12,7 @@ interface DragHandlerProps { isDragging: boolean; setIsDragging: React.Dispatch>; currentTimeRef: React.MutableRefObject; + setHandlebarTime?: React.Dispatch>; } // TODO: handle mobile touch events @@ -27,6 +28,7 @@ function useDraggableHandler({ isDragging, setIsDragging, currentTimeRef, + setHandlebarTime, }: DragHandlerProps) { const handleMouseDown = useCallback( (e: React.MouseEvent) => { @@ -110,6 +112,9 @@ function useDraggableHandler({ }); } }); + if (setHandlebarTime) { + setHandlebarTime(timelineStart - segmentIndex * segmentDuration); + } } } }, diff --git a/web/src/pages/UIPlayground.tsx b/web/src/pages/UIPlayground.tsx index 68c44ab14..2e0001a29 100644 --- a/web/src/pages/UIPlayground.tsx +++ b/web/src/pages/UIPlayground.tsx @@ -99,6 +99,9 @@ function UIPlayground() { const [timeline, setTimeline] = useState(undefined); const contentRef = useRef(null); const [mockEvents, setMockEvents] = useState([]); + const [handlebarTime, setHandlebarTime] = useState( + Math.floor(Date.now() / 1000) - 27 * 60 + ); const onSelect = useCallback(({ items }: { items: string[] }) => { setTimeline(items[0]); @@ -158,6 +161,10 @@ function UIPlayground() {
+ + Handlebar time + +

{handlebarTime}

Color scheme @@ -190,7 +197,8 @@ function UIPlayground() { timelineStart={Math.floor(Date.now() / 1000)} // start of the timeline - all times are numeric, not Date objects timelineEnd={Math.floor(Date.now() / 1000) + 2 * 60 * 60} // end of timeline - timestamp showHandlebar // show / hide the handlebar - handlebarTime={Math.floor(Date.now() / 1000) - 27 * 60} // set the time of the handlebar + handlebarTime={handlebarTime} // set the time of the handlebar + setHandlebarTime={setHandlebarTime} // expose handler to set the handlebar time showMinimap // show / hide the minimap minimapStartTime={Math.floor(Date.now() / 1000) - 35 * 60} // start time of the minimap - the earlier time (eg 1:00pm) minimapEndTime={Math.floor(Date.now() / 1000) - 21 * 60} // end of the minimap - the later time (eg 3:00pm)