mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Restore accidentally reverted changes
This commit is contained in:
parent
f23a26b5b2
commit
224a69aa10
1 changed files with 48 additions and 37 deletions
|
@ -487,20 +487,8 @@ export const bindLinearElement = (
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const binding: PointBinding | FixedPointBinding = {
|
let binding: PointBinding | FixedPointBinding = {
|
||||||
elementId: hoveredElement.id,
|
elementId: hoveredElement.id,
|
||||||
...(isElbowArrow(linearElement)
|
|
||||||
? {
|
|
||||||
...calculateFixedPointForElbowArrowBinding(
|
|
||||||
linearElement,
|
|
||||||
hoveredElement,
|
|
||||||
startOrEnd,
|
|
||||||
elementsMap,
|
|
||||||
),
|
|
||||||
focus: 0,
|
|
||||||
gap: 0,
|
|
||||||
}
|
|
||||||
: {
|
|
||||||
...normalizePointBinding(
|
...normalizePointBinding(
|
||||||
calculateFocusAndGap(
|
calculateFocusAndGap(
|
||||||
linearElement,
|
linearElement,
|
||||||
|
@ -510,9 +498,20 @@ export const bindLinearElement = (
|
||||||
),
|
),
|
||||||
hoveredElement,
|
hoveredElement,
|
||||||
),
|
),
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (isElbowArrow(linearElement)) {
|
||||||
|
binding = {
|
||||||
|
...binding,
|
||||||
|
...calculateFixedPointForElbowArrowBinding(
|
||||||
|
linearElement,
|
||||||
|
hoveredElement,
|
||||||
|
startOrEnd,
|
||||||
|
elementsMap,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
mutateElement(linearElement, {
|
mutateElement(linearElement, {
|
||||||
[startOrEnd === "start" ? "startBinding" : "endBinding"]: binding,
|
[startOrEnd === "start" ? "startBinding" : "endBinding"]: binding,
|
||||||
});
|
});
|
||||||
|
@ -1303,13 +1302,16 @@ const updateBoundPoint = (
|
||||||
pointDistance(adjacentPoint, edgePointAbsolute) +
|
pointDistance(adjacentPoint, edgePointAbsolute) +
|
||||||
pointDistance(adjacentPoint, center) +
|
pointDistance(adjacentPoint, center) +
|
||||||
Math.max(bindableElement.width, bindableElement.height) * 2;
|
Math.max(bindableElement.width, bindableElement.height) * 2;
|
||||||
const intersections = intersectElementWithLineSegment(
|
const intersections = [
|
||||||
|
...intersectElementWithLineSegment(
|
||||||
bindableElement,
|
bindableElement,
|
||||||
lineSegment<GlobalPoint>(
|
lineSegment<GlobalPoint>(
|
||||||
adjacentPoint,
|
adjacentPoint,
|
||||||
pointFromVector(
|
pointFromVector(
|
||||||
vectorScale(
|
vectorScale(
|
||||||
vectorNormalize(vectorFromPoint(focusPointAbsolute, adjacentPoint)),
|
vectorNormalize(
|
||||||
|
vectorFromPoint(focusPointAbsolute, adjacentPoint),
|
||||||
|
),
|
||||||
interceptorLength,
|
interceptorLength,
|
||||||
),
|
),
|
||||||
adjacentPoint,
|
adjacentPoint,
|
||||||
|
@ -1319,7 +1321,16 @@ const updateBoundPoint = (
|
||||||
).sort(
|
).sort(
|
||||||
(g, h) =>
|
(g, h) =>
|
||||||
pointDistanceSq(g, adjacentPoint) - pointDistanceSq(h, adjacentPoint),
|
pointDistanceSq(g, adjacentPoint) - pointDistanceSq(h, adjacentPoint),
|
||||||
);
|
),
|
||||||
|
// Fallback when arrow doesn't point to the shape
|
||||||
|
pointFromVector(
|
||||||
|
vectorScale(
|
||||||
|
vectorNormalize(vectorFromPoint(focusPointAbsolute, adjacentPoint)),
|
||||||
|
pointDistance(adjacentPoint, edgePointAbsolute),
|
||||||
|
),
|
||||||
|
adjacentPoint,
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
if (intersections.length > 1) {
|
if (intersections.length > 1) {
|
||||||
// The adjacent point is outside the shape (+ gap)
|
// The adjacent point is outside the shape (+ gap)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue