Fix groups being lost after toDataURLWithMultiplier.

This commit is contained in:
kangax 2012-06-26 16:41:43 +02:00
parent 30f24f7f35
commit b669085c97

View file

@ -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