Fix resize logic (partly) (#1475)

This commit is contained in:
Daishi Kato 2020-04-27 17:30:19 +09:00 committed by GitHub
parent 4824f9e1d4
commit da1031aeb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 26 deletions

View file

@ -140,7 +140,7 @@ export const resizeElements = (
const handleOffset = 4 / appState.zoom; // XXX import constant
const dashedLinePadding = 4 / appState.zoom; // XXX import constant
const offsetPointer = handleOffset + dashedLinePadding;
const minSize = handleOffset * 4;
const minSize = 0;
if (selectedElements.length === 1) {
const [element] = selectedElements;
if (resizeHandle === "rotation") {
@ -182,15 +182,17 @@ export const resizeElements = (
lastY,
);
} else if (resizeHandle) {
const [x1, y1] = getElementAbsoluteCoords(element);
const [x1, y1, x2, y2] = getElementAbsoluteCoords(element);
const resized = resizeXYWidthHightWithRotation(
resizeHandle,
x1,
y1,
x2,
y2,
element.width,
element.height,
x1 - element.x,
y1 - element.y,
element.x,
element.y,
element.angle,
xPointer,
yPointer,
@ -198,7 +200,10 @@ export const resizeElements = (
getResizeWithSidesSameLengthKey(event),
getResizeCenterPointKey(event),
);
if (resized.width !== 0 && resized.height !== 0) {
if (
Math.abs(resized.width) > minSize &&
Math.abs(resized.height) > minSize
) {
mutateElement(element, {
...resized,
...(isLinearElement(element)