!function(a,b){"function"==typeof define&&define.amd?define("waterfall",(function(){return b})):"object"==typeof module&&module.exports?module.exports=b:a.waterfall=b}(this,(function(a){function b(a){return window.getComputedStyle(a)}function c(a,c){return parseFloat(b(c)["margin"+a])||0}function d(a){return parseFloat(a)+"px"}function f(a){return parseFloat(a.style.left)}function g(a){return parseFloat(b(a).width)}function i(a){return function(a){return parseFloat(a.style.top)}(a)+function(a){return parseFloat(b(a).height)}(a)+c("Bottom",a)}function j(a){return f(a)+g(a)+c("Right",a)}function k(a){a=a.sort((function(a,b){return i(b)-i(a)||f(b)-f(a)}))}function m(a,b,c){a.style.position="absolute",a.style.top=d(b),a.style.left=d(c)}function o(a,b){m(b,a.style.top,j(a)+c("Left",b))}function p(a,b){m(b,i(a)+c("Top",b),f(a))}function r(b,c){return j(b[c-1])+g(b[c])<=g(a)}if("string"==typeof a&&(a=document.querySelector(a)),null!=a){var s=a.children;s.length&&function(a){m(a,0,c("Left",a))}(s[0]);for(var t=1;t