mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
DEBUG
This commit is contained in:
parent
541725ff5a
commit
82cef23c3d
1 changed files with 34 additions and 19 deletions
|
@ -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,17 +118,20 @@ const calculatePadding = (
|
||||||
startBoundingBox: Bounds,
|
startBoundingBox: Bounds,
|
||||||
endBoundingBox: Bounds,
|
endBoundingBox: Bounds,
|
||||||
) => {
|
) => {
|
||||||
return Math.min(
|
return Math.max(
|
||||||
Math.hypot(
|
Math.min(
|
||||||
startBoundingBox[2] - startBoundingBox[0],
|
Math.hypot(
|
||||||
startBoundingBox[3] - startBoundingBox[1],
|
startBoundingBox[2] - startBoundingBox[0],
|
||||||
) / 4,
|
startBoundingBox[3] - startBoundingBox[1],
|
||||||
Math.hypot(
|
) / 4,
|
||||||
endBoundingBox[2] - endBoundingBox[0],
|
Math.hypot(
|
||||||
endBoundingBox[3] - endBoundingBox[1],
|
endBoundingBox[2] - endBoundingBox[0],
|
||||||
) / 4,
|
endBoundingBox[3] - endBoundingBox[1],
|
||||||
Math.hypot(aabb[2] - aabb[0], aabb[3] - aabb[1]) / 4,
|
) / 4,
|
||||||
40,
|
Math.hypot(aabb[2] - aabb[0], aabb[3] - aabb[1]) / 4,
|
||||||
|
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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue