diff --git a/packages/element/src/binding.ts b/packages/element/src/binding.ts index 32bbd4f1d..91a5f00e2 100644 --- a/packages/element/src/binding.ts +++ b/packages/element/src/binding.ts @@ -213,43 +213,29 @@ const bindOrUnbindLinearElementEdge = ( } }; -const getOriginalBindingIfStillCloseOfLinearElementEdge = ( - linearElement: NonDeleted, - edge: "start" | "end", - elementsMap: NonDeletedSceneElementsMap, - zoom?: AppState["zoom"], -): NonDeleted | null => { - const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap); - const elementId = - edge === "start" - ? linearElement.startBinding?.elementId - : linearElement.endBinding?.elementId; - if (elementId) { - const element = elementsMap.get(elementId); - if ( - isBindableElement(element) && - bindingBorderTest(element, coors, elementsMap, zoom) - ) { - return element; - } - } - - return null; -}; - const getOriginalBindingsIfStillCloseToArrowEnds = ( linearElement: NonDeleted, elementsMap: NonDeletedSceneElementsMap, zoom?: AppState["zoom"], ): (NonDeleted | null)[] => - ["start", "end"].map((edge) => - getOriginalBindingIfStillCloseOfLinearElementEdge( - linearElement, - edge as "start" | "end", - elementsMap, - zoom, - ), - ); + (["start", "end"] as const).map((edge) => { + const coors = getLinearElementEdgeCoors(linearElement, edge, elementsMap); + const elementId = + edge === "start" + ? linearElement.startBinding?.elementId + : linearElement.endBinding?.elementId; + if (elementId) { + const element = elementsMap.get(elementId); + if ( + isBindableElement(element) && + bindingBorderTest(element, coors, elementsMap, zoom) + ) { + return element; + } + } + + return null; + }); const getBindingStrategyForDraggingArrowEndpoints = ( selectedElement: NonDeleted, @@ -265,7 +251,7 @@ const getBindingStrategyForDraggingArrowEndpoints = ( const endDragged = draggingPoints.findIndex((i) => i === endIdx) > -1; const start = startDragged ? isBindingEnabled - ? getElligibleElementForBindingElement( + ? getEligibleElementForBindingElement( selectedElement, "start", elementsMap, @@ -276,7 +262,7 @@ const getBindingStrategyForDraggingArrowEndpoints = ( : "keep"; const end = endDragged ? isBindingEnabled - ? getElligibleElementForBindingElement( + ? getEligibleElementForBindingElement( selectedElement, "end", elementsMap, @@ -308,7 +294,7 @@ const getBindingStrategyForDraggingArrowOrJoints = ( ); const start = startIsClose ? isBindingEnabled - ? getElligibleElementForBindingElement( + ? getEligibleElementForBindingElement( selectedElement, "start", elementsMap, @@ -319,7 +305,7 @@ const getBindingStrategyForDraggingArrowOrJoints = ( : null; const end = endIsClose ? isBindingEnabled - ? getElligibleElementForBindingElement( + ? getEligibleElementForBindingElement( selectedElement, "end", elementsMap, @@ -1369,7 +1355,7 @@ const maybeCalculateNewGapWhenScaling = ( return { ...currentBinding, gap: newGap }; }; -const getElligibleElementForBindingElement = ( +const getEligibleElementForBindingElement = ( linearElement: NonDeleted, startOrEnd: "start" | "end", elementsMap: NonDeletedSceneElementsMap, diff --git a/packages/element/src/elbowArrow.ts b/packages/element/src/elbowArrow.ts index e267a71a3..17d4e7631 100644 --- a/packages/element/src/elbowArrow.ts +++ b/packages/element/src/elbowArrow.ts @@ -897,37 +897,6 @@ export const updateElbowArrowPoints = ( return { points: updates.points ?? arrow.points }; } - // NOTE (mtolmacs): This is a temporary check to ensure that the incoming elbow - // arrow size is valid. This check will be removed once the issue is identified - if ( - arrow.x < -MAX_POS || - arrow.x > MAX_POS || - arrow.y < -MAX_POS || - arrow.y > MAX_POS || - arrow.x + (updates?.points?.[updates?.points?.length - 1]?.[0] ?? 0) < - -MAX_POS || - arrow.x + (updates?.points?.[updates?.points?.length - 1]?.[0] ?? 0) > - MAX_POS || - arrow.y + (updates?.points?.[updates?.points?.length - 1]?.[1] ?? 0) < - -MAX_POS || - arrow.y + (updates?.points?.[updates?.points?.length - 1]?.[1] ?? 0) > - MAX_POS || - arrow.x + (arrow?.points?.[arrow?.points?.length - 1]?.[0] ?? 0) < - -MAX_POS || - arrow.x + (arrow?.points?.[arrow?.points?.length - 1]?.[0] ?? 0) > - MAX_POS || - arrow.y + (arrow?.points?.[arrow?.points?.length - 1]?.[1] ?? 0) < - -MAX_POS || - arrow.y + (arrow?.points?.[arrow?.points?.length - 1]?.[1] ?? 0) > MAX_POS - ) { - console.error( - "Elbow arrow (or update) is outside reasonable bounds (> 1e6)", - { - arrow, - updates, - }, - ); - } // @ts-ignore See above note arrow.x = clamp(arrow.x, -MAX_POS, MAX_POS); // @ts-ignore See above note