moxiecode / moxie

Pollyfills for XHR2 and File API
GNU Affero General Public License v3.0
483 stars 134 forks source link

Update Image.js #156

Closed elantion closed 8 years ago

elantion commented 8 years ago

Create canvas element seem like not a sync behavior. So we need a callback after create a canvas.

elantion commented 8 years ago

Oh, there is a 'embedded' event trigger after embed. I can use it like this:

image.embed(parentEl);
image.addEventListener('embedded', function(){
        var imageEl = parentEl.getElementsByTagName('img') || parentEl.getElementsByTagName('canvas');
    });

Sorry I didn't read document carefully.