mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-27 11:19:53 +02:00
fix: Refactored timeout bind mode handling
fix: Center when orbiting feat: Color change on highlight
This commit is contained in:
@@ -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 };
|
||||
|
@@ -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,
|
||||
);
|
||||
|
@@ -269,7 +269,7 @@ const generateElementCanvas = (
|
||||
context.filter = IMAGE_INVERT_FILTER;
|
||||
}
|
||||
|
||||
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
||||
drawElementOnCanvas(element, rc, context, renderConfig);
|
||||
|
||||
context.restore();
|
||||
|
||||
@@ -404,7 +404,6 @@ const drawElementOnCanvas = (
|
||||
rc: RoughCanvas,
|
||||
context: CanvasRenderingContext2D,
|
||||
renderConfig: StaticCanvasRenderConfig,
|
||||
appState: StaticCanvasAppState,
|
||||
) => {
|
||||
switch (element.type) {
|
||||
case "rectangle":
|
||||
@@ -795,7 +794,7 @@ export const renderElement = (
|
||||
context.translate(cx, cy);
|
||||
context.rotate(element.angle);
|
||||
context.translate(-shiftX, -shiftY);
|
||||
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
||||
drawElementOnCanvas(element, rc, context, renderConfig);
|
||||
context.restore();
|
||||
} else {
|
||||
const elementWithCanvas = generateElementWithCanvas(
|
||||
@@ -888,13 +887,7 @@ export const renderElement = (
|
||||
|
||||
tempCanvasContext.translate(-shiftX, -shiftY);
|
||||
|
||||
drawElementOnCanvas(
|
||||
element,
|
||||
tempRc,
|
||||
tempCanvasContext,
|
||||
renderConfig,
|
||||
appState,
|
||||
);
|
||||
drawElementOnCanvas(element, tempRc, tempCanvasContext, renderConfig);
|
||||
|
||||
tempCanvasContext.translate(shiftX, shiftY);
|
||||
|
||||
@@ -933,7 +926,7 @@ export const renderElement = (
|
||||
}
|
||||
|
||||
context.translate(-shiftX, -shiftY);
|
||||
drawElementOnCanvas(element, rc, context, renderConfig, appState);
|
||||
drawElementOnCanvas(element, rc, context, renderConfig);
|
||||
}
|
||||
|
||||
context.restore();
|
||||
|
Reference in New Issue
Block a user