mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
Bind mode on precise binding
Fix binding to inside element Fix initial arrow not following cursor (white dot) Fix elbow arrow
This commit is contained in:
@ -139,7 +139,7 @@ export const bindOrUnbindBindingElement = (
|
||||
);
|
||||
bindOrUnbindBindingElementEdge(arrow, start, "start", scene);
|
||||
bindOrUnbindBindingElementEdge(arrow, end, "end", scene);
|
||||
if (start.focusPoint || end.focusPoint) {
|
||||
if (!isElbowArrow(arrow) && (start.focusPoint || end.focusPoint)) {
|
||||
// If the strategy dictates a focus point override, then
|
||||
// update the arrow points to point to the focus point.
|
||||
const updates: PointsPositionUpdates = new Map();
|
||||
|
@ -6233,6 +6233,16 @@ class App extends React.Component<AppProps, AppState> {
|
||||
multiElement.startBinding.mode === "orbit"
|
||||
) {
|
||||
const elementsMap = this.scene.getNonDeletedElementsMap();
|
||||
const hoveredElement = getHoveredElementForBinding(
|
||||
pointFrom<GlobalPoint>(scenePointerX, scenePointerY),
|
||||
this.scene.getNonDeletedElements(),
|
||||
this.scene.getNonDeletedElementsMap(),
|
||||
this.state.zoom,
|
||||
);
|
||||
if (
|
||||
!hoveredElement ||
|
||||
hoveredElement.id !== multiElement.startBinding.elementId
|
||||
) {
|
||||
const startPoint =
|
||||
LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||
multiElement,
|
||||
@ -6270,6 +6280,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// in this path, we're mutating multiElement to reflect
|
||||
// how it will be after adding pointer position as the next point
|
||||
@ -6933,9 +6944,13 @@ class App extends React.Component<AppProps, AppState> {
|
||||
clearTimeout(this.bindModeHandler);
|
||||
}
|
||||
this.bindModeHandler = null;
|
||||
// We need this iteration to complete binding and change
|
||||
// back to orbit mode after that
|
||||
setTimeout(() =>
|
||||
this.setState({
|
||||
bindMode: "orbit",
|
||||
});
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const scenePointer = viewportCoordsToSceneCoords(
|
||||
@ -8494,26 +8509,6 @@ class App extends React.Component<AppProps, AppState> {
|
||||
event[KEYS.CTRL_OR_CMD] ? null : this.getEffectiveGridSize(),
|
||||
);
|
||||
|
||||
// for arrows/lines, don't start dragging until a given threshold
|
||||
// to ensure we don't create a 2-point arrow by mistake when
|
||||
// user clicks mouse in a way that it moves a tiny bit (thus
|
||||
// triggering pointermove)
|
||||
if (
|
||||
!pointerDownState.drag.hasOccurred &&
|
||||
(this.state.activeTool.type === "arrow" ||
|
||||
this.state.activeTool.type === "line")
|
||||
) {
|
||||
if (
|
||||
pointDistance(
|
||||
pointFrom(pointerCoords.x, pointerCoords.y),
|
||||
pointFrom(pointerDownState.origin.x, pointerDownState.origin.y),
|
||||
) *
|
||||
this.state.zoom.value <
|
||||
MINIMUM_ARROW_SIZE
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (pointerDownState.resize.isResizing) {
|
||||
pointerDownState.lastCoords.x = pointerCoords.x;
|
||||
pointerDownState.lastCoords.y = pointerCoords.y;
|
||||
|
Reference in New Issue
Block a user