This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from Codeinwp/development
Fixed Issue with Jetpack Infinite scroll
- Loading branch information
Showing
2 changed files
with
43 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,46 @@ | ||
|
||
//Masonry init | ||
jQuery(function($) { | ||
var $container = $('.grid-layout'); | ||
$container.imagesLoaded( function() { | ||
$container.masonry({ | ||
itemSelector: '.hentry', | ||
isAnimated: true, | ||
animationOptions: { | ||
duration: 300, | ||
easing: 'linear', | ||
} | ||
}); | ||
}); | ||
|
||
var $container; | ||
|
||
function nsc_trigger_masonry() { | ||
// don't proceed if $grid has not been selected | ||
if ( !$container ) { | ||
return; | ||
} | ||
// init Masonry | ||
$container.imagesLoaded( function() { | ||
$container.masonry({ | ||
itemSelector: '.hentry', | ||
isAnimated: true, | ||
animationOptions: { | ||
duration: 300, | ||
easing: 'linear', | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
$(window).load(function(){ | ||
$container = $('.grid-layout'); // this is the grid container | ||
|
||
nsc_trigger_masonry(); | ||
|
||
// Triggers re-layout on infinite scroll | ||
$( document.body ).on( 'post-load', function () { | ||
|
||
// I removed the infinite_count code | ||
var $selector = $('.infinite-wrap'); | ||
var $elements = $selector.find('.hentry'); | ||
|
||
/* here is the idea which is to catch the selector whether it contain element or not, if it's move it to the masonry grid. */ | ||
if( $selector.children().length > 0 ) { | ||
$container.append( $elements ).masonry( 'appended', $elements, true ); | ||
nsc_trigger_masonry(); | ||
} | ||
|
||
}); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters