loadFromJSON() function is loading objects Filled

2019-04-09 12:29发布

问题:

When am trying to load the JSON data onto the canvas, every shape is getting loaded but the patterns that are filled in the shapes are loaded only after I click on the shape.

Could some one please explain why this is happening ? Even i checked this:

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

Also, the same problem is with the clone() function : The Object is duplicated. But the pattern filled in the object is shown only after I click on the object.

Iam using version 1.3.7

回答1:

I have found a "temporary" solution, and it works for me in IE9 and google chrome.

My solution is delay the renderAll() of the canvas object right after the loadFromJSON() function is called.

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