|
|
|
@ -29,7 +29,12 @@ import type {
|
|
|
|
|
} from "./types";
|
|
|
|
|
|
|
|
|
|
import type { Bounds } from "./bounds";
|
|
|
|
|
import { getCenterForBounds, getElementAbsoluteCoords } from "./bounds";
|
|
|
|
|
import {
|
|
|
|
|
getCenterForBounds,
|
|
|
|
|
getElementAbsoluteCoords,
|
|
|
|
|
getElementBounds,
|
|
|
|
|
doBoundsIntersect,
|
|
|
|
|
} from "./bounds";
|
|
|
|
|
import type { AppState } from "../types";
|
|
|
|
|
import { isPointOnShape } from "../../utils/collision";
|
|
|
|
|
import { getElementAtPosition } from "../scene";
|
|
|
|
@ -599,6 +604,21 @@ export const updateBoundElements = (
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for intersections before updating bound elements incase connected elements overlap
|
|
|
|
|
const startBindingElement = element.startBinding
|
|
|
|
|
? elementsMap.get(element.startBinding.elementId)
|
|
|
|
|
: null;
|
|
|
|
|
const endBindingElement = element.endBinding
|
|
|
|
|
? elementsMap.get(element.endBinding.elementId)
|
|
|
|
|
: null;
|
|
|
|
|
|
|
|
|
|
let startBounds: Bounds | null = null;
|
|
|
|
|
let endBounds: Bounds | null = null;
|
|
|
|
|
if (startBindingElement && endBindingElement) {
|
|
|
|
|
startBounds = getElementBounds(startBindingElement, elementsMap);
|
|
|
|
|
endBounds = getElementBounds(endBindingElement, elementsMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bindings = {
|
|
|
|
|
startBinding: maybeCalculateNewGapWhenScaling(
|
|
|
|
|
changedElement,
|
|
|
|
@ -627,10 +647,11 @@ export const updateBoundElements = (
|
|
|
|
|
isBindableElement(bindableElement) &&
|
|
|
|
|
(bindingProp === "startBinding" || bindingProp === "endBinding") &&
|
|
|
|
|
(changedElement.id === element[bindingProp]?.elementId ||
|
|
|
|
|
changedElement.id ===
|
|
|
|
|
(changedElement.id ===
|
|
|
|
|
element[
|
|
|
|
|
bindingProp === "startBinding" ? "endBinding" : "startBinding"
|
|
|
|
|
]?.elementId)
|
|
|
|
|
]?.elementId &&
|
|
|
|
|
!doBoundsIntersect(startBounds, endBounds)))
|
|
|
|
|
) {
|
|
|
|
|
const point = updateBoundPoint(
|
|
|
|
|
element,
|
|
|
|
|