metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.13k stars 315 forks source link

How can I make sure a grid align is always aligned top? #527

Closed ooozydev closed 5 years ago

ooozydev commented 5 years ago

I'm trying to figure out how to always align the items to the top, as in right on the edge to the next element. It fixes itself sometimes, and other times not.

Test case: http://dev.oozy.me/el/

image

It should look like:

image

Which does,s sometimes.

jQuery:

    function initIsotope() {
      var $grid = $(".file-list").packery({
        itemSelector: "li",
        gutter: 0,
        percentPosition: false
      });

      $grid.imagesLoaded().progress(function() {
        $grid.packery();
      });
    }
$(document).ready(function() {
  initIsotope();
});

What am I doing wrong?

desandro commented 5 years ago

If you're dynamically adding content, you'll need to trigger initIsotope after that content has been added to the page, not just on document.ready.