dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.62k stars 355 forks source link

Bugs of 'loadInvisible'. #95

Closed chenkun24 closed 8 years ago

chenkun24 commented 8 years ago

When an element is hidden, 'getBoundingClientRect' does not work, and images will load when the page was loaded. Is it a bug? Is there any way to load hidden images while scrolling?

dinbror commented 8 years ago

hey @chenkun24

Yes thats how getBoundingClientRect works. Instead of adding display:none to your container/image you could maybe use visibility: hidden or set height and width to zero? In that way it wont load on page load but first when it's inside the viewport.

dinbror commented 8 years ago

Closing it since it's a browser behavior. The browser doesn't bother rendering hidden items at all why getBoundingClientRect etc just returns zero