Skip to content
Snippets Groups Projects
Commit 688f9348 authored by Anthony's avatar Anthony
Browse files

WIP Fix freehand line tool

parent cb5e7355
Branches
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
...@@ -162,18 +162,17 @@ function AnnotationDrawing(props) { ...@@ -162,18 +162,17 @@ function AnnotationDrawing(props) {
// Handle other cases if any // Handle other cases if any
} }
// TODO Why this ? if (!currentShape) {
// if (this.state.currentShape === null) return; return;
// // Check if the current shape is a freehand object }
// if (this.state.selectedShapeId && this.state.currentShape.type === 'freehand') { // Check if the current shape is a freehand object
// // Start drawing if (currentShape.type === 'freehand') {
// this.setState({ // Start drawing
// isDrawing: true, setIsDrawing(true);
// shapes: this.state.shapes.map((shape) => (shape.id === this.state.selectedShapeId setShapes(shapes.map((s) => (s.id === currentShape.id
// ? { ...shape, points: [...shape.points, e.evt.clientX, e.evt.clientY] } ? { ...shape, points: [...s.points, e.evt.clientX, e.evt.clientY] }
// : shape)), : shape)));
// }); }
// }
} catch (error) { } catch (error) {
console.log('error', error); console.log('error', error);
} }
...@@ -222,7 +221,7 @@ function AnnotationDrawing(props) { ...@@ -222,7 +221,7 @@ function AnnotationDrawing(props) {
// TODO Break missing ? // TODO Break missing ?
case 'freehand': case 'freehand':
setShapes(shapes.map((shape) => (shape.id === selectedShapeId setShapes(shapes.map((shape) => (shape.id === currentShape.id
? { ...shape, points: [...shape.points, e.evt.clientX, e.evt.clientY] } ? { ...shape, points: [...shape.points, e.evt.clientX, e.evt.clientY] }
: shape))); : shape)));
break; break;
...@@ -235,10 +234,8 @@ function AnnotationDrawing(props) { ...@@ -235,10 +234,8 @@ function AnnotationDrawing(props) {
} }
}; };
/** */ /** Stop drawing */
const handleMouseUp = () => { const handleMouseUp = () => {
// Stop drawing
try { try {
console.log('mouse up', props.activeTool); console.log('mouse up', props.activeTool);
if (!isDrawing) return; if (!isDrawing) return;
...@@ -264,7 +261,7 @@ function AnnotationDrawing(props) { ...@@ -264,7 +261,7 @@ function AnnotationDrawing(props) {
/** */ /** */
const drawKonvas = () => { const drawKonvas = () => {
const shape = shapes.find((s) => s.id === selectedShapeId); const shape = shapes.find((s) => s.id === currentShape?.id);
if (shape) { if (shape) {
// if all the props are the same we don't update the shape // if all the props are the same we don't update the shape
...@@ -273,7 +270,8 @@ function AnnotationDrawing(props) { ...@@ -273,7 +270,8 @@ function AnnotationDrawing(props) {
shape.strokeColor = props.strokeColor; shape.strokeColor = props.strokeColor;
shape.strokeWidth = props.strokeWidth; shape.strokeWidth = props.strokeWidth;
const updatedShapes = shapes.map((s) => (s.id === selectedShapeId ? shape : s)); // TODO breaking somethinh here
const updatedShapes = shapes.map((s) => (s.id === currentShape?.id ? shape : s));
setShapes(updatedShapes); setShapes(updatedShapes);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment