Group position numeric origins (#5143)

* fixed positioning

* fixed positioning

* ok tests are ok

* ok tests are ok
This commit is contained in:
Andrea Bogazzi 2018-08-05 23:52:31 +02:00 committed by GitHub
parent c541a273ff
commit 133c674697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 35 deletions

View file

@ -77,13 +77,6 @@
this._objects[i].group = this;
}
if (options.originX) {
this.originX = options.originX;
}
if (options.originY) {
this.originY = options.originY;
}
if (!isAlreadyGrouped) {
var center = options && options.centerPoint;
// if coming from svg i do not want to calc bounds.
@ -489,7 +482,7 @@
}
}
this.set(this._getBounds(aX, aY, onlyWidthHeight));
this._getBounds(aX, aY, onlyWidthHeight);
},
/**
@ -498,28 +491,14 @@
_getBounds: function(aX, aY, onlyWidthHeight) {
var minXY = new fabric.Point(min(aX), min(aY)),
maxXY = new fabric.Point(max(aX), max(aY)),
obj = {
width: (maxXY.x - minXY.x) || 0,
height: (maxXY.y - minXY.y) || 0
};
top = minXY.y || 0, left = minXY.x || 0,
width = (maxXY.x - minXY.x) || 0,
height = (maxXY.y - minXY.y) || 0;
this.width = width;
this.height = height;
if (!onlyWidthHeight) {
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;
}
this.setPositionByOrigin({ x: left, y: top }, 'left', 'top');
}
return obj;
},
/* _TO_SVG_START_ */

View file

@ -218,13 +218,13 @@
strokeWidth: 0
}];
var expectedObject = {
'version': fabric.version,
'type': 'group',
'left': 50,
'top': 100,
'width': 80,
'height': 60,
'objects': objects
version: fabric.version,
type: 'group',
left: 50,
top: 100,
width: 80,
height: 60,
objects: objects
};
assert.deepEqual(clone, expectedObject);
});