infinite-scroll icon indicating copy to clipboard operation
infinite-scroll copied to clipboard

Using infinite scroll with Masonry and Flexslider

Open genethic opened this issue 12 years ago • 4 comments

I'm using masonry jQuery plugin and loading content with infinite scroll, and in this content a I have differents FlexSlider slideshows. When I use the infinite scroll, the slider doesn't show correctly, the next post is positioned just in the same place, like masonry doesn't load the flexslider post.. I suppouse that the FlexSlider jQuery doesn't load well with infinite scroll.

Like you can see, I append new elements to Masonry after load infinete scroll, and imageLoader and prettyPhoto, too. I have try to doing something like this with FlexSlider, but nothing. How can I achieve this? Help please! This is the code:

FlexSlider:

jQuery(document).ready(function ($) {
    $(\'#' . $id . '\').flexslider({
    namespace: "flex-",  
    selector: ".slides > li",
    animation: "' . $animation_effect . '",
    direction: "horizontal",  
    animationLoop: true,  
    slideshow: true,  
    slideshowSpeed:' . $slideshow_speed . ',
    animationSpeed:' . $animation_speed . ',
    pauseOnAction: true,  
    pauseOnHover: true,  
    useCSS: true,  
    touch: true,  
    video: true,  
    controlNav: false,  
    directionNav: false, 
    prevText: "",  
    nextText: "",
    });});

Masonry + Infinite scroll:

jQuery(document).ready(function($){
var $container = $('#masonry-content');
$container.imagesLoaded(function(){
              $container.masonry({
                itemSelector: 'article',
                columnWidth: 1,
              });
            });


        $container.infinitescroll({
          navSelector  : '.archive-nav',    // selector for the paged navigation 
          nextSelector : '.archive-nav .next',  // selector for the NEXT link (to page 2)
          itemSelector : '#masonry-content article',     // selector for all items you'll retrieve
          loading: {
              finishedMsg: 'No more pages to load.',
              img: 'http://i.imgur.com/6RMhx.gif',
              msgText:'',
            }
          },
          // 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 ); 
               $("a[rel^='prettyPhoto']").prettyPhoto();
               $('#slider-74').flexslider();
              });
          });
        <?php } ?>
    });

genethic avatar Feb 11 '14 10:02 genethic

Do you have an example we can see?

lukeshumard avatar Feb 11 '14 11:02 lukeshumard

In this web you can see. Just after the first loading, you will see the slider, it works, but it is bad positoned, I suppose because masonry don't take it's height.

genethic avatar Feb 11 '14 12:02 genethic

I'm stuck on the same problem. I want to use the freewall masonry with the infinity scroll. Adding new items and scrolling works good, but I do not figure out how to call a refresh on the freewall masonry. If I do like genethic as a callback function, firebug tells me, "SyntaxError: missing : after property id" before the newElements. You can see it in action at: http://michael-golinski.de/wordpress/

martinb07 avatar Feb 21 '14 14:02 martinb07

Thanks for reporting this issue. Sorry to hear you're having trouble with Infinite Scroll.

Infinite Scroll v3 is out!. It's an all new re-write, so take a look at how to upgrade from v2.

Infinite Scroll v3 has direct support for Masonry. I recommend upgrading to v3. Please open a new issue if you run into trouble with Infinite Scroll v3. 🌈🐻

desandro avatar Jun 26 '17 17:06 desandro