feat: Alt does not snap

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs
2025-11-06 15:34:16 +01:00
parent 87d89aa090
commit dd70f4e00f
4 changed files with 21 additions and 10 deletions

View File

@@ -149,7 +149,8 @@ export const bindOrUnbindBindingElement = (
scene: Scene,
appState: AppState,
opts?: {
newArrow: boolean;
newArrow?: boolean;
altKey?: boolean;
},
) => {
const { start, end } = getBindingStrategyForDraggingBindingElementEndpoints(
@@ -554,6 +555,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
opts?: {
newArrow?: boolean;
shiftKey?: boolean;
altKey?: boolean;
finalize?: boolean;
},
): { start: BindingStrategy; end: BindingStrategy } => {
@@ -587,6 +589,7 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
opts?: {
newArrow?: boolean;
shiftKey?: boolean;
altKey?: boolean;
finalize?: boolean;
},
): { start: BindingStrategy; end: BindingStrategy } => {
@@ -687,14 +690,15 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
: {
mode: "orbit",
element: hit,
focusPoint:
projectFixedPointOntoDiagonal(
arrow,
globalPoint,
hit,
startDragged ? "start" : "end",
elementsMap,
) || globalPoint,
focusPoint: opts?.altKey
? globalPoint
: projectFixedPointOntoDiagonal(
arrow,
globalPoint,
hit,
startDragged ? "start" : "end",
elementsMap,
) || globalPoint,
}
: { mode: null };
const otherBindableElement = otherBinding
@@ -707,7 +711,9 @@ const getBindingStrategyForDraggingBindingElementEndpoints_simple = (
startDragged ? -1 : 0,
elementsMap,
);
const other: BindingStrategy =
!opts?.altKey &&
opts?.newArrow &&
otherBindableElement &&
!isPointInElement(otherPoint, otherBindableElement, elementsMap)

View File

@@ -356,6 +356,7 @@ export class LinearElementEditor {
elements,
app,
event.shiftKey,
event.altKey,
);
LinearElementEditor.movePoints(element, app.scene, positions, {
@@ -520,6 +521,7 @@ export class LinearElementEditor {
elements,
app,
event.shiftKey,
event.altKey,
);
LinearElementEditor.movePoints(element, app.scene, positions, {
@@ -2058,6 +2060,7 @@ const pointDraggingUpdates = (
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
app: AppClassProperties,
shiftKey: boolean,
altKey: boolean,
): {
positions: PointsPositionUpdates;
updates?: PointMoveOtherUpdates;
@@ -2104,6 +2107,7 @@ const pointDraggingUpdates = (
{
newArrow: !!app.state.newElement,
shiftKey,
altKey,
},
);

View File

@@ -104,6 +104,7 @@ export const actionFinalize = register<FormData>({
bindOrUnbindBindingElement(element, draggedPoints, scene, appState, {
newArrow,
altKey: event.altKey,
});
} else if (isLineElement(element)) {
if (

View File

@@ -8616,7 +8616,7 @@ class App extends React.Component<AppProps, AppState> {
]),
this.scene,
this.state,
{ newArrow: true },
{ newArrow: true, altKey: event.altKey },
);
}