adjust segment math

This commit is contained in:
Josh Hawkins 2024-03-04 13:41:44 -06:00
parent 282c92c9c8
commit a4c406c911
2 changed files with 18 additions and 22 deletions

View File

@ -217,10 +217,8 @@ export function MotionSegment({
className={`h-[2px] rounded-full bg-motion_review`} className={`h-[2px] rounded-full bg-motion_review`}
onClick={segmentClick} onClick={segmentClick}
style={{ style={{
width: width: interpolateMotionAudioData(
maxSegmentWidth - getMotionSegmentValue(segmentTime),
interpolateMotionAudioData(
getMotionSegmentValue(segmentTime - segmentDuration / 2),
0, 0,
100, 100,
1, 1,
@ -236,7 +234,7 @@ export function MotionSegment({
onClick={segmentClick} onClick={segmentClick}
style={{ style={{
width: interpolateMotionAudioData( width: interpolateMotionAudioData(
getAudioSegmentValue(segmentTime - segmentDuration / 2), getAudioSegmentValue(segmentTime),
-100, -100,
0, 0,
1, 1,
@ -254,10 +252,8 @@ export function MotionSegment({
className={`h-[2px] rounded-full bg-motion_review`} className={`h-[2px] rounded-full bg-motion_review`}
onClick={segmentClick} onClick={segmentClick}
style={{ style={{
width: width: interpolateMotionAudioData(
maxSegmentWidth - getMotionSegmentValue(segmentTime - segmentDuration / 2),
interpolateMotionAudioData(
getMotionSegmentValue(segmentTime),
0, 0,
100, 100,
1, 1,
@ -273,7 +269,7 @@ export function MotionSegment({
onClick={segmentClick} onClick={segmentClick}
style={{ style={{
width: interpolateMotionAudioData( width: interpolateMotionAudioData(
getAudioSegmentValue(segmentTime), getAudioSegmentValue(segmentTime - segmentDuration / 2),
-100, -100,
0, 0,
1, 1,

View File

@ -45,13 +45,13 @@ export const useMotionSegmentUtils = (
const matchingEvent = motion_events.find((event) => { const matchingEvent = motion_events.find((event) => {
return ( return (
time >= getSegmentStart(event.start_time) && time >= getSegmentStart(event.start_time) &&
time < getSegmentEnd(event.end_time) time < getSegmentEnd(event.start_time + segmentDuration / 2)
); );
}); });
return matchingEvent?.motionValue ?? 0; return matchingEvent?.motionValue ?? 0;
}, },
[motion_events, getSegmentStart, getSegmentEnd], [motion_events, getSegmentStart, getSegmentEnd, segmentDuration],
); );
const getAudioSegmentValue = useCallback( const getAudioSegmentValue = useCallback(