luis-almeida / unveil

A very lightweight jQuery plugin to lazy load images
4.15k stars 675 forks source link

I found an issue when using unveil with isotope #89

Open rotaercz opened 9 years ago

rotaercz commented 9 years ago

Isotope (http://isotope.metafizzy.co/) is a plugin that can move the images around and also hide and show images based on filters and it seems unveil has trouble knowing when an image is on screen when using it. It would be great if you could support it.

Also is there a way to make it work?

brettmhoffman commented 9 years ago

This is not a fix, but a temporary workaround that may or may not work for your situation.

I am using Isotope (with a variety of filters and quick search) alongside Unveil and it seems that it only loads the images once you scroll, once they appear in the viewport. I'm currently just triggering Unveil on all the not-yet-loaded images in Isotope's layoutComplete function.

$container.isotope('on', 'layoutComplete', function() {
    // Trigger Unveil lazy load on items after filtering
    $('.element img').trigger('unveil');
});

Not the perfect solution, but at least there won't be empty images.