mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Restore elbow point snapping
This commit is contained in:
parent
cfaabf546e
commit
3428148e4d
1 changed files with 11 additions and 3 deletions
|
@ -44,6 +44,7 @@ import { intersectElementWithLineSegment } from "./collision";
|
||||||
import { distanceToBindableElement } from "./distance";
|
import { distanceToBindableElement } from "./distance";
|
||||||
import {
|
import {
|
||||||
headingForPointFromElement,
|
headingForPointFromElement,
|
||||||
|
headingIsHorizontal,
|
||||||
vectorToHeading,
|
vectorToHeading,
|
||||||
type Heading,
|
type Heading,
|
||||||
} from "./heading";
|
} from "./heading";
|
||||||
|
@ -922,16 +923,23 @@ export const bindPointToSnapToElementOutline = (
|
||||||
|
|
||||||
let intersection: GlobalPoint | null = null;
|
let intersection: GlobalPoint | null = null;
|
||||||
if (elbowed) {
|
if (elbowed) {
|
||||||
|
const isHorizontal = headingIsHorizontal(
|
||||||
|
headingForPointFromElement(bindableElement, aabb, globalP),
|
||||||
|
);
|
||||||
|
const otherPoint = pointFrom<GlobalPoint>(
|
||||||
|
isHorizontal ? center[0] : edgePoint[0],
|
||||||
|
!isHorizontal ? center[1] : edgePoint[1],
|
||||||
|
);
|
||||||
intersection = intersectElementWithLineSegment(
|
intersection = intersectElementWithLineSegment(
|
||||||
bindableElement,
|
bindableElement,
|
||||||
lineSegment(
|
lineSegment(
|
||||||
center,
|
otherPoint,
|
||||||
pointFromVector(
|
pointFromVector(
|
||||||
vectorScale(
|
vectorScale(
|
||||||
vectorNormalize(vectorFromPoint(edgePoint, center)),
|
vectorNormalize(vectorFromPoint(edgePoint, otherPoint)),
|
||||||
Math.max(bindableElement.width, bindableElement.height) * 2,
|
Math.max(bindableElement.width, bindableElement.height) * 2,
|
||||||
),
|
),
|
||||||
center,
|
otherPoint,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)[0];
|
)[0];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue