Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save codernik/2e44addd1a2fd889a0f0e02c661763a6 to your computer and use it in GitHub Desktop.
Save codernik/2e44addd1a2fd889a0f0e02c661763a6 to your computer and use it in GitHub Desktop.
Function to add popup-left class on last isotope item after filter is applied
$container.on( 'layoutComplete',
function( event, laidOutItems ) {
console.log( 'Isotope layout completed on ' + laidOutItems.length + ' items' );
var last_x = false;
jQuery(laidOutItems).removeClass('popup-left');
jQuery(laidOutItems).each(function(i, v){
console.log(i);
var current_x = jQuery(this.element).offset().left;
if( last_x !== false && last_x > current_x && typeof laidOutItems[i-1] !== 'undefined'){
jQuery(laidOutItems[i-1].element).addClass('popup-left');
}
last_x = current_x;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment