Multipoint arrows now have single point commit in binding zones

This commit is contained in:
Mark Tolmacs 2025-03-04 20:08:44 +01:00
parent ad8220c529
commit 11fe608f9a
3 changed files with 92 additions and 25 deletions

View file

@ -238,24 +238,23 @@ export class LinearElementEditor {
});
}
static getOutlineAvoidingPoint(
static getOutlineAvoidingPointOrNull(
element: NonDeleted<ExcalidrawLinearElement>,
coords: { x: number; y: number },
pointIndex: number,
app: AppClassProperties,
): GlobalPoint {
const elbowed = isElbowArrow(element);
) {
const hoveredElement = getHoveredElementForBinding(
coords,
app.scene.getNonDeletedElements(),
app.scene.getNonDeletedElementsMap(),
app.state.zoom,
true,
elbowed,
isElbowArrow(element),
);
const p = pointFrom<GlobalPoint>(coords.x, coords.y);
if (hoveredElement) {
const p = pointFrom<GlobalPoint>(coords.x, coords.y);
const newPoints = Array.from(element.points);
newPoints[pointIndex] = pointFrom<LocalPoint>(
p[0] - element.x,
@ -273,7 +272,27 @@ export class LinearElementEditor {
);
}
return p;
return null;
}
static getOutlineAvoidingPoint(
element: NonDeleted<ExcalidrawLinearElement>,
coords: { x: number; y: number },
pointIndex: number,
app: AppClassProperties,
): GlobalPoint {
const p = LinearElementEditor.getOutlineAvoidingPointOrNull(
element,
coords,
pointIndex,
app,
);
if (p) {
return p;
}
return pointFrom<GlobalPoint>(coords.x, coords.y);
}
/**