kaizau / Lazy-Load-Images-without-jQuery

Lazy load your images without the overhead of a library. IE7+, FF, Chrome.
http://kaizau.github.com/Lazy-Load-Images-without-jQuery/
94 stars 26 forks source link

Not worked if image has onyone class #3

Open kosmom opened 11 years ago

kosmom commented 11 years ago

if image has anyone class exception "lazy-load" - it's not shown, but image is loaded class lazy-loaded is not set after image load

try add any class name on demo page for example

img class="lazy-load test" src="demo/blank.gif" data-src-mobile="demo/mobile/1.jpg" data-src="demo/1.jpg"

kosmom commented 11 years ago

Not elegant but fast desition

image.onload = function() { var classes,key; classes=this.className.split(' '); for (key in classes){ if (classes[key]=='lazy-load')classes[key]='lazy-loaded'; } this.className = classes.join(' '); };