mobile support for client review player
Deploy / deploy (push) Failing after 5m17s

This commit is contained in:
twotalesanimation
2026-06-12 09:01:28 +02:00
parent 3248b8596a
commit 289e0c367a
5 changed files with 176 additions and 70 deletions
@@ -362,17 +362,73 @@ export function AnnotationCanvas({
}
}, [versionId, frameNumber, fps, selectedColor, annotationCommentedFrames, onAnnotationSaved, toast]);
// ── Touch events (mirrors mouse events for mobile drawing) ──────────────
const handleTouchStart = useCallback(
(e: React.TouchEvent<HTMLCanvasElement>) => {
if (!isAnnotating) return;
e.preventDefault();
const canvas = canvasRef.current;
if (!canvas) return;
const rect = canvas.getBoundingClientRect();
const touch = e.touches[0];
if (!touch) return;
const point: AnnotationPoint = {
x: (touch.clientX - rect.left) / rect.width,
y: (touch.clientY - rect.top) / rect.height,
};
const newShape: AnnotationShape = {
id: uuidv4(),
tool: selectedTool,
points: [point],
color: selectedColor,
strokeWidth,
frameNumber,
};
setDrawingState((prev) => ({ ...prev, isDrawing: true, currentShape: newShape }));
},
[isAnnotating, selectedTool, selectedColor, strokeWidth, frameNumber]
);
const handleTouchMove = useCallback(
(e: React.TouchEvent<HTMLCanvasElement>) => {
if (!drawingStateRef.current.isDrawing || !drawingStateRef.current.currentShape) return;
e.preventDefault();
const canvas = canvasRef.current;
if (!canvas) return;
const rect = canvas.getBoundingClientRect();
const touch = e.touches[0];
if (!touch) return;
const point: AnnotationPoint = {
x: (touch.clientX - rect.left) / rect.width,
y: (touch.clientY - rect.top) / rect.height,
};
setDrawingState((prev) => ({
...prev,
currentShape: prev.currentShape
? { ...prev.currentShape, points: [...prev.currentShape.points, point] }
: null,
}));
redraw();
},
[redraw]
);
return (
<canvas
ref={canvasRef}
className={`annotation-canvas-overlay ${isAnnotating ? "is-annotating" : ""}`}
style={{
cursor: isAnnotating ? "crosshair" : "default",
touchAction: isAnnotating ? "none" : "auto",
}}
onMouseDown={handleMouseDown}
onMouseMove={handleMouseMove}
onMouseUp={handleMouseUp}
onMouseLeave={handleMouseUp}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={() => void handleMouseUp()}
onTouchCancel={() => void handleMouseUp()}
/>
);
}