mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-16 12:20:59 +00:00
Update group.class.js
added managing of originX/Y to group.
This commit is contained in:
parent
d1ba16f177
commit
2fefe13613
1 changed files with 21 additions and 8 deletions
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue