mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-18 23:10:16 +02:00
fix: snapToCenter()
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
KEYS,
|
KEYS,
|
||||||
arrayToMap,
|
arrayToMap,
|
||||||
debugDrawPoint,
|
|
||||||
invariant,
|
invariant,
|
||||||
isAlwaysInsideBinding,
|
isAlwaysInsideBinding,
|
||||||
isDevEnv,
|
|
||||||
tupleToCoors,
|
tupleToCoors,
|
||||||
} from "@excalidraw/common";
|
} from "@excalidraw/common";
|
||||||
|
|
||||||
@@ -604,15 +602,6 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
globalBindMode,
|
globalBindMode,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isDevEnv()) {
|
|
||||||
if (start?.focusPoint) {
|
|
||||||
debugDrawPoint(start.focusPoint);
|
|
||||||
}
|
|
||||||
if (end?.focusPoint) {
|
|
||||||
debugDrawPoint(end.focusPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { start, end };
|
return { start, end };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,15 +624,6 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
{ appState },
|
{ appState },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isDevEnv()) {
|
|
||||||
if (current?.focusPoint) {
|
|
||||||
debugDrawPoint(current.focusPoint);
|
|
||||||
}
|
|
||||||
if (other?.focusPoint) {
|
|
||||||
debugDrawPoint(other.focusPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { start: current, end: other };
|
return { start: current, end: other };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,15 +645,6 @@ export const getBindingStrategyForDraggingBindingElementEndpoints = (
|
|||||||
{ appState },
|
{ appState },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isDevEnv()) {
|
|
||||||
if (current?.focusPoint) {
|
|
||||||
debugDrawPoint(current.focusPoint);
|
|
||||||
}
|
|
||||||
if (other?.focusPoint) {
|
|
||||||
debugDrawPoint(other.focusPoint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { start: other, end: current };
|
return { start: other, end: current };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1297,19 +1268,19 @@ export const snapToCenter = (
|
|||||||
): GlobalPoint => {
|
): GlobalPoint => {
|
||||||
const percent = 0.94868; // 90% by volume
|
const percent = 0.94868; // 90% by volume
|
||||||
|
|
||||||
return isPointInElement(
|
const isPointDeepInside = isPointInElement(
|
||||||
p,
|
p,
|
||||||
{
|
{
|
||||||
...element,
|
...element,
|
||||||
x: element.x - (element.width * (1 - percent)) / 2,
|
x: element.x + (element.width * (1 - percent)) / 2,
|
||||||
y: element.y - (element.height * (1 - percent)) / 2,
|
y: element.y + (element.height * (1 - percent)) / 2,
|
||||||
width: element.width * percent,
|
width: element.width * percent,
|
||||||
height: element.height * percent,
|
height: element.height * percent,
|
||||||
},
|
},
|
||||||
elementsMap,
|
elementsMap,
|
||||||
)
|
);
|
||||||
? elementCenterPoint(element, elementsMap)
|
|
||||||
: p;
|
return isPointDeepInside ? elementCenterPoint(element, elementsMap) : p;
|
||||||
};
|
};
|
||||||
|
|
||||||
const snapToMid = (
|
const snapToMid = (
|
||||||
|
Reference in New Issue
Block a user