I'm working on this website
The products on the center and right column
are in a masonry
container.
The problem I have is that If I apply the lazy load
plugin to it, since it has different heights the images overlaps the others container:
This is how it looks (when not using lazy load):
Any ideas on how to make it work?
This is my script:
Posts.prototype.onBeforeRender = function() {
var container;
/* log("Msnry!"); */
container = document.querySelector('#products_tmpl');
App.msnry = new Masonry(this.el, {
itemSelector: '.product',
columnWidth: container.querySelector('.column-width'),
gutter: container.querySelector('.gutter-sizer'),
transitionDuration: '0.1s'
});
return delay(1000, this.reRenderLayout);
};
jQuery(function() {
jQuery("img.lazy").lazyload({
effect : "fadeIn"
});
});
Post.prototype.returnImageForPost = function(maxSize) {
var image_url, thumbnail_images;
image_url = "";
if (this.model.get("thumbnail_images") != null) {
thumbnail_images = this.model.get("thumbnail_images");
thumbnail_images = _.sortBy(thumbnail_images, function(item) {
return -item.width;
});
_.each(thumbnail_images, function(thumb) {
if (thumb.width >= maxSize) {
return image_url = thumb;
}
});
}
return image_url;
};
This is the markup of each item:
<div class="product">
<div class="image">
<img class="lazy" data-original="<%= post_item.image_url.url %>">
</div>
<div class="obra_meta">
<span class="nombre_artista"><%= item.title %></span>
<span class="nombre_obra"><%= title %></span>
</div>
</div>