html5 canvas - Fabric.js doesn't maintain group when exporting/importing JSON -
so have issue fabric.js that's once again down own ignorance.
imagine using free draw scribble line paths on canvas. when finished, disable free draw , @ point want take objects drawn , group them in single entity.
i've created fiddle here shows grouping stage.
var grp=new fabric.group(); canvas.getobjects().map(function(o){ if(o.type=="path"){ o.hascontrols=o.hasborders=false; grp.addwithupdate(o); //canvas.clear(); // seems break grouping } }); canvas.add(grp); canvas._activeobject = null; canvas.setactivegroup(grp.setcoords()).renderall();
this appears work enough (even if paths appear darken once group has been created).
i want export json, save @ db, , in future reload , replicate whole layout.
in fiddle above reproduce sort of behaviour first saving canvas json after group has been created, , attempt reload it.
as you'll see, reload works fine , positioning item grouped has been loaded in it's constituent parts, rather being maintained group.
am doing dumb here?
thanks help!
Comments
Post a Comment