Switch fix aspect ratio to default when resizing by a corner (#681)

This commit is contained in:
DD Liu 2018-09-17 13:43:51 -04:00 committed by GitHub
parent 4b658c294f
commit b6ad997ea2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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;