eqheights
Version:
Give all elements in a group of elements at least the height of the tallest element within that group
1 lines • 1 kB
JavaScript
!function(e,t){if("function"==typeof define&&define.amd)define(["exports","module"],t);else if("undefined"!=typeof exports&&"undefined"!=typeof module)t(exports,module);else{var r={exports:{}};t(r.exports,r),e.eqheights=r.exports}}(this,function(e,t){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function n(e){return e.reduce(function(e,t){var r=t.offsetHeight;return r>e?r:e},0)}function o(e,t){e.forEach(function(e){e.style.minHeight=t})}function i(e){var t=n(e)+"px";o(e,t)}function u(e){function t(){o(c,"")}var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],u=n.autorun,f=void 0===u?!0:u;if("string"!=typeof e&&!(e instanceof NodeList&&e.constructor===NodeList))throw new TypeError("eqheights expects either a selector string or a NodeList as input.");var s="string"==typeof e?document.querySelectorAll(e):e,c=[].concat(r(s));return f&&i(c),{clear:t,recalc:function(){t(),i(c)}}}t.exports=u});