bbc / Imager.js

Responsive images while we wait for srcset to finish cooking
Apache License 2.0
3.84k stars 224 forks source link

Fixing IE10 issues with lazy load #99

Closed benjambles closed 9 years ago

benjambles commented 10 years ago

IE10 returns undefined for naturalWidth until the image supplied in the src has loaded, rather than the 0 defined in the spec. The 'naturalWidth' in (new Image) gets around this.

It also adds a width and height to the lazy loaded images, that the this.gif.removeAttribute fix further up doesn't fix. I've removed the attributes again once the image has had its src swapped and this fixes the issue.

Lazy Loading now works in IE10.

p.s. Thanks for the script, it's been pretty useful!

thom4parisot commented 9 years ago

Thanks @benjambles :-)

I have added some tests to make sure it will not break in the future.

benjambles commented 9 years ago

Nice one, thanks @oncletom