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/
95 stars 27 forks source link

Not worked if image has onyone class #3

Open kosmom opened 10 years ago

kosmom commented 10 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 10 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(' '); };