mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Further adjustments for edge cases
This commit is contained in:
parent
c7c6a4c3f1
commit
9a2bd18904
3 changed files with 40 additions and 31 deletions
|
@ -951,7 +951,6 @@ export const bindPointToSnapToElementOutline = (
|
||||||
otherPoint,
|
otherPoint,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
0.1,
|
|
||||||
)[0];
|
)[0];
|
||||||
} else {
|
} else {
|
||||||
intersection = intersectElementWithLineSegment(
|
intersection = intersectElementWithLineSegment(
|
||||||
|
@ -1116,6 +1115,17 @@ export const avoidRectangularCorner = (
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Break up explicit border bindings to have better elbow arrow routing
|
||||||
|
if (p[0] === element.x) {
|
||||||
|
return pointFrom(p[0] - FIXED_BINDING_DISTANCE, p[1]);
|
||||||
|
} else if (p[0] === element.x + element.width) {
|
||||||
|
return pointFrom(p[0] + FIXED_BINDING_DISTANCE, p[1]);
|
||||||
|
} else if (p[1] === element.y) {
|
||||||
|
return pointFrom(p[0], p[1] - FIXED_BINDING_DISTANCE);
|
||||||
|
} else if (p[1] === element.y + element.height) {
|
||||||
|
return pointFrom(p[0], p[1] + FIXED_BINDING_DISTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,10 @@ const handleSegmentRelease = (
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!restoredPoints) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
const nextPoints: GlobalPoint[] = [];
|
const nextPoints: GlobalPoint[] = [];
|
||||||
|
|
||||||
// First part of the arrow are the old points
|
// First part of the arrow are the old points
|
||||||
|
@ -2181,16 +2185,11 @@ const normalizeArrowElementUpdate = (
|
||||||
nextFixedSegments: readonly FixedSegment[] | null,
|
nextFixedSegments: readonly FixedSegment[] | null,
|
||||||
startIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"],
|
startIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"],
|
||||||
endIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"],
|
endIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"],
|
||||||
): {
|
): ElementUpdate<ExcalidrawElbowArrowElement> => {
|
||||||
points: LocalPoint[];
|
if (global.length === 0) {
|
||||||
x: number;
|
return {};
|
||||||
y: number;
|
}
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
fixedSegments: readonly FixedSegment[] | null;
|
|
||||||
startIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"];
|
|
||||||
endIsSpecial?: ExcalidrawElbowArrowElement["startIsSpecial"];
|
|
||||||
} => {
|
|
||||||
const offsetX = global[0][0];
|
const offsetX = global[0][0];
|
||||||
const offsetY = global[0][1];
|
const offsetY = global[0][1];
|
||||||
let points = global.map((p) =>
|
let points = global.map((p) =>
|
||||||
|
|
|
@ -78,9 +78,9 @@ describe("elbow arrow segment move", () => {
|
||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[109.92, 0],
|
[110, 0],
|
||||||
[109.92, 200],
|
[110, 200],
|
||||||
[189.85, 200],
|
[190, 200],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
mouse.reset();
|
mouse.reset();
|
||||||
|
@ -89,9 +89,9 @@ describe("elbow arrow segment move", () => {
|
||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[109.92, 0],
|
[110, 0],
|
||||||
[109.92, 200],
|
[110, 200],
|
||||||
[189.85, 200],
|
[190, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -201,9 +201,9 @@ describe("elbow arrow routing", () => {
|
||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[44.9292, 0],
|
[45, 0],
|
||||||
[44.9292, 200],
|
[45, 200],
|
||||||
[89.8585, 200],
|
[90, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -255,9 +255,9 @@ describe("elbow arrow ui", () => {
|
||||||
expect(arrow.elbowed).toBe(true);
|
expect(arrow.elbowed).toBe(true);
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[44.92, 0],
|
[45, 0],
|
||||||
[44.92, 200],
|
[45, 200],
|
||||||
[89.85, 200],
|
[90, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -297,9 +297,9 @@ describe("elbow arrow ui", () => {
|
||||||
|
|
||||||
expect(arrow.points).toCloselyEqualPoints([
|
expect(arrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[34.7084, 0],
|
[34.7791, 0],
|
||||||
[34.7084, 164.6246],
|
[34.7791, 164.67],
|
||||||
[104.333, 164.6246],
|
[102.931, 164.67],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -353,9 +353,9 @@ describe("elbow arrow ui", () => {
|
||||||
expect(duplicatedArrow.elbowed).toBe(true);
|
expect(duplicatedArrow.elbowed).toBe(true);
|
||||||
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[44.92, 0],
|
[45, 0],
|
||||||
[44.92, 200],
|
[45, 200],
|
||||||
[89.85, 200],
|
[90, 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);
|
||||||
|
@ -408,8 +408,8 @@ describe("elbow arrow ui", () => {
|
||||||
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
expect(duplicatedArrow.points).toCloselyEqualPoints([
|
||||||
[0, 0],
|
[0, 0],
|
||||||
[0, 100],
|
[0, 100],
|
||||||
[89.85, 100],
|
[90, 100],
|
||||||
[89.85, 200],
|
[90, 200],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue