【发布时间】:2016-12-27 14:13:48
【问题描述】:
html:
<canvas id="cnv" width="786" height="1113">
js:
var img = new Image(),
cnv = document.getElementById('cnv');
var context = cnv.getContext('2d');
img.onload = function () {
context.drawImage(img, 0, 0, 786, 1113);
alert('finished drawing');
}
img.src = 'https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white_fe6da1ec.png';
我想在画布完成渲染后显示警报。但是在绘制图像之前会显示警报。
如何等待 GUI 线程完成他的渲染?
【问题讨论】:
-
使用超时
setTimeout(function() { alert('finished drawing'); }, 200);
标签: javascript html canvas html5-canvas