diff --git a/web/src/components/timeline/MotionSegment.tsx b/web/src/components/timeline/MotionSegment.tsx
index 2c7138967..2efdd73d0 100644
--- a/web/src/components/timeline/MotionSegment.tsx
+++ b/web/src/components/timeline/MotionSegment.tsx
@@ -82,6 +82,19 @@ export function MotionSegment({
return isMobile ? 30 : 50;
}, []);
+ const segmentWidth = useMemo(() => {
+ return interpolateMotionAudioData(
+ getMotionSegmentValue(segmentTime + segmentDuration / 2),
+ maxSegmentWidth,
+ );
+ }, [
+ segmentTime,
+ segmentDuration,
+ maxSegmentWidth,
+ getMotionSegmentValue,
+ interpolateMotionAudioData,
+ ]);
+
const alignedMinimapStartTime = useMemo(
() => alignStartDateToTimeline(minimapStartTime ?? 0),
[minimapStartTime, alignStartDateToTimeline],
@@ -154,13 +167,18 @@ export function MotionSegment({
};
const segmentClick = useCallback(() => {
- if (startTimestamp && setHandlebarTime) {
+ if (startTimestamp && setHandlebarTime && segmentWidth > 1) {
setHandlebarTime(startTimestamp);
}
- }, [startTimestamp, setHandlebarTime]);
+ }, [startTimestamp, setHandlebarTime, segmentWidth]);
return (
-
+
handleTouchStart(event, segmentClick)}
+ >
handleTouchStart(event, segmentClick)}
style={{
- width: interpolateMotionAudioData(
- getMotionSegmentValue(segmentTime + segmentDuration / 2),
- maxSegmentWidth,
- ),
+ width: segmentWidth,
}}
>
@@ -202,13 +215,8 @@ export function MotionSegment({
handleTouchStart(event, segmentClick)}
style={{
- width: interpolateMotionAudioData(
- getMotionSegmentValue(segmentTime),
- maxSegmentWidth,
- ),
+ width: segmentWidth,
}}
>
diff --git a/web/src/hooks/use-motion-segment-utils.ts b/web/src/hooks/use-motion-segment-utils.ts
index 514f91c0c..4cf0c15e1 100644
--- a/web/src/hooks/use-motion-segment-utils.ts
+++ b/web/src/hooks/use-motion-segment-utils.ts
@@ -43,7 +43,7 @@ export const useMotionSegmentUtils = (
const matchingEvent = motion_events.find((event) => {
return (
time >= getSegmentStart(event.start_time) &&
- time < getSegmentEnd(event.start_time)
+ time <= getSegmentEnd(event.start_time)
);
});
diff --git a/web/src/pages/UIPlayground.tsx b/web/src/pages/UIPlayground.tsx
index bbfe211b9..40ddb5d2a 100644
--- a/web/src/pages/UIPlayground.tsx
+++ b/web/src/pages/UIPlayground.tsx
@@ -124,7 +124,7 @@ function UIPlayground() {
const [mockEvents, setMockEvents] = useState([]);
const [mockMotionData, setMockMotionData] = useState([]);
const [handlebarTime, setHandlebarTime] = useState(
- Math.floor(Date.now() / 1000) - 15 * 60,
+ Math.round((Date.now() / 1000 - 15 * 60) / 60) * 60,
);
useMemo(() => {
@@ -285,7 +285,7 @@ function UIPlayground() {