Created
March 23, 2018 10:48
-
-
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
This file contains hidden or 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
$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