From 7baec03341e3cfce1e028a2206db7e21e43d5861 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 16 Sep 2017 22:11:50 +0200 Subject: [PATCH] Fix scale equally and double flip not happening (#4313) * fix double flip * fixed lint --- src/canvas.class.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index 05c9b2ec92d..d0520b7d6fc 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -868,12 +868,13 @@ var dist = localMouse.y + localMouse.x, lastDist = _dim.y * transform.original.scaleY / target.scaleY + _dim.x * transform.original.scaleX / target.scaleX, - scaled; + scaled, signX = localMouse.x / Math.abs(localMouse.x), + signY = localMouse.y / Math.abs(localMouse.y); // We use transform.scaleX/Y instead of target.scaleX/Y // because the object may have a min scale and we'll loose the proportions - transform.newScaleX = transform.original.scaleX * dist / lastDist; - transform.newScaleY = transform.original.scaleY * dist / lastDist; + transform.newScaleX = signX * Math.abs(transform.original.scaleX * dist / lastDist); + transform.newScaleY = signY * Math.abs(transform.original.scaleY * dist / lastDist); scaled = transform.newScaleX !== target.scaleX || transform.newScaleY !== target.scaleY; target.set('scaleX', transform.newScaleX); target.set('scaleY', transform.newScaleY);