javascript - Fabric.js copy paste of selected group -
say have multiple objects selected on fabric.js canvas , can group of objects using getactivegroup. can provide example of how copy , paste group new group, where:
(a) each object in copied group retains relative position other copied objects
(b) copied group whole positioned @ specified x,y position
(c) copied group objects selected group after paste, if selection cleared treated individual objects on canvas
i have tried pasting cloning , adding cloned group this:
canvas.getactivegroup().clone(function(clone) { clone.left = 100; clone.top = 100; canvas.add(clone); canvas.deactivateall(); canvas.setactivegroup(clone).renderall(); });
now after code run cloned group objects seem added, positioned , selected ok, click canvas clear selection cloned group objects jump different spot on canvas. cloned objects not individually selectable , selection location out of sync new object location. anyways i'm sure i'm missing i'm not sure what. appreciated.
you should try canvas.getactivegroup().foreachobject(function(o)
group type objects , clone them.
i made jsfiddle cloning group.
Comments
Post a Comment