can't include img in div?

// Expert user has replied.
M MengChang Xiao 3 years 6 months ago
3 3 0

Actually I have post a question,but no response till now.
I found something.
This is my source code:
 
         
           
        var width = window.innerWidth;
        var height = window.innerHeight;
            var stage = new Konva.Stage({
          container: 'container',
          width: width,
          height: height,
          opacity:1
        });
        var backlayer = new Konva.Layer();
        stage.add(backlayer);
                        onaccclick = function(){   
          hev.accelerate();
        }
        onbrakeclick = function(){   
          hev.brake();
        }
......
I have insert a after div, but you cant find it in the spector:

If I lay it out of div,it will display.

I checked the definition of DIV,no such of limited.
Why?

Please Register or Login to post a reply

3 Replies

B Bhakta Ranjan Satapathy

Hello Xiao,

Could you please attach your complete sample application here, so that we can try to reproduce the same behaviour that you are seeing.

Thanks

R Robert Galvin

Hi,

If you are trying to add an image to your Konva canvas, you are doing it all wrong. Please check Konva's website for details:

Image Tutorial | Konva - JavaScript 2d canvas framework

 
 
  Konva Image Demo
 
    body {
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #F0F0F0;
    }
 

 
 
    var width = window.innerWidth;
    var height = window.innerHeight;

    var stage = new Konva.Stage({
      container: 'container',
      width: width,
      height: height
    });

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

      var yoda = new Konva.Image({
        x: 50,
        y: 50,
        image: imageObj,
        width: 106,
        height: 118
      });

      // add the shape to the layer
      layer.add(yoda);

      // add the layer to the stage
      stage.add(layer);
    };
    imageObj.src = 'http://konvajs.github.io/assets/yoda.jpg';
 

M MengChang Xiao

No people visit now?
Waiting for help.

CONTACT
Can’t find what you’re looking for?