I have been trying to piece together masonry and moo tools lazyload however they both dont seem to go very well together although it possibly could just be because I am slightly useless at coding!
The masonry works on this page.
However when I try to put it together with lazyload it seems to totally mess up. Does anyone have any idea how to implement both plugins together?
I have spent 6 days trying to figure it out and this is my final hope ha!
Thanks
softk5 answer wasn't working for me and causing freeze on the most of browser. Here is my following code and its working for me.
I posted the same answer on other same issues article. If you have the problem images get overlapped, I found the solution at the site below, although it is in Japanese.
http://www.webdesignleaves.com/wp/jquery/1340/
Hope this will help.
The point is use following;
HTML
jQuery
The reason is that Masonry needs to know the dimensions of the image in order to lay out the items properly. However LazyLoad delays loading the image until the image is in the viewport, meaning that the image will have no dimensions (or have the dimensions of the dummy/placeholder image you set as the img src).
may be someone will have problems too , hope help .
to make it work with wordpress photoswipe-masonry theme is impossible without plugin modification.
next is related to this modification and just with masonry
a) lazyload use data-original="xxx" attribute to set image url . NOT src . to you need place some placeholder . may be 1x1 pixel that will be loaded without lazyload .
b) this placeholder need cover ALL space for future lazyloaded image , OR masonry will make all images visible as lazyloading view . it's because before images loaded it have zero size 0px x 0px . and all images fit in visible area before loaded . Lazyload count all as visible and load all .
to arrange ALL space for future image you need set
style="width:xxpx;height:xxpx;"
just width="xx" and height="xx" is not enough
so image placeholder became as :
then apply lazy load normal way , and masonry . in any order .
Important - masonry update width to it's column size , BUT not height , so if your column size = 50px , then you need calculate heigh of placeholder
new_height = 50 / actual_width * actual_height;
so for wordpress theme need
.....
....
then add new lines below masonry init
Recently, I gotta solve this for one of my website. I have tried a couple of ways and it seems working.
1. First Method:
http://jsfiddle.net/7vEJM/8/
This method is good, but it has one disadvantage. The grid layout might not be kept the same since the time of masonry.reload() depends on each image's load time (i.e. the one supposed to be loaded first might only finish later)
2. Second Method: Look at sites like pinterest, i think, it does not follow the first method, because they have the container boxes arranged even before any image loaded, therefore, what I tried to achieve is to display just the boxes with same ratio as the images. The steps are:
{image1: [300,400],image2: [400,500]}
)http://jsfiddle.net/nathando/s3KPn/4/
[Edited to add the jsfiddle for the second method]
Notice:
/*display: none */
and commentdisplay: block
for#container.fluid .item img
Cheers