Last active
June 18, 2018 03:55
-
-
Save cjwebdev/3fe63af07f1910a5836f to your computer and use it in GitHub Desktop.
jQuery: Equal Column Heights Plugin
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
/* | |
* EqCol - Equalise Grid column heights | |
* Requires "Responsive Page Modes Plugin" | |
* http://cjweb.com.au | |
* Version: 1.0.0 (11-NOVEMBER-2014) | |
* Dual licensed under the MIT and GPL licenses. | |
* | |
* USAGE INSTRUCTIONS | |
* $('.grid').eqCol(); // <ul class="grid" data-eqcol-mode="medium,large" data-eqcol-item=".grid-col" > | |
* | |
* | |
*/ | |
(function ($) { | |
$.fn.eqCol = function() { | |
return this.each(function() { | |
var container = $(this); | |
var item = $(this).attr('data-eqcol-item'); | |
var modes = $(this).attr('data-eqcol-mode'); | |
modes = modes.replace(/ /g,''); | |
modes = modes.split(','); | |
//Reset | |
$(item, container).removeAttr('style'); | |
//Set if required | |
if ($.inArray($.responseMode.get(), modes) != -1) { | |
//Equalise | |
maxcol = 0; | |
$(item, container).each(function(index) { | |
if ($(this).height() > maxcol) | |
{ | |
maxcol = $(this).height(); | |
} | |
}); | |
$(item, container).height(maxcol); | |
} | |
}); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment