dkern / jquery.lazy

A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
http://jquery.eisbehr.de/lazy
Other
1.02k stars 237 forks source link

Lazyload invisible images #211

Closed ZoeFken closed 5 years ago

ZoeFken commented 5 years ago

Hello, first of all ty for creating and maintaining something like this.

I do have a issue that i am chewing on and unable to figuring out why it does not work.

I have a masonry layout (by desandro) where the lazyload is working as intended. When i click a image i have a CSS lightbox by (https://github.com/TheLastProject/CSSBox). I use this css lightbox so i can add extra fields inside the lightbox in an easy and maintanable way.

Now my issue is that all the images inside the lightbox area are allready loaded in (they are in the viewport). They are css wise not visible (visibility: hidden;). When i try to use the visibleOnly: true i don't seem to get it working at all. They either all load in or none.

dkern commented 5 years ago

The visibileOnly option has it downsites and if basically just a .id('visible') check of jQuery. This may have issues in some browsers on different uses.

Actually i have no idea how to fix this issue for you. It's not a bug, its just as you said, the images are loaded because they in the viewport even if they are not visible. Many lightboxes does have own lazy-loading implemented, solving this issue. But CSSBox of course did not.

Maybe build yourself something that creates the lightbox instance on the first click of the image?! No idea otherwise for the moment.