loadFromJSON()函数加载对象只有在画布上的Click事件后才填充Pattern [英] loadFromJSON() function is loading objects Filled with Pattern only after Click event on the Canvas

查看:715
本文介绍了loadFromJSON()函数加载对象只有在画布上的Click事件后才填充Pattern的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试将JSON数据加载到画布时,每个形状都会加载,但填充在形状中的模式只有在我点击形状。

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));

同样的问题是 clone $ c> function:对象被复制。

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使用版本1.3.7

Iam using version 1.3.7

推荐答案

我找到了一个临时解决方案,它适用于我在IE9和google chrome。

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

是在loadFromJSON()函数被调用后立即延迟canvas对象的renderAll()。

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

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

这篇关于loadFromJSON()函数加载对象只有在画布上的Click事件后才填充Pattern的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆