From b6ad997ea27008726d3e227f3f9d778e5d5269cf Mon Sep 17 00:00:00 2001 From: DD Liu Date: Mon, 17 Sep 2018 13:43:51 -0400 Subject: [PATCH] Switch fix aspect ratio to default when resizing by a corner (#681) --- src/helper/selection-tools/scale-tool.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/helper/selection-tools/scale-tool.js b/src/helper/selection-tools/scale-tool.js index 9500e7e8..58327817 100644 --- a/src/helper/selection-tools/scale-tool.js +++ b/src/helper/selection-tools/scale-tool.js @@ -40,6 +40,7 @@ class ScaleTool { this.corner = boundsPath.bounds[this._getRectCornerNameByIndex(index)].clone(); this.origSize = this.corner.subtract(this.pivot); this.origCenter = boundsPath.bounds.center; + this.isCorner = this._isCorner(index); this.centered = false; this.lastSx = 1; this.lastSy = 1; @@ -105,7 +106,7 @@ class ScaleTool { sy = size.y / modOrigSize.y; } - if (event.modifiers.shift) { + if (this.isCorner && !event.modifiers.shift) { const signx = sx > 0 ? 1 : -1; const signy = sy > 0 ? 1 : -1; sx = sy = Math.max(Math.abs(sx), Math.abs(sy)); @@ -197,6 +198,17 @@ class ScaleTool { return 'topCenter'; } } + _isCorner (index) { + switch (index) { + case 0: + case 2: + case 4: + case 6: + return true; + default: + return false; + } + } } export default ScaleTool;