Skip to content

Instantly share code, notes, and snippets.

@artygrand
Created June 21, 2016 12:30
Show Gist options
  • Save artygrand/fd6b8dadf69cb1dacb49c65d113aef1e to your computer and use it in GitHub Desktop.
Save artygrand/fd6b8dadf69cb1dacb49c65d113aef1e to your computer and use it in GitHub Desktop.
Equal heights for catalog grid
Object.defineProperty(Array.prototype, 'chunk', {value: function(n) {
return Array.from(Array(Math.ceil(this.length/n)), (_,i)=>this.slice(i*n,i*n+n));
}});
$(window).load(function(){
$.each($('.hit-info a').toArray().chunk(4), function(index, els) {
var maxheight = 0;
$(els).each(function(){
var height = $(this).outerHeight()
if(height > maxheight) {
maxheight = height;
}
}).css('min-height', maxheight);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment