Fine tuning
This commit is contained in:
parent
a8338cdb5a
commit
eaa869620e
@ -117,8 +117,8 @@ const calculatePadding = (
|
|||||||
const width = aabb[2] - aabb[0];
|
const width = aabb[2] - aabb[0];
|
||||||
const height = aabb[3] - aabb[1];
|
const height = aabb[3] - aabb[1];
|
||||||
const size = Math.max(width, height);
|
const size = Math.max(width, height);
|
||||||
|
// || compareHeading(startHeading, flipHeading(endHeading))
|
||||||
return compareHeading(startHeading, flipHeading(endHeading)) || size > 50
|
return size > 55
|
||||||
? 40
|
? 40
|
||||||
: Math.min(
|
: Math.min(
|
||||||
Math.max(
|
Math.max(
|
||||||
|
@ -77,9 +77,9 @@ describe("elbow arrow segment move", () => {
|
|||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[110, 0],
|
[109.92, 0],
|
||||||
[110, 200],
|
[109.92, 200],
|
||||||
[190, 200],
|
[189.85, 200],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
mouse.reset();
|
mouse.reset();
|
||||||
@ -88,9 +88,9 @@ describe("elbow arrow segment move", () => {
|
|||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[110, 0],
|
[109.92, 0],
|
||||||
[110, 200],
|
[109.92, 200],
|
||||||
[190, 200],
|
[189.85, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -198,11 +198,11 @@ describe("elbow arrow routing", () => {
|
|||||||
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(90, 200)],
|
points: [pointFrom<LocalPoint>(0, 0), pointFrom<LocalPoint>(90, 200)],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(arrow.points).toEqual([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[45, 0],
|
[44.92, 0],
|
||||||
[45, 200],
|
[44.92, 200],
|
||||||
[90, 200],
|
[89.85, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -252,11 +252,11 @@ describe("elbow arrow ui", () => {
|
|||||||
|
|
||||||
expect(arrow.type).toBe("arrow");
|
expect(arrow.type).toBe("arrow");
|
||||||
expect(arrow.elbowed).toBe(true);
|
expect(arrow.elbowed).toBe(true);
|
||||||
expect(arrow.points).toEqual([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[45, 0],
|
[44.92, 0],
|
||||||
[45, 200],
|
[44.92, 200],
|
||||||
[90, 200],
|
[89.85, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -296,9 +296,9 @@ describe("elbow arrow ui", () => {
|
|||||||
|
|
||||||
expect(arrow.points.map((point) => point.map(Math.round))).toEqual([
|
expect(arrow.points.map((point) => point.map(Math.round))).toEqual([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[35, 0],
|
[34, 0],
|
||||||
[35, 165],
|
[34, 165],
|
||||||
[103, 165],
|
[104, 165],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -350,11 +350,11 @@ describe("elbow arrow ui", () => {
|
|||||||
expect(duplicatedArrow.id).not.toBe(originalArrowId);
|
expect(duplicatedArrow.id).not.toBe(originalArrowId);
|
||||||
expect(duplicatedArrow.type).toBe("arrow");
|
expect(duplicatedArrow.type).toBe("arrow");
|
||||||
expect(duplicatedArrow.elbowed).toBe(true);
|
expect(duplicatedArrow.elbowed).toBe(true);
|
||||||
expect(duplicatedArrow.points).toEqual([
|
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[45, 0],
|
[44.92, 0],
|
||||||
[45, 200],
|
[44.92, 200],
|
||||||
[90, 200],
|
[89.85, 200],
|
||||||
]);
|
]);
|
||||||
expect(arrow.startBinding).not.toBe(null);
|
expect(arrow.startBinding).not.toBe(null);
|
||||||
expect(arrow.endBinding).not.toBe(null);
|
expect(arrow.endBinding).not.toBe(null);
|
||||||
@ -404,11 +404,11 @@ describe("elbow arrow ui", () => {
|
|||||||
expect(duplicatedArrow.id).not.toBe(originalArrowId);
|
expect(duplicatedArrow.id).not.toBe(originalArrowId);
|
||||||
expect(duplicatedArrow.type).toBe("arrow");
|
expect(duplicatedArrow.type).toBe("arrow");
|
||||||
expect(duplicatedArrow.elbowed).toBe(true);
|
expect(duplicatedArrow.elbowed).toBe(true);
|
||||||
expect(duplicatedArrow.points).toEqual([
|
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[0, 100],
|
[0, 100],
|
||||||
[90, 100],
|
[89.85, 100],
|
||||||
[90, 200],
|
[89.85, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -510,12 +510,12 @@ describe("arrow element", () => {
|
|||||||
h.state,
|
h.state,
|
||||||
)[0] as ExcalidrawElbowArrowElement;
|
)[0] as ExcalidrawElbowArrowElement;
|
||||||
|
|
||||||
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
|
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
|
||||||
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
||||||
|
|
||||||
UI.resize(rectangle, "se", [-200, -150]);
|
UI.resize(rectangle, "se", [-200, -150]);
|
||||||
|
|
||||||
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
|
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
|
||||||
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -538,11 +538,11 @@ describe("arrow element", () => {
|
|||||||
h.state,
|
h.state,
|
||||||
)[0] as ExcalidrawElbowArrowElement;
|
)[0] as ExcalidrawElbowArrowElement;
|
||||||
|
|
||||||
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1);
|
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(1.05);
|
||||||
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.75);
|
||||||
|
|
||||||
UI.resize([rectangle, arrow], "nw", [300, 350]);
|
UI.resize([rectangle, arrow], "nw", [300, 350]);
|
||||||
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(0);
|
expect(arrow.startBinding?.fixedPoint?.[0]).toBeCloseTo(-0.05);
|
||||||
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25);
|
expect(arrow.startBinding?.fixedPoint?.[1]).toBeCloseTo(0.25);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user