fix: Center when orbiting

This commit is contained in:
Mark Tolmacs
2025-08-21 21:46:19 +02:00
parent c7e43cfc79
commit 2434d5b351
2 changed files with 10 additions and 15 deletions

View File

@@ -415,7 +415,9 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
end = {
mode: isInsideBinding ? "inside" : "orbit",
element: hit,
focusPoint: point,
focusPoint: isInsideBinding
? point
: snapToCenter(hit, elementsMap, point),
};
} else {
end = { mode: null };
@@ -437,7 +439,6 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
globalBindMode?: AppState["bindMode"],
opts?: {
newArrow?: boolean;
appState?: AppState;
},
): { current: BindingStrategy; other: BindingStrategy } => {
@@ -493,12 +494,7 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
current = {
element: hit,
mode: "orbit",
focusPoint: opts?.newArrow
? pointFrom<GlobalPoint>(
hit.x + hit.width / 2,
hit.y + hit.height / 2,
)
: point,
focusPoint: snapToCenter(hit, elementsMap, point),
};
return { current, other };
@@ -509,9 +505,7 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
current = {
element: hit,
mode: "orbit",
focusPoint: opts?.newArrow
? pointFrom<GlobalPoint>(hit.x + hit.width / 2, hit.y + hit.height / 2)
: point,
focusPoint: snapToCenter(hit, elementsMap, point),
};
}
@@ -624,7 +618,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
elementsMap,
elements,
globalBindMode,
opts,
{ appState },
);
return { start: current, end: other };
@@ -645,7 +639,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
elementsMap,
elements,
globalBindMode,
opts,
{ appState },
);
return { start: other, end: current };

View File

@@ -49,6 +49,7 @@ import {
getOutlineAvoidingPoint,
isBindingEnabled,
maybeSuggestBindingsForBindingElementAtCoords,
snapToCenter,
} from "./binding";
import {
getElementAbsoluteCoords,
@@ -2037,7 +2038,7 @@ const pointDraggingUpdates = (
newGlobalPointPosition = getOutlineAvoidingPoint(
element,
hoveredElement,
newGlobalPointPosition,
snapToCenter(hoveredElement, elementsMap, newGlobalPointPosition),
pointIndex,
elementsMap,
customIntersector,
@@ -2127,7 +2128,7 @@ const pointDraggingUpdates = (
const newGlobalPointPosition = getOutlineAvoidingPoint(
element,
hoveredElement,
focusGlobalPoint,
snapToCenter(hoveredElement, elementsMap, focusGlobalPoint),
pointIndex,
elementsMap,
);