fix: Angle snapping around bindable objects incorrectly resolves (#10501)

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
Co-authored-by: zsviczian <viczian.zsolt@gmail.com>
This commit is contained in:
Márk Tolmács
2025-12-15 10:49:46 +01:00
committed by GitHub
parent bf4c65f483
commit f06484c6ab
4 changed files with 60 additions and 11 deletions
+16 -4
View File
@@ -343,6 +343,8 @@ export class LinearElementEditor {
[idx],
deltaX,
deltaY,
scenePointerX,
scenePointerY,
elementsMap,
element,
elements,
@@ -498,7 +500,6 @@ export class LinearElementEditor {
width + pivotPoint[0],
height + pivotPoint[1],
);
deltaX = target[0] - draggingPoint[0];
deltaY = target[1] - draggingPoint[1];
} else {
@@ -519,6 +520,8 @@ export class LinearElementEditor {
selectedPointsIndices,
deltaX,
deltaY,
scenePointerX,
scenePointerY,
elementsMap,
element,
elements,
@@ -2066,6 +2069,8 @@ const pointDraggingUpdates = (
selectedPointsIndices: readonly number[],
deltaX: number,
deltaY: number,
scenePointerX: number,
scenePointerY: number,
elementsMap: NonDeletedSceneElementsMap,
element: NonDeleted<ExcalidrawLinearElement>,
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
@@ -2106,6 +2111,8 @@ const pointDraggingUpdates = (
const { start, end } = getBindingStrategyForDraggingBindingElementEndpoints(
element,
naiveDraggingPoints,
scenePointerX,
scenePointerY,
elementsMap,
elements,
app.state,
@@ -2228,10 +2235,15 @@ const pointDraggingUpdates = (
// We need to use a custom intersector to ensure that if there is a big "jump"
// in the arrow's position, we can position it with outline avoidance
// pixel-perfectly and avoid "dancing" arrows.
const customIntersector =
// NOTE: Direction matters here, so we create two intersectors
const startCustomIntersector =
start.focusPoint && end.focusPoint
? lineSegment(start.focusPoint, end.focusPoint)
: undefined;
const endCustomIntersector =
start.focusPoint && end.focusPoint
? lineSegment(end.focusPoint, start.focusPoint)
: undefined;
// Needed to handle a special case where an existing arrow is dragged over
// the same element it is bound to on the other side
@@ -2268,7 +2280,7 @@ const pointDraggingUpdates = (
nextArrow.endBinding,
endBindable,
elementsMap,
customIntersector,
endCustomIntersector,
) || nextArrow.points[nextArrow.points.length - 1]
: nextArrow.points[nextArrow.points.length - 1];
@@ -2299,7 +2311,7 @@ const pointDraggingUpdates = (
nextArrow.startBinding,
startBindable,
elementsMap,
customIntersector,
startCustomIntersector,
) || nextArrow.points[0]
: nextArrow.points[0];