mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Fix simultaneous update issue with arrows
This commit is contained in:
parent
272b418445
commit
868517ab75
1 changed files with 58 additions and 54 deletions
|
@ -178,61 +178,65 @@ export const moveElement = (
|
|||
}
|
||||
|
||||
if (isFrameLikeElement(originalElement)) {
|
||||
getFrameChildren(originalElementsMap, originalElement.id).forEach(
|
||||
(child) => {
|
||||
const latestChildElement = elementsMap.get(child.id);
|
||||
|
||||
if (!latestChildElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [childCX, childCY] = [
|
||||
child.x + child.width / 2,
|
||||
child.y + child.height / 2,
|
||||
];
|
||||
const [childTopLeftX, childTopLeftY] = pointRotateRads(
|
||||
pointFrom(child.x, child.y),
|
||||
pointFrom(childCX, childCY),
|
||||
child.angle,
|
||||
);
|
||||
|
||||
const childNewTopLeftX = Math.round(childTopLeftX + changeInX);
|
||||
const childNewTopLeftY = Math.round(childTopLeftY + changeInY);
|
||||
|
||||
const [childX, childY] = pointRotateRads(
|
||||
pointFrom(childNewTopLeftX, childNewTopLeftY),
|
||||
pointFrom(childCX + changeInX, childCY + changeInY),
|
||||
-child.angle as Radians,
|
||||
);
|
||||
|
||||
scene.mutateElement(
|
||||
latestChildElement,
|
||||
{
|
||||
x: childX,
|
||||
y: childY,
|
||||
},
|
||||
{ informMutation: shouldInformMutation, isDragging: false },
|
||||
);
|
||||
updateBindings(latestChildElement, scene);
|
||||
|
||||
const boundTextElement = getBoundTextElement(
|
||||
latestChildElement,
|
||||
originalElementsMap,
|
||||
);
|
||||
if (boundTextElement) {
|
||||
const latestBoundTextElement = elementsMap.get(boundTextElement.id);
|
||||
latestBoundTextElement &&
|
||||
scene.mutateElement(
|
||||
latestBoundTextElement,
|
||||
{
|
||||
x: boundTextElement.x + changeInX,
|
||||
y: boundTextElement.y + changeInY,
|
||||
},
|
||||
{ informMutation: shouldInformMutation, isDragging: false },
|
||||
);
|
||||
}
|
||||
},
|
||||
const originalChildren = getFrameChildren(
|
||||
originalElementsMap,
|
||||
originalElement.id,
|
||||
);
|
||||
originalChildren.forEach((child) => {
|
||||
const latestChildElement = elementsMap.get(child.id);
|
||||
|
||||
if (!latestChildElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
const [childCX, childCY] = [
|
||||
child.x + child.width / 2,
|
||||
child.y + child.height / 2,
|
||||
];
|
||||
const [childTopLeftX, childTopLeftY] = pointRotateRads(
|
||||
pointFrom(child.x, child.y),
|
||||
pointFrom(childCX, childCY),
|
||||
child.angle,
|
||||
);
|
||||
|
||||
const childNewTopLeftX = Math.round(childTopLeftX + changeInX);
|
||||
const childNewTopLeftY = Math.round(childTopLeftY + changeInY);
|
||||
|
||||
const [childX, childY] = pointRotateRads(
|
||||
pointFrom(childNewTopLeftX, childNewTopLeftY),
|
||||
pointFrom(childCX + changeInX, childCY + changeInY),
|
||||
-child.angle as Radians,
|
||||
);
|
||||
|
||||
scene.mutateElement(
|
||||
latestChildElement,
|
||||
{
|
||||
x: childX,
|
||||
y: childY,
|
||||
},
|
||||
{ informMutation: shouldInformMutation, isDragging: false },
|
||||
);
|
||||
updateBindings(latestChildElement, scene, {
|
||||
simultaneouslyUpdated: originalChildren,
|
||||
});
|
||||
|
||||
const boundTextElement = getBoundTextElement(
|
||||
latestChildElement,
|
||||
originalElementsMap,
|
||||
);
|
||||
if (boundTextElement) {
|
||||
const latestBoundTextElement = elementsMap.get(boundTextElement.id);
|
||||
latestBoundTextElement &&
|
||||
scene.mutateElement(
|
||||
latestBoundTextElement,
|
||||
{
|
||||
x: boundTextElement.x + changeInX,
|
||||
y: boundTextElement.y + changeInY,
|
||||
},
|
||||
{ informMutation: shouldInformMutation, isDragging: false },
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue