javascript - Uncaught TypeError: Cannot read property 'width' of null -


i'm trying out fabric.js, , right i'm trying put in image experiment with.

i've followed the tutorial following error:

uncaught typeerror: cannot read property 'width' of null 

... refers line 14805 in all.js:

_setwidthheight: function(options) {     this.width = 'width' in options         ? options.width         : (this.getelement().width || 0);    // <------ line     this.height = 'height' in options         ? options.height         : (this.getelement().height || 0); }, 

my code (html):

... <div id="avatarbox">     <canvas id="canvas" width="500" height="500"/>     <img src="img/test.png" id="my-image"> </div> ... 

my code (js):

var canvas = new fabric.canvas('canvas'); var imgelement = document.getelementbyid('my-img');  var imginstance = new fabric.image(imgelement, {     left: 100,     top: 100,     angle: 30,     opacity: 0.85 });  canvas.add(imginstance); 

what can wrong?

you don't have "my-img" in html. have "my-image", maybe problem comes there?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -