Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combination with masonry, infinitescroll and gifs #280

Closed
MrMooky opened this issue Feb 24, 2019 · 4 comments
Closed

Combination with masonry, infinitescroll and gifs #280

MrMooky opened this issue Feb 24, 2019 · 4 comments

Comments

@MrMooky
Copy link

MrMooky commented Feb 24, 2019

I'm having some trouble with posted gifs in combination with imagesloaded and masonry. Basically, this happens quite often:

screenshot 2019-02-24 at 14 51 03

screenshot 2019-02-24 at 14 50 48

The initial loading seems to work fine, but as soon as the second or third page loads with infinite-scroll, the gifs are cut off sometimes. How could I prevent this?

How my code looks like:

$.getScript("https://webdata.friendships.me/js/infinite-scroll.min.js", function() {
            $.getScript("https://webdata.friendships.me/js/masonry.js", function() {

                $grid = $('.timeline__posts__container .posts').masonry({
                    itemSelector: 'none',
                    columnWidth: '.grid__col-sizer',
                    gutter: '.grid__gutter-sizer',
                    percentPosition: true,
                    stagger: 30,
                    visibleStyle: { transform: 'translateY(0)', opacity: 1 },
                    hiddenStyle: { transform: 'translateY(100px)', opacity: 0 },
                });

                // get Masonry instance
                var msnry = $grid.data('masonry');

                // initial items reveal
                $grid.imagesLoaded( function() {
                    $grid.removeClass('are-images-unloaded');
                    $grid.masonry( 'option', { itemSelector: '.timeline__post' });
                    var $items = $grid.find('.timeline__post');
                    $grid.masonry('appended', $items);
                });

                $grid.infiniteScroll({
                    path: '.nextPage',
                    append: '.single__post',
                    outlayer: msnry,
                    status: '.page-load-status',
                    history: false,
                    hideNav: 'ul.pagination'
                });

            });
        });
@desandro
Copy link
Owner

Thanks for reporting this issue. Do you have a live URL I could take a look at?

@MrMooky
Copy link
Author

MrMooky commented Feb 26, 2019

You can see it on https://friendships.me. You can login with User and Pass 'desandro'.

@desandro
Copy link
Owner

Thanks for that. I didn't see the overlap in Chrome or Firefox, but I did see it in Safari. In which case, look at metafizzy/infinite-scroll#671 for some related solutions

@MrMooky
Copy link
Author

MrMooky commented Mar 1, 2019

Ah, great. I'll check if any workaround mentioned there works. Thanks a lot for checking and your feedback. :)

@MrMooky MrMooky closed this as completed Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants