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.63k stars 354 forks source link

document.ready #18

Closed joshribakoff closed 10 years ago

joshribakoff commented 10 years ago

Looks like if other scripts like a jquery carousel fire after document.ready, and makes the page grow, some unloaded images are shown without being triggered until the user subsequently scrolls or resizes by at least 1px.

Possible solutions:

1) polling - every 250ms or so, see if the offsets of any arbitrary element has changed from its last known value 2) document.ready - wait until document.ready to bind blazy (I don't like it) 3) no change - leave it up to the users to explicitly call bLazy.revalidate

dinbror commented 10 years ago

I don't like number 1. Have you tried to pass the container of your carousel to bLazy (http://dinbror.dk/blog/blazy/#Inside)? I have no problems with number 2 or 3. If you're using jquery plugins and already depended on doc ready why not init bLazy there as well?

joshribakoff commented 10 years ago

Actually I think the simple thing to say here is that as a user of blazy, I should make sure my pages don't reflow by wrapping things like that carousel in a wrapper div & applying padding-bottom to force an aspect ratio & prevent reflow.