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 356 forks source link

Images no longer lazy load after 1.8.0 #113

Closed dbirkbeck closed 7 years ago

dbirkbeck commented 7 years ago

If a container extends outside of the view range, all images within the container (including images outside of the viewport) are now loaded. To fix this, the container must be bounded by the viewport (plus offset). I'm new to GitHub so I'll post the fix in this message below as well as try to submit a pull request.

                var containerRectWithOffset = {
                    top: ((containerRect.top - options.offset) < _viewport.top) ? containerRect.top - options.offset : _viewport.top,
                    right: ((containerRect.right + options.offset) > _viewport.right) ? containerRect.right + options.offset : _viewport.right,
                    bottom: ((containerRect.bottom + options.offset) < _viewport.bottom) ? containerRect.bottom + options.offset : _viewport.bottom,
                    left: ((containerRect.left - options.offset) < _viewport.left) ? containerRect.left - options.offset : _viewport.left
                };
dinbror commented 7 years ago

Thanks @dbirkbeck - Released in v.1.8.2. Some of your chevrons were wrong