@@ -172,12 +172,16 @@ export const bindOrUnbindBindingElement = (
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isMidpointSnappingEnabled =
|
||||||
|
appState.isMidpointSnappingEnabled && !appState.gridModeEnabled;
|
||||||
|
|
||||||
bindOrUnbindBindingElementEdge(
|
bindOrUnbindBindingElementEdge(
|
||||||
arrow,
|
arrow,
|
||||||
start,
|
start,
|
||||||
"start",
|
"start",
|
||||||
scene,
|
scene,
|
||||||
appState.isBindingEnabled,
|
appState.isBindingEnabled,
|
||||||
|
isMidpointSnappingEnabled,
|
||||||
);
|
);
|
||||||
bindOrUnbindBindingElementEdge(
|
bindOrUnbindBindingElementEdge(
|
||||||
arrow,
|
arrow,
|
||||||
@@ -185,6 +189,7 @@ export const bindOrUnbindBindingElement = (
|
|||||||
"end",
|
"end",
|
||||||
scene,
|
scene,
|
||||||
appState.isBindingEnabled,
|
appState.isBindingEnabled,
|
||||||
|
isMidpointSnappingEnabled,
|
||||||
);
|
);
|
||||||
if (start.focusPoint || end.focusPoint) {
|
if (start.focusPoint || end.focusPoint) {
|
||||||
// If the strategy dictates a focus point override, then
|
// If the strategy dictates a focus point override, then
|
||||||
@@ -229,6 +234,7 @@ const bindOrUnbindBindingElementEdge = (
|
|||||||
startOrEnd: "start" | "end",
|
startOrEnd: "start" | "end",
|
||||||
scene: Scene,
|
scene: Scene,
|
||||||
shouldSnapToOutline = true,
|
shouldSnapToOutline = true,
|
||||||
|
isMidpointSnappingEnabled = true,
|
||||||
): void => {
|
): void => {
|
||||||
if (mode === null) {
|
if (mode === null) {
|
||||||
// null means break the binding
|
// null means break the binding
|
||||||
@@ -242,6 +248,7 @@ const bindOrUnbindBindingElementEdge = (
|
|||||||
scene,
|
scene,
|
||||||
focusPoint,
|
focusPoint,
|
||||||
shouldSnapToOutline,
|
shouldSnapToOutline,
|
||||||
|
isMidpointSnappingEnabled,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1047,6 +1054,7 @@ export const bindBindingElement = (
|
|||||||
scene: Scene,
|
scene: Scene,
|
||||||
focusPoint?: GlobalPoint,
|
focusPoint?: GlobalPoint,
|
||||||
shouldSnapToOutline = true,
|
shouldSnapToOutline = true,
|
||||||
|
isMidpointSnappingEnabled = true,
|
||||||
): void => {
|
): void => {
|
||||||
const elementsMap = scene.getNonDeletedElementsMap();
|
const elementsMap = scene.getNonDeletedElementsMap();
|
||||||
|
|
||||||
@@ -1062,6 +1070,7 @@ export const bindBindingElement = (
|
|||||||
startOrEnd,
|
startOrEnd,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
shouldSnapToOutline,
|
shouldSnapToOutline,
|
||||||
|
isMidpointSnappingEnabled,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -1810,7 +1819,7 @@ const snapBoundPointToGrid = (
|
|||||||
const absNX = Math.abs(normalGlobal[0]);
|
const absNX = Math.abs(normalGlobal[0]);
|
||||||
const absNY = Math.abs(normalGlobal[1]);
|
const absNY = Math.abs(normalGlobal[1]);
|
||||||
if (absNX >= absNY) {
|
if (absNX >= absNY) {
|
||||||
// Global X is closest to the perpendicular → snap Y, intersect horizontal line
|
// Global X is closest to the perpendicular so snap Y, intersect horizontal line
|
||||||
const [, snappedY] = getGridPoint(
|
const [, snappedY] = getGridPoint(
|
||||||
outlinePoint[0],
|
outlinePoint[0],
|
||||||
outlinePoint[1],
|
outlinePoint[1],
|
||||||
@@ -1833,7 +1842,7 @@ const snapBoundPointToGrid = (
|
|||||||
return intersection ?? pointFrom<GlobalPoint>(outlinePoint[0], snappedY);
|
return intersection ?? pointFrom<GlobalPoint>(outlinePoint[0], snappedY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global Y is closest to the perpendicular → snap X, intersect vertical line
|
// Global Y is closest to the perpendicular so snap X, intersect vertical line
|
||||||
const [snappedX] = getGridPoint(outlinePoint[0], outlinePoint[1], gridSize);
|
const [snappedX] = getGridPoint(outlinePoint[0], outlinePoint[1], gridSize);
|
||||||
const intersector = lineSegment<GlobalPoint>(
|
const intersector = lineSegment<GlobalPoint>(
|
||||||
pointFrom<GlobalPoint>(snappedX, center[1] - extent),
|
pointFrom<GlobalPoint>(snappedX, center[1] - extent),
|
||||||
|
|||||||
Reference in New Issue
Block a user