jQuery masonry with Wordpress and imagesLoaded -


i using jquery masonry on wordpress theme working on. after struggling getting work while found this:

 <script type="text/javascript"> jquery(function () { jquery('#masonry-wrap').masonry({ itemselector: '.masonry-box', columnwidth: 283 }); }) </script> 

seems working fine me... checking site in chrome , safari pushes bottom of containing elements following elements...

now read somewhere, can solved using imagesloaded plugin , code found here: http://masonry.desandro.com/demos/images.html - since absolutely terrible jquery, i'm having little difficulty getting work.

could me incorporate code using , works (the 1 above)?

any appreciated!! julian

i think should work you;

// masonry trigger var $container = jquery('#masonry-wrap'); $container.imagesloaded( function(){ $container.masonry({ itemselector: '.masonry-box', columnwidth: 283 }); }) 

remember use latest version of imagesloaded, had problem while , reason version out of date.

edit

that said, use imagesloaded when i've loaded in new content via ajax , using relayout method. if run masonry on $window.load() after images loaded should run fine too.

(function($){ $(window).load(function() { // masonry trigger var $container = $('#masonry-wrap'); $container.masonry({ // options itemselector: '.masonry-box', columnwidth: 283 }); }); })(jquery); 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -