use timestamp for end of timeline instead of duration

This commit is contained in:
Josh Hawkins 2024-02-21 11:02:47 -06:00
parent 2dda228449
commit a45c94eec0
2 changed files with 7 additions and 3 deletions

View File

@ -15,7 +15,7 @@ export type EventReviewTimelineProps = {
segmentDuration: number; segmentDuration: number;
timestampSpread: number; timestampSpread: number;
timelineStart: number; timelineStart: number;
timelineDuration?: number; timelineEnd: number;
showHandlebar?: boolean; showHandlebar?: boolean;
handlebarTime?: number; handlebarTime?: number;
showMinimap?: boolean; showMinimap?: boolean;
@ -30,7 +30,7 @@ export function EventReviewTimeline({
segmentDuration, segmentDuration,
timestampSpread, timestampSpread,
timelineStart, timelineStart,
timelineDuration = 24 * 60 * 60, timelineEnd,
showHandlebar = false, showHandlebar = false,
handlebarTime, handlebarTime,
showMinimap = false, showMinimap = false,
@ -46,6 +46,10 @@ export function EventReviewTimeline({
const timelineRef = useRef<HTMLDivElement>(null); const timelineRef = useRef<HTMLDivElement>(null);
const currentTimeRef = useRef<HTMLDivElement>(null); const currentTimeRef = useRef<HTMLDivElement>(null);
const observer = useRef<ResizeObserver | null>(null); const observer = useRef<ResizeObserver | null>(null);
const timelineDuration = useMemo(
() => timelineEnd - timelineStart,
[timelineEnd, timelineStart]
);
const { alignDateToTimeline } = useEventUtils(events, segmentDuration); const { alignDateToTimeline } = useEventUtils(events, segmentDuration);

View File

@ -188,7 +188,7 @@ function UIPlayground() {
segmentDuration={60} // seconds per segment segmentDuration={60} // seconds per segment
timestampSpread={15} // minutes between each major timestamp timestampSpread={15} // minutes between each major timestamp
timelineStart={Math.floor(Date.now() / 1000)} // start of the timeline - all times are numeric, not Date objects timelineStart={Math.floor(Date.now() / 1000)} // start of the timeline - all times are numeric, not Date objects
timelineDuration={24 * 60 * 60} // in minutes, defaults to 24 hours timelineEnd={Math.floor(Date.now() / 1000) + 2 * 60 * 60} // end of timeline - timestamp
showHandlebar // show / hide the handlebar showHandlebar // show / hide the handlebar
handlebarTime={Math.floor(Date.now() / 1000) - 27 * 60} // set the time of the handlebar handlebarTime={Math.floor(Date.now() / 1000) - 27 * 60} // set the time of the handlebar
showMinimap // show / hide the minimap showMinimap // show / hide the minimap