From 0f24b4b6b5643fb467676c1bd97a20747d604cf0 Mon Sep 17 00:00:00 2001 From: Jacco Kulman Date: Wed, 17 Jun 2020 06:47:20 +0200 Subject: [PATCH] MIN_SCALE_FACTOR & clamping instead of halting --- src/helper/selection-tools/scale-tool.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/helper/selection-tools/scale-tool.js b/src/helper/selection-tools/scale-tool.js index f3fed211..1b27eaeb 100644 --- a/src/helper/selection-tools/scale-tool.js +++ b/src/helper/selection-tools/scale-tool.js @@ -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,19 +116,15 @@ class ScaleTool { sy = size.y / this.origSize.y; } + const signx = sx > 0 ? 1 : -1; + const signy = sy > 0 ? 1 : -1; 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)); sx *= signx; sy *= signy; } - if (Math.abs(sx) < 0.0001) { - sx = this.lastSx; - } - if (Math.abs(sy) < 0.0001) { - sy = this.lastSy; - } + 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);