mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-02-14 00:17:05 +01:00
simplify interp and fix math
This commit is contained in:
parent
a4c406c911
commit
648f615560
@ -219,9 +219,6 @@ export function MotionSegment({
|
||||
style={{
|
||||
width: interpolateMotionAudioData(
|
||||
getMotionSegmentValue(segmentTime),
|
||||
0,
|
||||
100,
|
||||
1,
|
||||
maxSegmentWidth,
|
||||
),
|
||||
}}
|
||||
@ -235,9 +232,6 @@ export function MotionSegment({
|
||||
style={{
|
||||
width: interpolateMotionAudioData(
|
||||
getAudioSegmentValue(segmentTime),
|
||||
-100,
|
||||
0,
|
||||
1,
|
||||
maxSegmentWidth,
|
||||
),
|
||||
}}
|
||||
@ -253,10 +247,7 @@ export function MotionSegment({
|
||||
onClick={segmentClick}
|
||||
style={{
|
||||
width: interpolateMotionAudioData(
|
||||
getMotionSegmentValue(segmentTime - segmentDuration / 2),
|
||||
0,
|
||||
100,
|
||||
1,
|
||||
getMotionSegmentValue(segmentTime + segmentDuration / 2),
|
||||
maxSegmentWidth,
|
||||
),
|
||||
}}
|
||||
@ -269,10 +260,7 @@ export function MotionSegment({
|
||||
onClick={segmentClick}
|
||||
style={{
|
||||
width: interpolateMotionAudioData(
|
||||
getAudioSegmentValue(segmentTime - segmentDuration / 2),
|
||||
-100,
|
||||
0,
|
||||
1,
|
||||
getAudioSegmentValue(segmentTime + segmentDuration / 2),
|
||||
maxSegmentWidth,
|
||||
),
|
||||
}}
|
||||
|
@ -26,16 +26,8 @@ export const useMotionSegmentUtils = (
|
||||
);
|
||||
|
||||
const interpolateMotionAudioData = useCallback(
|
||||
(
|
||||
value: number,
|
||||
oldMin: number,
|
||||
oldMax: number,
|
||||
newMin: number,
|
||||
newMax: number,
|
||||
): number => {
|
||||
return (
|
||||
((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin
|
||||
);
|
||||
(value: number, newMax: number): number => {
|
||||
return Math.ceil((Math.abs(value) / 100.0) * newMax) || 1;
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user