Merge pull request #1120 from Jacco/fix-379

prevent scaling factor too low (per direction)
This commit is contained in:
DD Liu 2020-06-18 21:37:35 -04:00 committed by GitHub
commit e90000b20b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,8 @@ import {getItems} from '../selection';
import {getActionBounds} from '../view';
import {BitmapModes} from '../../lib/modes';
const MIN_SCALE_FACTOR = 0.0001;
/**
* Tool to handle scaling items by pulling on the handles around the edges of the bounding
* box when in the bounding box tool.
@ -114,13 +116,15 @@ class ScaleTool {
sy = size.y / this.origSize.y;
}
if (this.isCorner && !event.modifiers.shift) {
const signx = sx > 0 ? 1 : -1;
const signy = sy > 0 ? 1 : -1;
if (this.isCorner && !event.modifiers.shift) {
sx = sy = Math.max(Math.abs(sx), Math.abs(sy));
sx *= signx;
sy *= signy;
}
sx = signx * Math.max(Math.abs(sx), MIN_SCALE_FACTOR);
sy = signy * Math.max(Math.abs(sy), MIN_SCALE_FACTOR);
this.itemGroup.scale(sx / this.lastSx, sy / this.lastSy, this.pivot);
if (this.selectionAnchor) {
this.selectionAnchor.scale(this.lastSx / sx, this.lastSy / sy);