diff --git a/web/src/CameraMap.jsx b/web/src/CameraMap.jsx
index ad1d5ffcf..27f2f632c 100644
--- a/web/src/CameraMap.jsx
+++ b/web/src/CameraMap.jsx
@@ -96,18 +96,14 @@ export default function Camera({ camera, url }) {
);
}
-function EditableMask({ onChange, points: initialPoints, scale, width, height }) {
- const [points, setPoints] = useState(initialPoints);
-
- useEffect(() => {
- setPoints(initialPoints);
- }, [setPoints, initialPoints]);
+function EditableMask({ onChange, points, scale, width, height }) {
+ const boundingRef = useRef(null);
function boundedSize(value, maxValue) {
return Math.min(Math.max(0, Math.round(value)), maxValue);
}
- const handleDragEnd = useCallback(
+ const handleMovePoint = useCallback(
(index, newX, newY) => {
if (newX < 0 && newY < 0) {
return;
@@ -116,10 +112,9 @@ function EditableMask({ onChange, points: initialPoints, scale, width, height })
const y = boundedSize(newY / scale, height);
const newPoints = [...points];
newPoints[index] = [x, y];
- setPoints(newPoints);
onChange(newPoints);
},
- [scale, points, setPoints]
+ [scale, points]
);
// Add a new point between the closest two other points
@@ -138,20 +133,18 @@ function EditableMask({ onChange, points: initialPoints, scale, width, height })
const index = points.indexOf(closest);
const newPoints = [...points];
newPoints.splice(index, 0, newPoint);
- setPoints(newPoints);
onChange(newPoints);
},
- [scale, points, setPoints, onChange]
+ [scale, points, onChange]
);
const handleRemovePoint = useCallback(
(index) => {
const newPoints = [...points];
newPoints.splice(index, 1);
- setPoints(newPoints);
onChange(newPoints);
},
- [points, setPoints, onChange]
+ [points, onChange]
);
const scaledPoints = useMemo(() => scalePolylinePoints(points, scale), [points, scale]);
@@ -161,9 +154,22 @@ function EditableMask({ onChange, points: initialPoints, scale, width, height })
{!scaledPoints
? null
: scaledPoints.map(([x, y], i) => (
-
+
))}
-