From 254a0753ff098f7537b487e8b459f08f98356f69 Mon Sep 17 00:00:00 2001 From: David Luzar Date: Wed, 18 Mar 2020 16:34:04 +0100 Subject: [PATCH] fix negative resize for non-multipoint elements (#1000) --- src/components/App.tsx | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index 179c80a7..e03eae9d 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1818,11 +1818,13 @@ export class App extends React.Component { break; case "n": { const height = element.height - deltaY; - if (height <= 0) { - break; - } if (isLinearElement(element)) { + if (element.points.length > 2 && height <= 0) { + // Someday we should implement logic to flip the shape. + // But for now, just stop. + break; + } mutateElement(element, { height, y: element.y + deltaY, @@ -1840,11 +1842,13 @@ export class App extends React.Component { case "w": { const width = element.width - deltaX; - if (width <= 0) { - // Someday we should implement logic to flip the shape. But for now, just stop. - break; - } if (isLinearElement(element)) { + if (element.points.length > 2 && width <= 0) { + // Someday we should implement logic to flip the shape. + // But for now, just stop. + break; + } + mutateElement(element, { width, x: element.x + deltaX, @@ -1860,11 +1864,13 @@ export class App extends React.Component { } case "s": { const height = element.height + deltaY; - if (height <= 0) { - break; - } if (isLinearElement(element)) { + if (element.points.length > 2 && height <= 0) { + // Someday we should implement logic to flip the shape. + // But for now, just stop. + break; + } mutateElement(element, { height, points: rescalePoints(1, height, element.points), @@ -1878,11 +1884,13 @@ export class App extends React.Component { } case "e": { const width = element.width + deltaX; - if (width <= 0) { - break; - } if (isLinearElement(element)) { + if (element.points.length > 2 && width <= 0) { + // Someday we should implement logic to flip the shape. + // But for now, just stop. + break; + } mutateElement(element, { width, points: rescalePoints(0, width, element.points),