Skip to content Skip to sidebar Skip to footer

Masonry.js – Items Not Moving Vertically

I don't know how to explain this without an image. Please take a look. I'm fairly sure I've done everything correctly, but for some reason the divs are not moving down. Here's my c

Solution 1:

This has to do with the timing of the images being loaded. Take a look a the ImageLoaded plugin, I believe it is actually baked into Isotope, Masonry's big brother. Take a look at this: http://isotope.metafizzy.co/appendix.html

Further Explanation:

The page loads and executes the script before the images have time to download, this then causes the masonry objects to think they have a height of 0. There are a few ways to fix it, the above mentioned is the quick and relatively painless way, and the other is to actually tell every image tag exactly how large it is. Now... that has an inherit problem if you allow the masonry objects to change width, since you have no idea what width the container object is going to be when it renders, thus making the height indeterminable, outside of javascript... which loops us back around to option one.

What I generally do is put some variety of 'cover' over the masonry wrapper with a loading gif inside it, and when the images loaded plugin finishes and the masonry is rendered, you fade it out. This will prevent a weird moment prior to the script executing where images may finish loading and start rendering in a single, giant column, then moving violently into place.

Post a Comment for "Masonry.js – Items Not Moving Vertically"