mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-18 05:00:58 +00:00
Fix groups being lost after toDataURLWithMultiplier.
This commit is contained in:
parent
30f24f7f35
commit
b669085c97
1 changed files with 34 additions and 3 deletions
|
|
@ -569,12 +569,17 @@
|
|||
origHeight = this.getHeight(),
|
||||
scaledWidth = origWidth * multiplier,
|
||||
scaledHeight = origHeight * multiplier,
|
||||
activeObject = this.getActiveObject();
|
||||
activeObject = this.getActiveObject(),
|
||||
activeGroup = this.getActiveGroup();
|
||||
|
||||
this.setWidth(scaledWidth).setHeight(scaledHeight);
|
||||
this.contextTop.scale(multiplier, multiplier);
|
||||
|
||||
if (activeObject) {
|
||||
if (activeGroup) {
|
||||
// not removing group due to complications with restoring it with correct state afterwords
|
||||
this._tempRemoveBordersCornersFromGroup(activeGroup);
|
||||
}
|
||||
else if (activeObject) {
|
||||
this.deactivateAll();
|
||||
}
|
||||
|
||||
|
|
@ -590,14 +595,40 @@
|
|||
this.contextTop.scale(1 / multiplier, 1 / multiplier);
|
||||
this.setWidth(origWidth).setHeight(origHeight);
|
||||
|
||||
if (activeObject) {
|
||||
if (activeGroup) {
|
||||
this._restoreBordersCornersOnGroup(activeGroup);
|
||||
}
|
||||
else if (activeObject) {
|
||||
this.setActiveObject(activeObject);
|
||||
}
|
||||
|
||||
this.renderAll();
|
||||
|
||||
return dataURL;
|
||||
},
|
||||
|
||||
_tempRemoveBordersCornersFromGroup: function(group) {
|
||||
group.origHideCorners = group.hideCorners;
|
||||
group.origBorderColor = group.borderColor;
|
||||
|
||||
group.hideCorners = true;
|
||||
group.borderColor = 'rgba(0,0,0,0)';
|
||||
|
||||
group.forEachObject(function(o) {
|
||||
o.origBorderColor = o.borderColor;
|
||||
o.borderColor = 'rgba(0,0,0,0)';
|
||||
});
|
||||
},
|
||||
_restoreBordersCornersOnGroup: function(group) {
|
||||
group.hideCorners = group.origHideCorners;
|
||||
group.borderColor = group.origBorderColor;
|
||||
|
||||
group.forEachObject(function(o) {
|
||||
o.borderColor = o.origBorderColor;
|
||||
delete o.origBorderColor;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns coordinates of a center of canvas.
|
||||
* Returned value is an object with top and left properties
|
||||
|
|
|
|||
Loading…
Reference in a new issue