mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-04 20:04:45 +00:00
Group position numeric origins (#5143)
* fixed positioning * fixed positioning * ok tests are ok * ok tests are ok
This commit is contained in:
parent
c541a273ff
commit
133c674697
2 changed files with 14 additions and 35 deletions
|
|
@ -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_ */
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue