mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-15 21:40:06 +02:00
fix: Center when orbiting
This commit is contained in:
@@ -415,7 +415,9 @@ const bindingStrategyForNewSimpleArrowEndpointDragging = (
|
|||||||
end = {
|
end = {
|
||||||
mode: isInsideBinding ? "inside" : "orbit",
|
mode: isInsideBinding ? "inside" : "orbit",
|
||||||
element: hit,
|
element: hit,
|
||||||
focusPoint: point,
|
focusPoint: isInsideBinding
|
||||||
|
? point
|
||||||
|
: snapToCenter(hit, elementsMap, point),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
end = { mode: null };
|
end = { mode: null };
|
||||||
@@ -437,7 +439,6 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
|
|||||||
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
|
elements: readonly Ordered<NonDeletedExcalidrawElement>[],
|
||||||
globalBindMode?: AppState["bindMode"],
|
globalBindMode?: AppState["bindMode"],
|
||||||
opts?: {
|
opts?: {
|
||||||
newArrow?: boolean;
|
|
||||||
appState?: AppState;
|
appState?: AppState;
|
||||||
},
|
},
|
||||||
): { current: BindingStrategy; other: BindingStrategy } => {
|
): { current: BindingStrategy; other: BindingStrategy } => {
|
||||||
@@ -493,12 +494,7 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
|
|||||||
current = {
|
current = {
|
||||||
element: hit,
|
element: hit,
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
focusPoint: opts?.newArrow
|
focusPoint: snapToCenter(hit, elementsMap, point),
|
||||||
? pointFrom<GlobalPoint>(
|
|
||||||
hit.x + hit.width / 2,
|
|
||||||
hit.y + hit.height / 2,
|
|
||||||
)
|
|
||||||
: point,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return { current, other };
|
return { current, other };
|
||||||
@@ -509,9 +505,7 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
|
|||||||
current = {
|
current = {
|
||||||
element: hit,
|
element: hit,
|
||||||
mode: "orbit",
|
mode: "orbit",
|
||||||
focusPoint: opts?.newArrow
|
focusPoint: snapToCenter(hit, elementsMap, point),
|
||||||
? pointFrom<GlobalPoint>(hit.x + hit.width / 2, hit.y + hit.height / 2)
|
|
||||||
: point,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +618,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
elementsMap,
|
elementsMap,
|
||||||
elements,
|
elements,
|
||||||
globalBindMode,
|
globalBindMode,
|
||||||
opts,
|
{ appState },
|
||||||
);
|
);
|
||||||
|
|
||||||
return { start: current, end: other };
|
return { start: current, end: other };
|
||||||
@@ -645,7 +639,7 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
elementsMap,
|
elementsMap,
|
||||||
elements,
|
elements,
|
||||||
globalBindMode,
|
globalBindMode,
|
||||||
opts,
|
{ appState },
|
||||||
);
|
);
|
||||||
|
|
||||||
return { start: other, end: current };
|
return { start: other, end: current };
|
||||||
|
@@ -49,6 +49,7 @@ import {
|
|||||||
getOutlineAvoidingPoint,
|
getOutlineAvoidingPoint,
|
||||||
isBindingEnabled,
|
isBindingEnabled,
|
||||||
maybeSuggestBindingsForBindingElementAtCoords,
|
maybeSuggestBindingsForBindingElementAtCoords,
|
||||||
|
snapToCenter,
|
||||||
} from "./binding";
|
} from "./binding";
|
||||||
import {
|
import {
|
||||||
getElementAbsoluteCoords,
|
getElementAbsoluteCoords,
|
||||||
@@ -2037,7 +2038,7 @@ const pointDraggingUpdates = (
|
|||||||
newGlobalPointPosition = getOutlineAvoidingPoint(
|
newGlobalPointPosition = getOutlineAvoidingPoint(
|
||||||
element,
|
element,
|
||||||
hoveredElement,
|
hoveredElement,
|
||||||
newGlobalPointPosition,
|
snapToCenter(hoveredElement, elementsMap, newGlobalPointPosition),
|
||||||
pointIndex,
|
pointIndex,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
customIntersector,
|
customIntersector,
|
||||||
@@ -2127,7 +2128,7 @@ const pointDraggingUpdates = (
|
|||||||
const newGlobalPointPosition = getOutlineAvoidingPoint(
|
const newGlobalPointPosition = getOutlineAvoidingPoint(
|
||||||
element,
|
element,
|
||||||
hoveredElement,
|
hoveredElement,
|
||||||
focusGlobalPoint,
|
snapToCenter(hoveredElement, elementsMap, focusGlobalPoint),
|
||||||
pointIndex,
|
pointIndex,
|
||||||
elementsMap,
|
elementsMap,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user