Do not move mid point for simple arrows bound on both ends

This commit is contained in:
Mark Tolmacs 2025-06-24 17:27:42 +02:00
parent c4a52a982a
commit 06dc04ea5d
No known key found for this signature in database
2 changed files with 16 additions and 1 deletions

View File

@ -863,7 +863,10 @@ export const updateBoundElements = (
? elementsMap.get(element.startBinding.elementId)
: null;
const endBindingElement = element.endBinding
? elementsMap.get(element.endBinding.elementId)
? // PERF: If the arrow is bound to the same element on both ends.
startBindingElement?.id === element.endBinding.elementId
? startBindingElement
: elementsMap.get(element.endBinding.elementId)
: null;
let startBounds: Bounds | null = null;
@ -936,6 +939,9 @@ export const updateBoundElements = (
...(changedElement.id === element.endBinding?.elementId
? { endBinding: bindings.endBinding }
: {}),
moveMidPointsWithElement:
!!startBindingElement &&
startBindingElement?.id === endBindingElement?.id,
});
const boundText = getBoundTextElement(element, elementsMap);

View File

@ -1426,6 +1426,7 @@ export class LinearElementEditor {
otherUpdates?: {
startBinding?: PointBinding | null;
endBinding?: PointBinding | null;
moveMidPointsWithElement?: boolean | null;
},
) {
const { points } = element;
@ -1471,6 +1472,14 @@ export class LinearElementEditor {
: points.map((p, idx) => {
const current = pointUpdates.get(idx)?.point ?? p;
if (
otherUpdates?.moveMidPointsWithElement &&
idx !== 0 &&
idx !== points.length - 1
) {
return pointFrom<LocalPoint>(current[0], current[1]);
}
return pointFrom<LocalPoint>(
current[0] - offsetX,
current[1] - offsetY,