Infinite scroll & Isotope

5 replies · opened May 31, 2020

PPeadeyMay 31, 2020

Hello Team,

I tried everything, but with little success:

On my page is a list with tv productions. I use this code for initialization and add ing new item:


    var takePages = @take;

    $(document).ready(function(){

        const $container = $('#posts');
        var stopLoading = false;
        $("#footer").css("margin-top", 0);

        $($container).isotope();
        setTimeout( function(){
            $container.isotope('layout');
            SEMICOLON.initialize.resizeVideos();
            SEMICOLON.widget.loadFlexSlider();
            SEMICOLON.widget.masonryThumbs();
        }, 500 );

        $container.infiniteScroll({
            path: function() {
                const pageNumber = (this.loadCount + 1) * takePages;
                console.log("skip: " + pageNumber);
                var activeTag = $(".article-list #page-menu li.current").attr("data-tag");
                if (activeTag === undefined) activeTag = "";
                if(stopLoading) return null;
                return "@Url.Action("ArticleList", "Articles")" + "?skip=" + pageNumber + "&tag=" + activeTag;
            },
            history: false,
            checkLastPage: true
        });

        $container.on('load.infiniteScroll', function (event, response, path) {
            console.log(response);
            var $items = $(response).find('.entry');
            console.log("$items.length: " + $items.length);
            if ($items.length === 0) {
                stopLoading = true;
                return true;
            }
            // append items after images loaded
            $items.imagesLoaded(function () {
                $container.append( $items );
                $container.isotope( 'insert', $items );
                setTimeout( function(){
                    $container.isotope('layout');
                    SEMICOLON.initialize.resizeVideos();
                    SEMICOLON.widget.loadFlexSlider();
                    SEMICOLON.widget.masonryThumbs();
                }, 1000 );
            });
        });
    });

On first load I get always some strange gaps on top of the "articles". After adding more items via infinite scroll the gaps disappear and the new articles get these gaps again.

Do you have any suggestions for me to solve this problem?

The site is here:

http://s811333950.online.de/productions

Thank you.

Peter

PPeadeyMay 31, 2020

Also I'd like to make the video rezise not so obvious, the best solution would be to do it before the list is shown. I use these timeouts, but this doesn't help.

SSemicolon WebSTAFFJun 1, 2020

Hello,

The issue appears to be with the Isotope not getting initialized correctly on Load due to the Video being resized. This unfortunately, cannot be avoided. So we would recommend you to use the Bootstrap Embed Utility Classes for your Videos instead: https://getbootstrap.com/docs/4.5/utilities/embed/ as the Video Resize is handled by CSS. Also you wont need to call the SEMICOLON.initialize.resizeVideos(); Function anymore.

This should fix your issue. Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

PPeadeyJun 1, 2020

I found a really easy solution. I just changed the order of function calls:

$($container).isotope();
SEMICOLON.initialize.resizeVideos();
SEMICOLON.widget.loadFlexSlider();
SEMICOLON.widget.masonryThumbs();
$container.isotope('layout'); // this one at last!
PPeadeyJun 1, 2020

And no timeout anymore.

SSemicolon WebSTAFFJun 2, 2020

Hello,

Really Glad that your issues were resolved. Thanks for your Patience.

Yes, this makes the Grid Items realigned based on their New Heights.

Do let us know if we can help you with anything else or if you find any further issues with Canvas.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard