我正在使用Raphael加载图像,然后使用raphael在图像上绘制一些节点。但由于图像文件需要一些时间来加载,因此节点会在图像之前加载。我正在寻找关于如何在执行JS的其余部分之前完全加载图像的建议。
var r = Raphael("canvas", 1500,1500);
var attr = {
//"stroke": "#666",
"stroke-width": 1,
"stroke-linejoin": "round",
"fill": "#000000"
};
var t="t-165,-30";
var figure=r.image("images4.png",100,117,600,900); // Loading the image and then more JS follows
答案 0 :(得分:0)
var img = document.createElement('img');
img.onload = function() {
//Do your stuff here, the image is loaded.
delete img;
};
img.setAttribute('src', imageSrc);