From 2fefe136135abca6ee8af0fb769f976b83f1f07e Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Mon, 20 Oct 2014 15:38:05 +0200 Subject: [PATCH] Update group.class.js added managing of originX/Y to group. --- src/shapes/group.class.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/shapes/group.class.js b/src/shapes/group.class.js index 00ac56e5..87c59a7c 100644 --- a/src/shapes/group.class.js +++ b/src/shapes/group.class.js @@ -58,13 +58,13 @@ this.originalState = { }; this.callSuper('initialize'); - this._calcBounds(); - this._updateObjectsCoords(); - if (options) { extend(this, options); } + this._calcBounds(); + this._updateObjectsCoords(); + this.setCoords(); this.saveCoords(); }, @@ -81,13 +81,14 @@ */ _updateObjectCoords: function(object) { var objectLeft = object.getLeft(), - objectTop = object.getTop(); + objectTop = object.getTop(), + center = this.getCenterPoint(); object.set({ originalLeft: objectLeft, originalTop: objectTop, - left: objectLeft - this.left, - top: objectTop - this.top + left: objectLeft - center.x, + top: objectTop - center.y }); object.setCoords(); @@ -449,8 +450,20 @@ }; if (!onlyWidthHeight) { - obj.left = (minXY.x + maxXY.x) / 2 || 0; - obj.top = (minXY.y + maxXY.y) / 2 || 0; + obj.left = minXY.x || 0; + obj.top = minXY.y || 0; + if (this.originX === 'center') { + obj.left += obj.width / 2; + } + if (this.originX === 'right') { + obj.left += obj.width; + } + if (this.originY === 'center') { + obj.top += obj.height / 2; + } + if (this.originY === 'bottom') { + obj.top += obj.height; + } } return obj; },