[whatwg] Canvas and Image problems

Schalk Neethling schalk at ossreleasefeed.com
Mon May 24 02:14:11 PDT 2010


Hi Marius,

 

That is actually a pretty good idea. You can still have your other code run
at document ready, but then do the drawing to canvas once the image is
ready. Best of both ;)

 

Thanks,

Schalk

 

From: Marius Gundersen [mailto:gundersen at gmail.com] 
Sent: Monday, May 24, 2010 4:49 AM
To: Schalk Neethling
Cc: whatwg at lists.whatwg.org
Subject: Re: [whatwg] Canvas and Image problems

 

You could also add a listener to the image to check that it actually loads:

 

$(document).ready(function() {

      var image = $("#cat").get(0);

      image.onload = function(e){

          var cv = $("#img_container").get(0);      

          var ctx = cv.getContext('2d');

      

          ctx.drawImage(image, 0, 0);

            };

});

On Sun, May 23, 2010 at 10:30 PM, Schalk Neethling
<schalk at ossreleasefeed.com> wrote:

Jip, using $(window).load() works perfect.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100524/43c82c2f/attachment.htm>


More information about the whatwg mailing list