@@ -694,6 +694,7 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
localPoint,
|
localPoint,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
);
|
);
|
||||||
|
|
||||||
const hit = getHoveredElementForBinding(
|
const hit = getHoveredElementForBinding(
|
||||||
globalPoint,
|
globalPoint,
|
||||||
elements,
|
elements,
|
||||||
@@ -749,7 +750,8 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
: // NOTE: Can only affect the start point because new arrows always drag the end point
|
: // NOTE: Can only affect the start point because new arrows always drag the end point
|
||||||
opts?.newArrow
|
opts?.newArrow
|
||||||
? appState.selectedLinearElement!.initialState.origin!
|
? appState.selectedLinearElement!.initialState.origin!
|
||||||
: LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
: appState.selectedLinearElement?.initialState.altFocusPoint ||
|
||||||
|
LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||||
arrow,
|
arrow,
|
||||||
0,
|
0,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
@@ -760,7 +762,8 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
element: hit,
|
element: hit,
|
||||||
focusPoint: endDragged
|
focusPoint: endDragged
|
||||||
? globalPoint
|
? globalPoint
|
||||||
: LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
: appState.selectedLinearElement?.initialState.altFocusPoint ||
|
||||||
|
LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||||
arrow,
|
arrow,
|
||||||
-1,
|
-1,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
@@ -833,26 +836,41 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
overrideShouldTestInside: true,
|
overrideShouldTestInside: true,
|
||||||
});
|
});
|
||||||
const otherPointWasInsideAtStart =
|
const otherPointWasInsideAtStart =
|
||||||
!appState.selectedLinearElement?.initialState.altFocusPoint ||
|
appState.selectedLinearElement?.initialState
|
||||||
pointsEqual(
|
.arrowOtherEndpointInitialBinding?.mode === "inside";
|
||||||
appState.selectedLinearElement.initialState.altFocusPoint,
|
|
||||||
otherEndpoint,
|
|
||||||
);
|
|
||||||
const otherNeverOverride = opts?.newArrow
|
const otherNeverOverride = opts?.newArrow
|
||||||
? appState.selectedLinearElement?.initialState.arrowStartIsInside
|
? appState.selectedLinearElement?.initialState.arrowStartIsInside
|
||||||
: otherBinding?.mode === "inside" && otherPointWasInsideAtStart;
|
: otherBinding?.mode === "inside" && otherPointWasInsideAtStart;
|
||||||
const other: BindingStrategy = !otherNeverOverride
|
|
||||||
? otherBindableElement &&
|
let other: BindingStrategy = { mode: undefined };
|
||||||
|
if (!otherNeverOverride) {
|
||||||
|
if (
|
||||||
|
otherBinding?.mode === "inside" &&
|
||||||
|
!otherPointWasInsideAtStart &&
|
||||||
|
otherBindableElement
|
||||||
|
) {
|
||||||
|
other = {
|
||||||
|
mode: "orbit",
|
||||||
|
element: otherBindableElement,
|
||||||
|
focusPoint: getGlobalFixedPointForBindableElement(
|
||||||
|
otherBinding.fixedPoint,
|
||||||
|
otherBindableElement,
|
||||||
|
elementsMap,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
} else if (
|
||||||
|
otherBindableElement &&
|
||||||
!otherFocusPointIsInElement &&
|
!otherFocusPointIsInElement &&
|
||||||
!pointIsCloseToOtherElement &&
|
!pointIsCloseToOtherElement &&
|
||||||
appState.selectedLinearElement?.initialState.altFocusPoint
|
appState.selectedLinearElement?.initialState.altFocusPoint
|
||||||
? {
|
) {
|
||||||
|
other = {
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
element: otherBindableElement,
|
element: otherBindableElement,
|
||||||
focusPoint: appState.selectedLinearElement.initialState.altFocusPoint,
|
focusPoint: appState.selectedLinearElement.initialState.altFocusPoint,
|
||||||
}
|
};
|
||||||
: opts?.angleLocked && otherBindableElement
|
} else if (opts?.angleLocked && otherBindableElement) {
|
||||||
? {
|
other = {
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
element: otherBindableElement,
|
element: otherBindableElement,
|
||||||
focusPoint:
|
focusPoint:
|
||||||
@@ -865,9 +883,9 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
appState.zoom,
|
appState.zoom,
|
||||||
appState.isMidpointSnappingEnabled,
|
appState.isMidpointSnappingEnabled,
|
||||||
) || otherEndpoint,
|
) || otherEndpoint,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
: { mode: undefined }
|
|
||||||
: { mode: undefined };
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
start: startDragged ? current : other,
|
start: startDragged ? current : other,
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ export class LinearElementEditor {
|
|||||||
};
|
};
|
||||||
arrowStartIsInside: boolean;
|
arrowStartIsInside: boolean;
|
||||||
altFocusPoint: Readonly<GlobalPoint> | null;
|
altFocusPoint: Readonly<GlobalPoint> | null;
|
||||||
|
arrowOtherEndpointInitialBinding: FixedPointBinding | null;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/** whether you're dragging a point */
|
/** whether you're dragging a point */
|
||||||
@@ -193,6 +194,7 @@ export class LinearElementEditor {
|
|||||||
added: false,
|
added: false,
|
||||||
},
|
},
|
||||||
arrowStartIsInside: false,
|
arrowStartIsInside: false,
|
||||||
|
arrowOtherEndpointInitialBinding: null,
|
||||||
altFocusPoint: null,
|
altFocusPoint: null,
|
||||||
};
|
};
|
||||||
this.hoverPointIndex = -1;
|
this.hoverPointIndex = -1;
|
||||||
@@ -764,6 +766,7 @@ export class LinearElementEditor {
|
|||||||
...editingLinearElement.initialState,
|
...editingLinearElement.initialState,
|
||||||
origin: null,
|
origin: null,
|
||||||
arrowStartIsInside: false,
|
arrowStartIsInside: false,
|
||||||
|
arrowOtherEndpointInitialBinding: null,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1085,6 +1088,10 @@ export class LinearElementEditor {
|
|||||||
!!app.state.newElement &&
|
!!app.state.newElement &&
|
||||||
(app.state.bindMode === "inside" || app.state.bindMode === "skip"),
|
(app.state.bindMode === "inside" || app.state.bindMode === "skip"),
|
||||||
altFocusPoint: null,
|
altFocusPoint: null,
|
||||||
|
arrowOtherEndpointInitialBinding:
|
||||||
|
linearElementEditor.selectedPointsIndices?.includes(0)
|
||||||
|
? element.startBinding
|
||||||
|
: element.endBinding,
|
||||||
},
|
},
|
||||||
selectedPointsIndices: [element.points.length - 1],
|
selectedPointsIndices: [element.points.length - 1],
|
||||||
lastUncommittedPoint: null,
|
lastUncommittedPoint: null,
|
||||||
@@ -1147,6 +1154,10 @@ export class LinearElementEditor {
|
|||||||
!!app.state.newElement &&
|
!!app.state.newElement &&
|
||||||
(app.state.bindMode === "inside" || app.state.bindMode === "skip"),
|
(app.state.bindMode === "inside" || app.state.bindMode === "skip"),
|
||||||
altFocusPoint: null,
|
altFocusPoint: null,
|
||||||
|
arrowOtherEndpointInitialBinding:
|
||||||
|
linearElementEditor.selectedPointsIndices?.includes(0)
|
||||||
|
? element.startBinding
|
||||||
|
: element.endBinding,
|
||||||
},
|
},
|
||||||
selectedPointsIndices: nextSelectedPointsIndices,
|
selectedPointsIndices: nextSelectedPointsIndices,
|
||||||
pointerOffset: targetPoint
|
pointerOffset: targetPoint
|
||||||
@@ -2409,9 +2420,8 @@ const pointDraggingUpdates = (
|
|||||||
)! as ExcalidrawBindableElement)
|
)! as ExcalidrawBindableElement)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
const endLocalPoint = startIsDraggingOverEndElement
|
const endLocalPoint =
|
||||||
? nextArrow.points[nextArrow.points.length - 1]
|
endIsDraggingOverStartElement &&
|
||||||
: endIsDraggingOverStartElement &&
|
|
||||||
app.state.bindMode !== "inside" &&
|
app.state.bindMode !== "inside" &&
|
||||||
getFeatureFlag("COMPLEX_BINDINGS")
|
getFeatureFlag("COMPLEX_BINDINGS")
|
||||||
? nextArrow.points[0]
|
? nextArrow.points[0]
|
||||||
@@ -2458,13 +2468,11 @@ const pointDraggingUpdates = (
|
|||||||
: nextArrow.points[0];
|
: nextArrow.points[0];
|
||||||
|
|
||||||
const endChanged =
|
const endChanged =
|
||||||
!startIsDraggingOverEndElement &&
|
|
||||||
!(
|
!(
|
||||||
endIsDraggingOverStartElement &&
|
endIsDraggingOverStartElement &&
|
||||||
app.state.bindMode !== "inside" &&
|
app.state.bindMode !== "inside" &&
|
||||||
getFeatureFlag("COMPLEX_BINDINGS")
|
getFeatureFlag("COMPLEX_BINDINGS")
|
||||||
) &&
|
) && !!endBindable;
|
||||||
!!endBindable;
|
|
||||||
const startChanged =
|
const startChanged =
|
||||||
pointDistance(startLocalPoint, nextArrow.points[0]) !== 0;
|
pointDistance(startLocalPoint, nextArrow.points[0]) !== 0;
|
||||||
|
|
||||||
|
|||||||
@@ -8663,6 +8663,7 @@ exports[`regression tests > key 5 selects arrow tool > [end of test] appState 1`
|
|||||||
"hoveredFocusPointBinding": null,
|
"hoveredFocusPointBinding": null,
|
||||||
"initialState": {
|
"initialState": {
|
||||||
"altFocusPoint": null,
|
"altFocusPoint": null,
|
||||||
|
"arrowOtherEndpointInitialBinding": null,
|
||||||
"arrowStartIsInside": false,
|
"arrowStartIsInside": false,
|
||||||
"lastClickedPoint": -1,
|
"lastClickedPoint": -1,
|
||||||
"origin": null,
|
"origin": null,
|
||||||
@@ -8895,6 +8896,7 @@ exports[`regression tests > key 6 selects line tool > [end of test] appState 1`]
|
|||||||
"hoveredFocusPointBinding": null,
|
"hoveredFocusPointBinding": null,
|
||||||
"initialState": {
|
"initialState": {
|
||||||
"altFocusPoint": null,
|
"altFocusPoint": null,
|
||||||
|
"arrowOtherEndpointInitialBinding": null,
|
||||||
"arrowStartIsInside": false,
|
"arrowStartIsInside": false,
|
||||||
"lastClickedPoint": -1,
|
"lastClickedPoint": -1,
|
||||||
"origin": null,
|
"origin": null,
|
||||||
@@ -9317,6 +9319,7 @@ exports[`regression tests > key a selects arrow tool > [end of test] appState 1`
|
|||||||
"hoveredFocusPointBinding": null,
|
"hoveredFocusPointBinding": null,
|
||||||
"initialState": {
|
"initialState": {
|
||||||
"altFocusPoint": null,
|
"altFocusPoint": null,
|
||||||
|
"arrowOtherEndpointInitialBinding": null,
|
||||||
"arrowStartIsInside": false,
|
"arrowStartIsInside": false,
|
||||||
"lastClickedPoint": -1,
|
"lastClickedPoint": -1,
|
||||||
"origin": null,
|
"origin": null,
|
||||||
@@ -9729,6 +9732,7 @@ exports[`regression tests > key l selects line tool > [end of test] appState 1`]
|
|||||||
"hoveredFocusPointBinding": null,
|
"hoveredFocusPointBinding": null,
|
||||||
"initialState": {
|
"initialState": {
|
||||||
"altFocusPoint": null,
|
"altFocusPoint": null,
|
||||||
|
"arrowOtherEndpointInitialBinding": null,
|
||||||
"arrowStartIsInside": false,
|
"arrowStartIsInside": false,
|
||||||
"lastClickedPoint": -1,
|
"lastClickedPoint": -1,
|
||||||
"origin": null,
|
"origin": null,
|
||||||
|
|||||||
Reference in New Issue
Block a user