UNPKG

dzxstatic

Version:

The static files of Discuz! X

1 lines 1.08 kB
function waterfall(t){var e=1,i=void 0===(t=void 0===t?{}:t).totalwidth?0:t.totalwidth,a=void 0===t.totalheight?0:t.totalheight,o=void 0===t.parent?$("waterfall"):t.parent,l=void 0===t.container?$("threadlist"):t.container,n=void 0===t.maxcolumn?0:t.maxcolumn,h=void 0===t.space?10:t.space,d=void 0===t.index?0:t.index,r=void 0===t.tag?"li":t.tag,f=void 0===t.columnsheight?[]:t.columnsheight;function v(){var t=0,e=0;if(f.length>0){t=Math.min.apply({},f);for(var i=0,a=f.length;i<a;i++)if(f[i]==t){e=i;break}}return{value:t,index:e}}var s={value:0,index:0},g=[],x=0;if((g=o.getElementsByTagName(r)).length>0){if(e=Math.floor((l.offsetWidth-h)/(g[0].offsetWidth+h)),n&&e>n&&(e=n),e||(e=1),f.length!=e){f=[];for(var p=0;p<e;p++)f[p]=0;d=0}i=(x=g[0].offsetWidth+h)*e-h;p=d;for(var u=g.length;p<u;p++)s=v(),g[p].style.position="absolute",g[p].style.left=x*s.index+"px",g[p].style.top=s.value+"px",f[s.index]=f[s.index]+g[p].offsetHeight+h,a=Math.max(a,Math.max.apply({},f)),d++;o.style.height=a+"px",o.style.width=i+"px"}return{index:d,totalwidth:i,totalheight:a,columnsheight:f}}