0

How to use node.setZIndex(2); or node.moveToTop(); node.moveToBottom(); for background layer fix in bottom any images and texts?

If a clicked background -> image -> background, the image go to bottom

https://jsfiddle.net/hk7xe0we/12/

$('.back').click(function(){
    imgback = $(this).find('img').attr('src');


    var imageObj = new Image();
    imageObj.onload = function() {

      var background = new Konva.Image({
        image: imageObj,
      });
      // add the shape to the layer
      layer.add(background);
      layer.draw();


    };
    imageObj.src = imgback ; 

});

https://github.com/EditorsJS/editorimagekonvajs

Thanks for any help

Gislef
  • 1,555
  • 3
  • 14
  • 37

1 Answers1

0
imageObj.onload = function() {
    // remove previous backgorun
    layer.find('.backgroud').destroy();

    var background = new Konva.Image({
        name: 'backgroud',
        image: imageObj,
    });
    // add new one
    layer.add(background);
    background.moveToBottom();
    layer.draw();
};

https://jsfiddle.net/hk7xe0we/13/

lavrton
  • 18,973
  • 4
  • 30
  • 63