mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-04-10 01:10:59 +00:00
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:
parent
b92650ef0d
commit
492a7693c5
1 changed files with 10 additions and 11 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue