mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-29 20:29:53 +02:00
Simplify state
This commit is contained in:
@@ -303,8 +303,7 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
|
||||
|
||||
// With new arrows it represents the continuous dragging of the end point
|
||||
if (endDragged) {
|
||||
const arrowOriginalStartPoint =
|
||||
appState?.selectedLinearElement?.pointerDownState.arrowOriginalStartPoint;
|
||||
const origin = appState?.selectedLinearElement?.pointerDownState.origin;
|
||||
|
||||
// Inside -> inside binding
|
||||
if (hit && arrow.startBinding?.elementId === hit.id) {
|
||||
@@ -317,7 +316,7 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
|
||||
start: {
|
||||
mode: "inside",
|
||||
element: hit,
|
||||
focusPoint: arrowOriginalStartPoint ?? center,
|
||||
focusPoint: origin ?? center,
|
||||
},
|
||||
end: { mode: "inside", element: hit, focusPoint: point },
|
||||
};
|
||||
@@ -337,12 +336,11 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
|
||||
mode: otherIsInsideBinding ? "inside" : "orbit",
|
||||
element: otherElement,
|
||||
focusPoint: otherIsInsideBinding
|
||||
? arrowOriginalStartPoint ?? pointFrom<GlobalPoint>(arrow.x, arrow.y)
|
||||
? origin ?? pointFrom<GlobalPoint>(arrow.x, arrow.y)
|
||||
: snapToCenter(
|
||||
otherElement,
|
||||
elementsMap,
|
||||
arrowOriginalStartPoint ??
|
||||
pointFrom<GlobalPoint>(arrow.x, arrow.y),
|
||||
origin ?? pointFrom<GlobalPoint>(arrow.x, arrow.y),
|
||||
),
|
||||
};
|
||||
|
||||
|
@@ -135,13 +135,12 @@ export class LinearElementEditor {
|
||||
prevSelectedPointsIndices: readonly number[] | null;
|
||||
/** index */
|
||||
lastClickedPoint: number;
|
||||
origin: Readonly<{ x: number; y: number }> | null;
|
||||
origin: Readonly<GlobalPoint> | null;
|
||||
segmentMidpoint: {
|
||||
value: GlobalPoint | null;
|
||||
index: number | null;
|
||||
added: boolean;
|
||||
};
|
||||
arrowOriginalStartPoint?: GlobalPoint;
|
||||
arrowStartIsInside: boolean;
|
||||
}>;
|
||||
|
||||
@@ -631,7 +630,7 @@ export class LinearElementEditor {
|
||||
customLineAngle: null,
|
||||
pointerDownState: {
|
||||
...editingLinearElement.pointerDownState,
|
||||
arrowOriginalStartPoint: undefined,
|
||||
origin: null,
|
||||
arrowStartIsInside: false,
|
||||
},
|
||||
};
|
||||
@@ -933,7 +932,7 @@ export class LinearElementEditor {
|
||||
pointerDownState: {
|
||||
prevSelectedPointsIndices: linearElementEditor.selectedPointsIndices,
|
||||
lastClickedPoint: -1,
|
||||
origin: { x: scenePointer.x, y: scenePointer.y },
|
||||
origin: pointFrom<GlobalPoint>(scenePointer.x, scenePointer.y),
|
||||
segmentMidpoint: {
|
||||
value: segmentMidpoint,
|
||||
index: segmentMidpointIndex,
|
||||
@@ -994,7 +993,7 @@ export class LinearElementEditor {
|
||||
pointerDownState: {
|
||||
prevSelectedPointsIndices: linearElementEditor.selectedPointsIndices,
|
||||
lastClickedPoint: clickedPointIndex,
|
||||
origin: { x: scenePointer.x, y: scenePointer.y },
|
||||
origin: pointFrom<GlobalPoint>(scenePointer.x, scenePointer.y),
|
||||
segmentMidpoint: {
|
||||
value: segmentMidpoint,
|
||||
index: segmentMidpointIndex,
|
||||
@@ -1525,7 +1524,7 @@ export class LinearElementEditor {
|
||||
|
||||
const origin = linearElementEditor.pointerDownState.origin!;
|
||||
const dist = pointDistance(
|
||||
pointFrom(origin.x, origin.y),
|
||||
origin,
|
||||
pointFrom(pointerCoords.x, pointerCoords.y),
|
||||
);
|
||||
if (
|
||||
|
@@ -280,7 +280,7 @@ export const actionFinalize = register<FormData>({
|
||||
: selectedLinearElement.isEditing,
|
||||
pointerDownState: {
|
||||
...selectedLinearElement.pointerDownState,
|
||||
arrowOriginalStartPoint: undefined,
|
||||
origin: null,
|
||||
},
|
||||
}
|
||||
: selectedLinearElement;
|
||||
|
@@ -8346,7 +8346,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
pointerDownState: {
|
||||
...linearElementEditor.pointerDownState,
|
||||
lastClickedPoint: endIdx,
|
||||
arrowOriginalStartPoint: pointFrom<GlobalPoint>(
|
||||
origin: pointFrom<GlobalPoint>(
|
||||
pointerDownState.origin.x,
|
||||
pointerDownState.origin.y,
|
||||
),
|
||||
|
Reference in New Issue
Block a user