I am fabric.js
application using fabric.js
and fabric.js
experiencing really strange behavior. I add both images and text instances using regular fabric.Canvas
(not fabric.StaticCanvas
) and cannot move or resize these elements after adding. I added only a couple of types. The main functionality is wrapped in a callback tied to the click event on a button, but the functionality of the main structure looks something like this (simplified, but almost the same as for the code associated with the network):
<canvas id="myCanvas" height=600 width=800></canvas> <input id="addStuff" type="button" value="Add!" /> .... var canvas = new fabric.Canvas('myCanvas'); canvas.renderOnAddition = true; $(function(){ $('#addStuff').on('click', function(e) { var text = new fabric.Text("Hello, world", { top : 100, left : 100, fontSize : 12, fontFamily : 'Delicious_500' }); text.hasControls = false; canvas.add(text); fabric.Image.fromURL('./img/pic.png', function(img) { var imgX = img.set({ top: 200, left: 100, }); canvas.add(imgX); }); canvas.renderAll(); }); });
The above code displays elements well, but they cannot be changed or moved, and act statically. It is strange that if I open and close the chrome dev panel (F12 panel or [Ctrl / CMD] + SHIFT + I twice), the canvas restores functionality and everything works again . I also have some server-side stuff (this is just a mock example of what I'm doing), but I have no idea how to further trace this to this strange behavior. I am using the latest code (built from github repo). Thoughts?
sa125 source share