@@ -27,6 +27,7 @@ import type {
|
|||||||
ElementsMap,
|
ElementsMap,
|
||||||
ExcalidrawArrowElement,
|
ExcalidrawArrowElement,
|
||||||
ExcalidrawBindableElement,
|
ExcalidrawBindableElement,
|
||||||
|
FixedPointBinding,
|
||||||
NonDeletedSceneElementsMap,
|
NonDeletedSceneElementsMap,
|
||||||
PointsPositionUpdates,
|
PointsPositionUpdates,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
@@ -110,10 +111,17 @@ const focusPointUpdate = (
|
|||||||
) => {
|
) => {
|
||||||
const pointUpdates = new Map();
|
const pointUpdates = new Map();
|
||||||
|
|
||||||
|
const originalAdjacentBinding =
|
||||||
|
appState.selectedLinearElement?.initialState
|
||||||
|
.arrowOtherEndpointInitialBinding;
|
||||||
const bindingField = isStartBinding ? "startBinding" : "endBinding";
|
const bindingField = isStartBinding ? "startBinding" : "endBinding";
|
||||||
const adjacentBindingField = isStartBinding ? "endBinding" : "startBinding";
|
const adjacentBindingField = isStartBinding ? "endBinding" : "startBinding";
|
||||||
let currentBinding = arrow[bindingField];
|
let currentBinding = arrow[bindingField];
|
||||||
let adjacentBinding = arrow[adjacentBindingField];
|
let adjacentBinding =
|
||||||
|
originalAdjacentBinding?.mode === "orbit" &&
|
||||||
|
arrow[adjacentBindingField]?.mode === "inside"
|
||||||
|
? originalAdjacentBinding
|
||||||
|
: arrow[adjacentBindingField];
|
||||||
|
|
||||||
// Update the dragged focus point related end
|
// Update the dragged focus point related end
|
||||||
if (currentBinding && bindableElement) {
|
if (currentBinding && bindableElement) {
|
||||||
@@ -339,6 +347,7 @@ export const handleFocusPointPointerDown = (
|
|||||||
): {
|
): {
|
||||||
hitFocusPoint: "start" | "end" | null;
|
hitFocusPoint: "start" | "end" | null;
|
||||||
pointerOffset: { x: number; y: number };
|
pointerOffset: { x: number; y: number };
|
||||||
|
arrowOtherEndpointInitialBinding: FixedPointBinding | null;
|
||||||
} => {
|
} => {
|
||||||
const pointerPos = pointFrom(
|
const pointerPos = pointFrom(
|
||||||
pointerDownState.origin.x,
|
pointerDownState.origin.x,
|
||||||
@@ -376,6 +385,7 @@ export const handleFocusPointPointerDown = (
|
|||||||
x: pointerPos[0] - focusPoint[0],
|
x: pointerPos[0] - focusPoint[0],
|
||||||
y: pointerPos[1] - focusPoint[1],
|
y: pointerPos[1] - focusPoint[1],
|
||||||
},
|
},
|
||||||
|
arrowOtherEndpointInitialBinding: arrow.endBinding,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -411,6 +421,7 @@ export const handleFocusPointPointerDown = (
|
|||||||
x: pointerPos[0] - focusPoint[0],
|
x: pointerPos[0] - focusPoint[0],
|
||||||
y: pointerPos[1] - focusPoint[1],
|
y: pointerPos[1] - focusPoint[1],
|
||||||
},
|
},
|
||||||
|
arrowOtherEndpointInitialBinding: arrow.startBinding,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,13 +430,14 @@ export const handleFocusPointPointerDown = (
|
|||||||
return {
|
return {
|
||||||
hitFocusPoint: null,
|
hitFocusPoint: null,
|
||||||
pointerOffset: { x: 0, y: 0 },
|
pointerOffset: { x: 0, y: 0 },
|
||||||
|
arrowOtherEndpointInitialBinding: null,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleFocusPointPointerUp = (
|
export const handleFocusPointPointerUp = (
|
||||||
linearElementEditor: LinearElementEditor,
|
linearElementEditor: LinearElementEditor,
|
||||||
scene: Scene,
|
scene: Scene,
|
||||||
) => {
|
): { arrowOtherEndpointInitialBinding: FixedPointBinding | null } => {
|
||||||
invariant(
|
invariant(
|
||||||
linearElementEditor.draggedFocusPointBinding,
|
linearElementEditor.draggedFocusPointBinding,
|
||||||
"Must have a dragged focus point at pointer release",
|
"Must have a dragged focus point at pointer release",
|
||||||
@@ -483,6 +495,10 @@ export const handleFocusPointPointerUp = (
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
arrowOtherEndpointInitialBinding: null,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handleFocusPointHover = (
|
export const handleFocusPointHover = (
|
||||||
|
|||||||
@@ -1088,10 +1088,7 @@ 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:
|
arrowOtherEndpointInitialBinding: element.startBinding,
|
||||||
linearElementEditor.selectedPointsIndices?.includes(0)
|
|
||||||
? element.startBinding
|
|
||||||
: element.endBinding,
|
|
||||||
},
|
},
|
||||||
selectedPointsIndices: [element.points.length - 1],
|
selectedPointsIndices: [element.points.length - 1],
|
||||||
lastUncommittedPoint: null,
|
lastUncommittedPoint: null,
|
||||||
@@ -1154,10 +1151,9 @@ 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:
|
arrowOtherEndpointInitialBinding: nextSelectedPointsIndices?.includes(0)
|
||||||
linearElementEditor.selectedPointsIndices?.includes(0)
|
? element.endBinding
|
||||||
? element.startBinding
|
: element.startBinding,
|
||||||
: element.endBinding,
|
|
||||||
},
|
},
|
||||||
selectedPointsIndices: nextSelectedPointsIndices,
|
selectedPointsIndices: nextSelectedPointsIndices,
|
||||||
pointerOffset: targetPoint
|
pointerOffset: targetPoint
|
||||||
|
|||||||
@@ -8396,8 +8396,11 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
) as any;
|
) as any;
|
||||||
|
|
||||||
if (arrow && isBindingElement(arrow)) {
|
if (arrow && isBindingElement(arrow)) {
|
||||||
const { hitFocusPoint, pointerOffset } =
|
const {
|
||||||
handleFocusPointPointerDown(
|
hitFocusPoint,
|
||||||
|
pointerOffset,
|
||||||
|
arrowOtherEndpointInitialBinding,
|
||||||
|
} = handleFocusPointPointerDown(
|
||||||
arrow,
|
arrow,
|
||||||
pointerDownState,
|
pointerDownState,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
@@ -8412,6 +8415,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
hoveredFocusPointBinding: hitFocusPoint,
|
hoveredFocusPointBinding: hitFocusPoint,
|
||||||
draggedFocusPointBinding: hitFocusPoint,
|
draggedFocusPointBinding: hitFocusPoint,
|
||||||
pointerOffset,
|
pointerOffset,
|
||||||
|
initialState: {
|
||||||
|
...linearElementEditor.initialState,
|
||||||
|
arrowOtherEndpointInitialBinding,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -10524,6 +10531,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.selectedLinearElement.draggedFocusPointBinding) {
|
if (this.state.selectedLinearElement.draggedFocusPointBinding) {
|
||||||
|
const { arrowOtherEndpointInitialBinding } =
|
||||||
handleFocusPointPointerUp(
|
handleFocusPointPointerUp(
|
||||||
this.state.selectedLinearElement,
|
this.state.selectedLinearElement,
|
||||||
this.scene,
|
this.scene,
|
||||||
@@ -10532,6 +10540,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
selectedLinearElement: {
|
selectedLinearElement: {
|
||||||
...this.state.selectedLinearElement,
|
...this.state.selectedLinearElement,
|
||||||
draggedFocusPointBinding: null,
|
draggedFocusPointBinding: null,
|
||||||
|
initialState: {
|
||||||
|
...this.state.selectedLinearElement.initialState,
|
||||||
|
arrowOtherEndpointInitialBinding,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else if (
|
} else if (
|
||||||
|
|||||||
Reference in New Issue
Block a user