main
parent
520099b31d
commit
a907f2781c
|
@ -169,9 +169,23 @@ const DrawingCanvas = () => {
|
|||
setShapes(prev => {
|
||||
const updated = [...prev];
|
||||
const shape = { ...updated[selectedIndex] };
|
||||
// Move shape based on offset
|
||||
if (shape.type === 'pencil') {
|
||||
// Calculate movement delta
|
||||
const dx = x - offset.x - shape.points[0].x;
|
||||
const dy = y - offset.y - shape.points[0].y;
|
||||
shape.points = shape.points.map(pt => ({
|
||||
x: pt.x + dx,
|
||||
y: pt.y + dy
|
||||
}));
|
||||
// Update offset so dragging is smooth
|
||||
setOffset({
|
||||
x: x - shape.points[0].x,
|
||||
y: y - shape.points[0].y
|
||||
});
|
||||
} else {
|
||||
shape.x = x - offset.x;
|
||||
shape.y = y - offset.y;
|
||||
}
|
||||
updated[selectedIndex] = shape;
|
||||
return updated;
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue