fix: Diamonds and ellipses
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
@@ -818,6 +818,11 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
|
|||||||
elementsMap,
|
elementsMap,
|
||||||
appState.gridSize as NullableGridSize,
|
appState.gridSize as NullableGridSize,
|
||||||
arrow,
|
arrow,
|
||||||
|
LinearElementEditor.getPointAtIndexGlobalCoordinates(
|
||||||
|
arrow,
|
||||||
|
startDragged ? 1 : -2,
|
||||||
|
elementsMap,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
: globalPoint,
|
: globalPoint,
|
||||||
hit,
|
hit,
|
||||||
@@ -1768,17 +1773,21 @@ const snapBoundPointToGrid = (
|
|||||||
elementsMap: ElementsMap,
|
elementsMap: ElementsMap,
|
||||||
gridSize: NullableGridSize,
|
gridSize: NullableGridSize,
|
||||||
arrowElement: ExcalidrawArrowElement,
|
arrowElement: ExcalidrawArrowElement,
|
||||||
|
adjacentPoint?: GlobalPoint,
|
||||||
): GlobalPoint => {
|
): GlobalPoint => {
|
||||||
if (!gridSize) {
|
if (!gridSize) {
|
||||||
return outlinePoint;
|
return outlinePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
const aabb = aabbForElement(bindableElement, elementsMap);
|
const aabb = aabbForElement(bindableElement, elementsMap);
|
||||||
const heading = headingForPointFromElement(
|
// For ellipses and diamonds use the arrow's incoming direction instead of
|
||||||
bindableElement,
|
// the position-based heading, which can give the wrong axis when the
|
||||||
aabb,
|
// outline point is near a cardinal zone or an angled diamond face.
|
||||||
outlinePoint,
|
const heading =
|
||||||
);
|
adjacentPoint &&
|
||||||
|
(bindableElement.type === "ellipse" || bindableElement.type === "diamond")
|
||||||
|
? vectorToHeading(vectorFromPoint(adjacentPoint, outlinePoint))
|
||||||
|
: headingForPointFromElement(bindableElement, aabb, outlinePoint);
|
||||||
|
|
||||||
const normalLocal = pointFrom<GlobalPoint>(heading[0], heading[1]);
|
const normalLocal = pointFrom<GlobalPoint>(heading[0], heading[1]);
|
||||||
const normalGlobal = pointRotateRads(
|
const normalGlobal = pointRotateRads(
|
||||||
|
|||||||
Reference in New Issue
Block a user