I am trying to send backward & bring forward a active object/active group on click of button in fabric js , i am able send backward a active object but getting problem in group.
Here is my code
$('#send-backward').click(function() {
var activeObject=canvas.getActiveObject(),
activeGroup=canvas.getActiveGroup();
if (activeObject) {
canvas.sendBackwards(activeObject);
canvas.renderAll();
}
else if (activeGroup) {
canvas.getActiveGroup().forEachObject(function(o){canvas.sendBackwards(o); });
//activeGroup.sendBackwards();
canvas.renderAll();
}
});
$('#bring-forward').click(function() {
var activeObject=canvas.getActiveObject(),
activeGroup=canvas.getActiveGroup();
if (activeObject) {
canvas.bringForward(activeObject);
canvas.renderAll();
}
else if (activeGroup) {
canvas.getActiveGroup().forEachObject(function(o){canvas.bringForward(o); });
//activeGroup.bringForward();
canvas.renderAll();
}
});
Jsfiddle
with this code bring forward is ok but problem in send backward
and another code try is
jsfiddlethis code is working strange it make a copy of group
Thanks in advance for help