Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 10, 2015 17:12
Show Gist options
  • Save trys/5150c92497a2260694d3 to your computer and use it in GitHub Desktop.
Save trys/5150c92497a2260694d3 to your computer and use it in GitHub Desktop.
Match column heights
MatchColumnHeights: function( group, width ) {
var tallest = 0,
gCount,
subGroup,
splitGroup,
i;
splitGroup = [];
while ( group.length > 0 ) {
splitGroup.push( group.splice( 0, width ) );
}
for ( gCount = 0; gCount < splitGroup.length; gCount++ ) {
tallest = 0;
subGroup = splitGroup[ gCount ];
$( subGroup ).css('height','auto');
for ( i = 0; i < subGroup.length; i++ ) {
tallest = Math.max( tallest, $( subGroup[ i ] ).outerHeight() );
}
$( subGroup ).css( 'height', tallest + 'px' );
}
}
ProjectNamespace.MatchColumnHeights( $( '.layout--1of3' ), 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment