Magnific popup and infinite scrolling

2019-08-10 09:10发布

问题:

I have a tumblr blog whit infine scrolling and magnific-popup to visualize the image.

When I scroll to the bottom and load new posts, magnific-popup doesn't works in the new posts loaded but only in the old.

If I try to go to "page-2" manually everything works.

Is there a way to reload magnific-popup on load posts or something similar?

Many thanks

回答1:

All you need to do is call the .magnificPopup method on the new elements when infinitescroll is loaded, this way:

$YOUR_CONTAINER.infinitescroll({
    navSelector:  ".Pagination",
    nextSelector: ".Pagination-next",
    itemSelector: ".Post"
}, function( newElements ) {
    $(newElements).magnificPopup({/*your options here*/});
});