mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-10-14 11:39:54 +02:00
@@ -35,7 +35,6 @@ import {
|
||||
import {
|
||||
getAllHoveredElementAtPoint,
|
||||
getHoveredElementForBinding,
|
||||
hitElementItself,
|
||||
intersectElementWithLineSegment,
|
||||
isPointInElement,
|
||||
} from "./collision";
|
||||
@@ -644,68 +643,6 @@ export const bindOrUnbindBindingElements = (
|
||||
});
|
||||
};
|
||||
|
||||
export const maybeSuggestBindingsForBindingElementAtCoords = (
|
||||
linearElement: NonDeleted<ExcalidrawArrowElement>,
|
||||
startOrEndOrBoth: "start" | "end" | "both",
|
||||
scene: Scene,
|
||||
pointerCoords: GlobalPoint,
|
||||
): AppState["suggestedBinding"] => {
|
||||
const startCoords =
|
||||
startOrEndOrBoth === "start"
|
||||
? pointerCoords
|
||||
: LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||
linearElement,
|
||||
0,
|
||||
scene.getNonDeletedElementsMap(),
|
||||
);
|
||||
const endCoords =
|
||||
startOrEndOrBoth === "end"
|
||||
? pointerCoords
|
||||
: LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||
linearElement,
|
||||
-1,
|
||||
scene.getNonDeletedElementsMap(),
|
||||
);
|
||||
const startHovered = getHoveredElementForBinding(
|
||||
startCoords,
|
||||
scene.getNonDeletedElements(),
|
||||
scene.getNonDeletedElementsMap(),
|
||||
);
|
||||
const endHovered = getHoveredElementForBinding(
|
||||
endCoords,
|
||||
scene.getNonDeletedElements(),
|
||||
scene.getNonDeletedElementsMap(),
|
||||
);
|
||||
|
||||
let suggestedBinding: AppState["suggestedBinding"] = null;
|
||||
|
||||
if (startHovered != null && startHovered.id === endHovered?.id) {
|
||||
const hitStart = hitElementItself({
|
||||
element: startHovered,
|
||||
elementsMap: scene.getNonDeletedElementsMap(),
|
||||
point: pointFrom<GlobalPoint>(startCoords[0], startCoords[1]),
|
||||
threshold: 0,
|
||||
overrideShouldTestInside: true,
|
||||
});
|
||||
const hitEnd = hitElementItself({
|
||||
element: endHovered,
|
||||
elementsMap: scene.getNonDeletedElementsMap(),
|
||||
point: pointFrom<GlobalPoint>(endCoords[0], endCoords[1]),
|
||||
threshold: 0,
|
||||
overrideShouldTestInside: true,
|
||||
});
|
||||
if (hitStart && hitEnd) {
|
||||
suggestedBinding = startHovered;
|
||||
}
|
||||
} else if (startOrEndOrBoth === "start" && startHovered != null) {
|
||||
suggestedBinding = startHovered;
|
||||
} else if (startOrEndOrBoth === "end" && endHovered != null) {
|
||||
suggestedBinding = endHovered;
|
||||
}
|
||||
|
||||
return suggestedBinding;
|
||||
};
|
||||
|
||||
export const bindBindingElement = (
|
||||
arrow: NonDeleted<ExcalidrawArrowElement>,
|
||||
hoveredElement: ExcalidrawBindableElement,
|
||||
|
Reference in New Issue
Block a user