From a826b4ec7ecdbec42ac8d5cd7d41042b4f204aa0 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Sun, 10 Mar 2024 21:38:08 -0500 Subject: [PATCH] fix segments on motion review --- web/src/components/timeline/MotionSegment.tsx | 32 ++++++++++++++++--- web/src/hooks/use-motion-segment-utils.ts | 14 +++++--- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/web/src/components/timeline/MotionSegment.tsx b/web/src/components/timeline/MotionSegment.tsx index 2efdd73d0..d9c3ca8a5 100644 --- a/web/src/components/timeline/MotionSegment.tsx +++ b/web/src/components/timeline/MotionSegment.tsx @@ -82,7 +82,19 @@ export function MotionSegment({ return isMobile ? 30 : 50; }, []); - const segmentWidth = useMemo(() => { + const firstHalfSegmentWidth = useMemo(() => { + return interpolateMotionAudioData( + getMotionSegmentValue(segmentTime), + maxSegmentWidth, + ); + }, [ + segmentTime, + maxSegmentWidth, + getMotionSegmentValue, + interpolateMotionAudioData, + ]); + + const secondHalfSegmentWidth = useMemo(() => { return interpolateMotionAudioData( getMotionSegmentValue(segmentTime + segmentDuration / 2), maxSegmentWidth, @@ -167,14 +179,24 @@ export function MotionSegment({ }; const segmentClick = useCallback(() => { - if (startTimestamp && setHandlebarTime && segmentWidth > 1) { + if ( + startTimestamp && + setHandlebarTime && + (firstHalfSegmentWidth > 1 || secondHalfSegmentWidth > 1) + ) { setHandlebarTime(startTimestamp); } - }, [startTimestamp, setHandlebarTime, segmentWidth]); + }, [ + startTimestamp, + setHandlebarTime, + firstHalfSegmentWidth, + secondHalfSegmentWidth, + ]); return (