-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjquery.equalheights.js
39 lines (34 loc) · 1.08 KB
/
jquery.equalheights.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*global jQuery */
(function ($) {
/* A better equal heights plugin for jQuery
* Version 0.1
*
* Copyright (c) 2011 Luminosity Group
*/
$.fn.equalheights = function (options) {
var container = this, defaults, settings;
defaults = {
selector: '.column',
animate: false,
duration: 1000
};
/* Merge options with defaults */
settings = $.extend(true, {}, defaults, options);
return $(container).each(function () {
var target = 0, height;
$(settings.selector, this).each(function () {
height = $(this).height();
if (height > target) {
target = height;
}
});
$(settings.selector, this).each(function () {
if (settings.animate) {
$(this).animate({'height': target}, settings.duration, 'linear');
} else {
$(this).css({'height': target});
}
});
});
};
}(jQuery));