Description
I'm using this plugin to lazy load <img>
and background images. I use the afterLoad event to add a class to the element so that I can trigger some CSS animation. This works fine most of the time (about 90% of the time), but here and there the event simply doesn't get triggered at all on some elements, even after successfully loading the image.
So far, this seems to be only an issue with background images.
This is the code I'm using:
$('.lazy').Lazy({
threshold: $(window).width() > 767 ? 500 : 50,
afterLoad: function(element) {
element.addClass('lazy-loaded');
}
});
Update
I wanted to a quick ugly workaround with beforeLoad and realized beforeLoad also doesn't get triggered here and there. It seems like all the events/callbacks aren't working properly with background images.
I also noticed that when the issue happens and I have a full row of multiple elements with background images, the full row won't have the events triggered. It seems to be an issue related to the viewport more than a single element.