Equalizer
Equalizer is a MooTools plugin which analyzes a given set of elements and equalizers their height, taking into account the box model additions.
Download Debut Article Example Usage
Equalizer Class
var Equalizer = new Class({
initialize: function(elements) {
this.elements = $$(elements);
},
equalize: function(hw) {
if(!hw) { hw = 'height'; }
var max = 0,
prop = (typeof document.body.style.maxHeight != 'undefined' ? 'min-' : '') + hw; //ie6 ftl
offset = 'offset' + hw.capitalize();
this.elements.each(function(element,i) {
var calc = element[offset];
if(calc > max) { max = calc; }
},this);
this.elements.each(function(element,i) {
element.setStyle(prop,max - (element[offset] - element.getStyle(hw).toInt()));
});
return max;
}
});
Sample Usage
var equalizer = new Equalizer(elements).equalize('height');
Arguments
- elements: A collection of elements for which Equalizer should account for.
Methods
- equalize('height'|'width'): The method which will equalize either the height or width of an element.
