I'm trying to crossfade images using the canvas drawImage() method. I'm using jQuery to fadeIn() and fadeOut() the canvas.
Here's the code:
$("#c").fadeOut(800,function() {
//aw and ah are calculated here
ctx = canvas.getContext('2d');
ctx.drawImage(img1, 0, 0, aw, ah);
$("#c").fadeIn(400);
});
c is the id of the canvas. The problem is - if img1 has been viewed already, the fadeOut happens after the image has changed, i.e. first the image changes, and then the canvas fades out and back in. Am I missing something? Thanks