From 143e3ee66a2d893ce7371debf583f0033d53097e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Wed, 30 Dec 2015 16:24:02 +0100 Subject: [PATCH] update _normalizePointer --- src/canvas.class.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/canvas.class.js b/src/canvas.class.js index 1a305c0e..b415dcc7 100644 --- a/src/canvas.class.js +++ b/src/canvas.class.js @@ -277,22 +277,24 @@ */ _normalizePointer: function (object, pointer) { var activeGroup = this.getActiveGroup(), - x = pointer.x, - y = pointer.y, isObjectInGroup = ( activeGroup && object.type !== 'group' && activeGroup.contains(object)), - lt; + lt, m; if (isObjectInGroup) { - lt = fabric.util.transformPoint(activeGroup.getCenterPoint(), this.viewportTransform, true); - x -= lt.x; - y -= lt.y; - x /= activeGroup.scaleX; - y /= activeGroup.scaleY; + m = fabric.util.multiplyTransformMatrices( + this.viewportTransform, + activeGroup.calcTransformMatrix()); + + m = fabric.util.invertTransform(m); + pointer = fabric.util.transformPoint(pointer, m , false); + lt = fabric.util.transformPoint(activeGroup.getCenterPoint(), m , false); + pointer.x -= lt.x; + pointer.y -= lt.y; } - return { x: x, y: y }; + return { x: pointer.x, y: pointer.y }; }, /**