Update group.class.js

added managing of  originX/Y to group.
This commit is contained in:
Andrea Bogazzi 2014-10-20 15:38:05 +02:00
parent d1ba16f177
commit 2fefe13613

View file

@ -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;
},