The LoadFromJSON () function loads objects filled with a template only after a Click event on the canvas

When I try to load the JSON data onto the canvas each form is loaded, but templates filled with shapes are loaded only after I click on the shape.

Can someone explain why this is happening? Even I checked this:

 canvas2.loadFromJSON(json,canvas2.renderAll.bind(canvas2)); 

In addition, the same problem is associated with the clone() function: the object is duplicated. But the template filled with the object is displayed only after clicking on the object.

Iam using version 1.3.7

+4
source share
1 answer

I found a “temporary” solution and it works for me in IE9 and google chrome.

My solution delays the renderAll () of the canvas object immediately after calling the loadFromJSON () function.

 setTimeout(function(){ canvas.renderAll(); }, 1); 
+1
source

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


All Articles