This commit is contained in:
dwelle 2025-04-30 10:39:54 +02:00
parent 541725ff5a
commit 82cef23c3d

View file

@ -65,6 +65,8 @@ import type {
NonDeletedExcalidrawElement, NonDeletedExcalidrawElement,
} from "./types"; } from "./types";
import { debugDrawBounds } from "@excalidraw/utils/visualdebug";
type GridAddress = [number, number] & { _brand: "gridaddress" }; type GridAddress = [number, number] & { _brand: "gridaddress" };
type Node = { type Node = {
@ -116,7 +118,8 @@ const calculatePadding = (
startBoundingBox: Bounds, startBoundingBox: Bounds,
endBoundingBox: Bounds, endBoundingBox: Bounds,
) => { ) => {
return Math.min( return Math.max(
Math.min(
Math.hypot( Math.hypot(
startBoundingBox[2] - startBoundingBox[0], startBoundingBox[2] - startBoundingBox[0],
startBoundingBox[3] - startBoundingBox[1], startBoundingBox[3] - startBoundingBox[1],
@ -127,6 +130,8 @@ const calculatePadding = (
) / 4, ) / 4,
Math.hypot(aabb[2] - aabb[0], aabb[3] - aabb[1]) / 4, Math.hypot(aabb[2] - aabb[0], aabb[3] - aabb[1]) / 4,
40, 40,
),
30,
); );
}; };
@ -1347,16 +1352,12 @@ const getElbowArrowData = (
); );
const startOffsets = offsetFromHeading( const startOffsets = offsetFromHeading(
startHeading, startHeading,
arrow.startArrowhead arrow.startArrowhead ? FIXED_BINDING_DISTANCE * 4 : FIXED_BINDING_DISTANCE,
? FIXED_BINDING_DISTANCE * 4
: FIXED_BINDING_DISTANCE * 2,
1, 1,
); );
const endOffsets = offsetFromHeading( const endOffsets = offsetFromHeading(
endHeading, endHeading,
arrow.endArrowhead arrow.endArrowhead ? FIXED_BINDING_DISTANCE * 4 : FIXED_BINDING_DISTANCE,
? FIXED_BINDING_DISTANCE * 4
: FIXED_BINDING_DISTANCE * 2,
1, 1,
); );
const startElementBounds = hoveredStartElement const startElementBounds = hoveredStartElement
@ -1406,7 +1407,7 @@ const getElbowArrowData = (
: BASE_PADDING - : BASE_PADDING -
(arrow.startArrowhead (arrow.startArrowhead
? FIXED_BINDING_DISTANCE * 6 ? FIXED_BINDING_DISTANCE * 6
: FIXED_BINDING_DISTANCE * 2), : FIXED_BINDING_DISTANCE),
BASE_PADDING, BASE_PADDING,
), ),
boundsOverlap boundsOverlap
@ -1422,7 +1423,7 @@ const getElbowArrowData = (
: BASE_PADDING - : BASE_PADDING -
(arrow.endArrowhead (arrow.endArrowhead
? FIXED_BINDING_DISTANCE * 6 ? FIXED_BINDING_DISTANCE * 6
: FIXED_BINDING_DISTANCE * 2), : FIXED_BINDING_DISTANCE),
BASE_PADDING, BASE_PADDING,
), ),
boundsOverlap, boundsOverlap,
@ -1431,6 +1432,20 @@ const getElbowArrowData = (
: startPointBounds, : startPointBounds,
hoveredEndElement ? aabbForElement(hoveredEndElement) : endPointBounds, hoveredEndElement ? aabbForElement(hoveredEndElement) : endPointBounds,
); );
debugDrawBounds(startElementBounds, {
permanent: false,
color: "red",
});
debugDrawBounds(endElementBounds, {
permanent: false,
color: "green",
});
debugDrawBounds(dynamicAABBs, {
permanent: false,
color: "blue",
});
const startDonglePosition = getDonglePosition( const startDonglePosition = getDonglePosition(
dynamicAABBs[0], dynamicAABBs[0],
startHeading, startHeading,