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';
http://jsfiddle.net/FxrSa/14/
I want to show the alert after the canvas finished his rendering. But the alert show before the image is drawn.
How can I wait for the GUI thread to finish his rendering?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…