1

I'm using Paul Irish's Infinite-Scroll jQuery plugin in combination with Isotope. It seems to be working well except for one thing: the loading animation doesn't appear at all. Also, when you scroll down, the original pagination links are visible for a second, then they disappear, and a second or so later the next 'page' loads. Since it takes a second for the second 'page' to load, I would really like the loading animation to appear so that the user knows another page is loading. How can I force the pagination links to be invisible and the loading animation to appear? Below is the code I'm using:

// Isotope (with Infinite Scroll)
  $(function(){

    var $container = $('.isotope-container');

    $container.imagesLoaded(function(){
      $container.masonry({
        itemSelector: '.isotope-item',
        layoutMode: 'masonry'
      });
    });

    // filter items on button click
    $('#filters').on( 'click', 'button', function() {
      var selector = $(this).attr('data-filter');
      $container.isotope({ filter: selector });
    });

    $container.infinitescroll({
      navSelector  : '.pagination',    // selector for the paged navigation 
      nextSelector : '.next-post a',  // selector for the NEXT link (to page 2)
      itemSelector : '.isotope-item',     // selector for all items you'll retrieve
      loading: {
          finishedMsg: 'No more pages to load.',
          msgText: "loading new posts",
          img: 'http://i.imgur.com/6RMhx.gif',
          selector: "#loading-animation"
        }
      },
      // trigger Masonry as a callback
      function( newElements ) {
        // hide new items while they are loading
        var $newElems = $( newElements ).css({ opacity: 0 });
        // ensure that images load before adding to masonry layout
        $newElems.imagesLoaded(function(){
          // show elems now they're ready
          $newElems.animate({ opacity: 1 });
          $container.masonry( 'appended', $newElems, true ); 
        });
      }
    );

  });

EDIT: Upon inspecting the page, it looks like the loading div #infscr-loading is loading at the top of the page beneath the other elements. But I can't figure out how to get it to load at the bottom...

mcography
  • 1,081
  • 6
  • 19
  • 36
  • Need to see more of your code. How about a jsFiddle? – Macsupport Oct 03 '14 at 20:39
  • Here's the site: http://uic.slamagency.com/blog/ – mcography Oct 03 '14 at 20:39
  • just an FYI, in Safari, your site causes a download of masthead-teaser.ogv each time you load the page. Separate but you should fix that! Plus the site shows isotope is loaded but you state in the code, masonry? – Macsupport Oct 03 '14 at 20:51
  • Thanks, yeah I am still working on the video header. Yes, I'm using the masonry option of Isotope. – mcography Oct 03 '14 at 20:54
  • the masonry option in isotope is called '$container.isotope({ itemSelector: '.isotope-item', masonry: { columnWidth: 100 //or whatever other size you set } });' and your infinite scroll is '$container.isotope( 'appended', $newElems, true );'. Not '$container.masonry' – Macsupport Oct 03 '14 at 21:05
  • I changed it to `$container.masonry` but that broke the infinite scroll. Now when I scroll down, it loads one item in the left column and breaks the footer... – mcography Oct 03 '14 at 21:11
  • I would suggest making a jsFiddle with your code. Examining your site is frustrating since every time I reload the page, a new .ogv file is downloaded. Kinda done with that. ;-) – Macsupport Oct 03 '14 at 21:22
  • Sorry about that. I don't know how to make a jsFiddle with this code because it depends on the Wordpress posts... I took the .ogv video off. – mcography Oct 03 '14 at 21:29
  • Does anyone else have any ideas on how to fix this? – mcography Oct 08 '14 at 17:16

1 Answers1

0

I found this solution with the help of this post: http://wpquestions.com/question/show/id/8043.

#infscr-loading {

  position: fixed;

  bottom: 30px;

  left: 42%;

  z-index: 100;

  background: white;

  background: hsla( 0, 0%, 100%, 0.9 );

  padding: 20px;

  color: #222;

  font-size: 15px;

  font-weight: bold;

}
mcography
  • 1,081
  • 6
  • 19
  • 36