mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-11-20 04:34:20 +01:00
fix: New arrow preserved projection
This commit is contained in:
@@ -151,6 +151,7 @@ export const bindOrUnbindBindingElement = (
|
|||||||
opts?: {
|
opts?: {
|
||||||
newArrow?: boolean;
|
newArrow?: boolean;
|
||||||
altKey?: boolean;
|
altKey?: boolean;
|
||||||
|
initialBinding?: boolean;
|
||||||
},
|
},
|
||||||
) => {
|
) => {
|
||||||
const { start, end } = getBindingStrategyForDraggingBindingElementEndpoints(
|
const { start, end } = getBindingStrategyForDraggingBindingElementEndpoints(
|
||||||
@@ -557,6 +558,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
shiftKey?: boolean;
|
shiftKey?: boolean;
|
||||||
altKey?: boolean;
|
altKey?: boolean;
|
||||||
finalize?: boolean;
|
finalize?: boolean;
|
||||||
|
initialBinding?: boolean;
|
||||||
},
|
},
|
||||||
): { start: BindingStrategy; end: BindingStrategy } => {
|
): { start: BindingStrategy; end: BindingStrategy } => {
|
||||||
if (getFeatureFlag("COMPLEX_BINDINGS")) {
|
if (getFeatureFlag("COMPLEX_BINDINGS")) {
|
||||||
@@ -591,6 +593,7 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
shiftKey?: boolean;
|
shiftKey?: boolean;
|
||||||
altKey?: boolean;
|
altKey?: boolean;
|
||||||
finalize?: boolean;
|
finalize?: boolean;
|
||||||
|
initialBinding?: boolean;
|
||||||
},
|
},
|
||||||
): { start: BindingStrategy; end: BindingStrategy } => {
|
): { start: BindingStrategy; end: BindingStrategy } => {
|
||||||
const startIdx = 0;
|
const startIdx = 0;
|
||||||
@@ -658,28 +661,6 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
(e) => maxBindingGap_simple(e, e.width, e.height, appState.zoom),
|
(e) => maxBindingGap_simple(e, e.width, e.height, appState.zoom),
|
||||||
);
|
);
|
||||||
const pointInElement = hit && isPointInElement(globalPoint, hit, elementsMap);
|
const pointInElement = hit && isPointInElement(globalPoint, hit, elementsMap);
|
||||||
|
|
||||||
// Handle outside-outside binding with the same element
|
|
||||||
if (otherBinding && otherBinding.elementId === hit?.id && !pointInElement) {
|
|
||||||
const [startFixedPoint, endFixedPoint] = getGlobalFixedPoints(
|
|
||||||
arrow,
|
|
||||||
elementsMap,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
start: {
|
|
||||||
mode: "inside",
|
|
||||||
element: hit,
|
|
||||||
focusPoint: startDragged ? globalPoint : startFixedPoint,
|
|
||||||
},
|
|
||||||
end: {
|
|
||||||
mode: "inside",
|
|
||||||
element: hit,
|
|
||||||
focusPoint: endDragged ? globalPoint : endFixedPoint,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const otherBindableElement = otherBinding
|
const otherBindableElement = otherBinding
|
||||||
? (elementsMap.get(
|
? (elementsMap.get(
|
||||||
otherBinding.elementId,
|
otherBinding.elementId,
|
||||||
@@ -703,6 +684,32 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
otherFocusPoint &&
|
otherFocusPoint &&
|
||||||
isPointInElement(otherFocusPoint, otherBindableElement, elementsMap);
|
isPointInElement(otherFocusPoint, otherBindableElement, elementsMap);
|
||||||
|
|
||||||
|
// Handle outside-outside binding with the same element
|
||||||
|
if (
|
||||||
|
otherBinding &&
|
||||||
|
otherBinding.elementId === hit?.id &&
|
||||||
|
!pointInElement &&
|
||||||
|
!otherFocusPointIsInElement
|
||||||
|
) {
|
||||||
|
const [startFixedPoint, endFixedPoint] = getGlobalFixedPoints(
|
||||||
|
arrow,
|
||||||
|
elementsMap,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
start: {
|
||||||
|
mode: "inside",
|
||||||
|
element: hit,
|
||||||
|
focusPoint: startDragged ? globalPoint : startFixedPoint,
|
||||||
|
},
|
||||||
|
end: {
|
||||||
|
mode: "inside",
|
||||||
|
element: hit,
|
||||||
|
focusPoint: endDragged ? globalPoint : endFixedPoint,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const current: BindingStrategy = hit
|
const current: BindingStrategy = hit
|
||||||
? pointInElement || opts?.altKey
|
? pointInElement || opts?.altKey
|
||||||
? {
|
? {
|
||||||
@@ -736,13 +743,15 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
element: otherBindableElement,
|
element: otherBindableElement,
|
||||||
focusPoint:
|
focusPoint:
|
||||||
projectFixedPointOntoDiagonal(
|
otherFocusPointIsInElement && !opts?.initialBinding
|
||||||
arrow,
|
? otherFocusPoint
|
||||||
otherPoint,
|
: projectFixedPointOntoDiagonal(
|
||||||
otherBindableElement,
|
arrow,
|
||||||
startDragged ? "end" : "start",
|
otherPoint,
|
||||||
elementsMap,
|
otherBindableElement,
|
||||||
) || otherPoint,
|
startDragged ? "end" : "start",
|
||||||
|
elementsMap,
|
||||||
|
) || otherPoint,
|
||||||
}
|
}
|
||||||
: { mode: undefined };
|
: { mode: undefined };
|
||||||
|
|
||||||
@@ -762,6 +771,7 @@ const getBindingStrategyForDraggingBindingElementEndpoints_complex = (
|
|||||||
newArrow?: boolean;
|
newArrow?: boolean;
|
||||||
shiftKey?: boolean;
|
shiftKey?: boolean;
|
||||||
finalize?: boolean;
|
finalize?: boolean;
|
||||||
|
initialBinding?: boolean;
|
||||||
},
|
},
|
||||||
): { start: BindingStrategy; end: BindingStrategy } => {
|
): { start: BindingStrategy; end: BindingStrategy } => {
|
||||||
const globalBindMode = appState.bindMode || "orbit";
|
const globalBindMode = appState.bindMode || "orbit";
|
||||||
|
|||||||
@@ -8616,7 +8616,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
]),
|
]),
|
||||||
this.scene,
|
this.scene,
|
||||||
this.state,
|
this.state,
|
||||||
{ newArrow: true, altKey: event.altKey },
|
{ newArrow: true, altKey: event.altKey, initialBinding: true },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user