How to send back and transfer the active group to fabricjs

I am trying to send back and display the active object / active group by pressing a button in java java, I can send back the active object, but get problems in the 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 push forward normally, but the problem is sending back
and try another code - jsfiddle this code works weird, it makes a copy of the group

Thank you in advance

+4
source share
2 answers

You can directly use the activeGroup.sendBackwards()appropriateactiveGroup.bringForward()

+2
source

1.7.3 activeGroup.sendBackwards() && & activeGroup.bringForward()

, , Both sendToBack && & && ToFront

fooobar.com/questions/290264/...

0

Source: https://habr.com/ru/post/1611909/


All Articles