Infinite Scroll Masonry. Cant find a working callback.
-
Hi!
Im trying to get Infinite Scroll to work with Masonry, but second pageload is outside masonry. I have tried every callback I can find online, but nothing seems to be working.
This is my .js for Masonry:
(function( $ ) { "use strict"; $(function() { //set the container that Masonry will be inside of in a var var container = document.querySelector('.js-masonry'); //create empty var msnry var msnry; // initialize Masonry after all images have loaded imagesLoaded( container, function() { msnry = new Masonry( container, { itemSelector: '.feed-item' }); }); }); }(jQuery));
I enqueue it like this:
wp_enqueue_script( 'masonry' ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'masonryInit', get_stylesheet_directory_uri().'/js/masonry.js', array( 'masonry', 'jquery' ) );
The Callbacks mostly looks like this, but not working:
var $newElems = $( newElements ).css({ opacity: 0 }); $newElems.imagesLoaded(function(){ $newElems.animate({ opacity: 1 }); $('.js-masonry').masonry( 'appended', $newElems, true ); }
What am I doing wrong?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Infinite Scroll Masonry. Cant find a working callback.’ is closed to new replies.