fix negative resize for non-multipoint elements (#1000)

This commit is contained in:
David Luzar 2020-03-18 16:34:04 +01:00 committed by GitHub
parent d8bbe536a7
commit 254a0753ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1818,11 +1818,13 @@ export class App extends React.Component<any, AppState> {
break; break;
case "n": { case "n": {
const height = element.height - deltaY; const height = element.height - deltaY;
if (height <= 0) {
break;
}
if (isLinearElement(element)) { 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, { mutateElement(element, {
height, height,
y: element.y + deltaY, y: element.y + deltaY,
@ -1840,11 +1842,13 @@ export class App extends React.Component<any, AppState> {
case "w": { case "w": {
const width = element.width - deltaX; 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 (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, { mutateElement(element, {
width, width,
x: element.x + deltaX, x: element.x + deltaX,
@ -1860,11 +1864,13 @@ export class App extends React.Component<any, AppState> {
} }
case "s": { case "s": {
const height = element.height + deltaY; const height = element.height + deltaY;
if (height <= 0) {
break;
}
if (isLinearElement(element)) { 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, { mutateElement(element, {
height, height,
points: rescalePoints(1, height, element.points), points: rescalePoints(1, height, element.points),
@ -1878,11 +1884,13 @@ export class App extends React.Component<any, AppState> {
} }
case "e": { case "e": {
const width = element.width + deltaX; const width = element.width + deltaX;
if (width <= 0) {
break;
}
if (isLinearElement(element)) { 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, { mutateElement(element, {
width, width,
points: rescalePoints(0, width, element.points), points: rescalePoints(0, width, element.points),