Don't destroy the selection group when doing toSVG

toSVG now mirrors the behaviour of toJSON and does not destroy
the active selection group when serialising. Instead, the effect
of the group is simulated on a clone of the object and this is
what gets serialised.
This commit is contained in:
KJ Tsanaktsidis 2015-02-26 13:39:45 +11:00
parent b92650ef0d
commit 492a7693c5

View file

@ -1278,18 +1278,17 @@
* @private
*/
_setSVGObjects: function(markup, reviver) {
var activeGroup = this.getActiveGroup();
if (activeGroup) {
this.discardActiveGroup();
}
var selectionGroup = this.getActiveGroup();
for (var i = 0, objects = this.getObjects(), len = objects.length; i < len; i++) {
markup.push(objects[i].toSVG(reviver));
}
if (activeGroup) {
this.setActiveGroup(new fabric.Group(activeGroup.getObjects()));
activeGroup.forEachObject(function(o) {
o.set('active', true);
});
if (selectionGroup && objects[i].group === selectionGroup) {
//If the object is in a selection group, simulate what would happen to that
//object when the group is deselected
var objectClone = objects[i].clone();
selectionGroup.realizeTransform(objectClone);
markup.push(objectClone.toSVG(reviver));
} else {
markup.push(objects[i].toSVG(reviver));
}
}
},