问题
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*/});
});
回答2:
You can use onInit
event for callback function. See more
Example code:
$('.your-class-name').infiniteScroll({
// options
path: '.next.page-numbers',
append: '.post',
history: false,
status: '.page-load-status',
button: '.page-load-more',
loadOnScroll: false,
elementScroll: true,
hideNav: '.post-pagination',
onInit: function() {
this.on( 'append', function() {
$('.your-item-class-name').magnificPopup({
/* magnificPopup options here */
});
});
}
});
来源:https://stackoverflow.com/questions/23761192/magnific-popup-and-infinite-scrolling