0

I'm using Masonry and Infinite Scroll on my site to load in content. However, whenever it gets to the point where Infinite Scroll loads in the new content, the images overlap with each other. I've tried everything I can think of with nothing working. Any ideas?

HTML

<div id="container" class="js-masonry infinite-scroll" data-masonry-options='{ "isFitWidth": true }'>
    {% paginate blog.articles by 20 %}
      {% for article in blog.articles %}
          <div class="item">
            <div class="overlay">
                    <a href="{{ article.url }}">{{ article.content }}</a>
                </div>
          </div>
      {% endfor %}

      {% if paginate.next %}
        <div class="more"><a href="{{ paginate.next.url }}">More</a></div>
      {% endif %}
    {% endpaginate %}       
</div>

JS

$(window).load(function(){
  var $container = $('#container');
  $container.infinitescroll({
    navSelector  : '.more',    // selector for the paged navigation 
    nextSelector : '.more a',  // selector for the NEXT link (to page 2)
    itemSelector : '.item',     // selector for all items you'll retrieve
    loading: {
        finishedMsg: 'No more pages to load.',
        img: 'http://i.imgur.com/6RMhx.gif'
      }
    },
    // trigger Masonry as a callback
    function( newElements ) {
      var $newElems = $( newElements );
      $container.masonry( 'appended', $newElems, true );
        $container.masonry();
    }
  );
});
Eric Filkins
  • 329
  • 2
  • 8
  • 23
  • jsbin demo page might help dude – vsync May 24 '14 at 21:03
  • Can't really get that working either. http://jsfiddle.net/bb4C7/2/ – Eric Filkins May 24 '14 at 21:26
  • That did seem to fix the image sizes in the fiddle, however I'm not entirely sure what your second sentence is supposed to mean. – Eric Filkins May 26 '14 at 21:09
  • why do you think your images were all over each other? because you didn't give them any specified width! and you cannot give them width without them having a layout. this is basic CSS. – vsync May 27 '14 at 09:09

0 Answers0