1
/*!
2
* Packery layout mode PACKAGED v2.0.0
3
* sub-classes Packery
4
*/
5
6
!function(a,b){"function"==typeof define&&define.amd?define("packery/js/rect",b):"object"==typeof module&&module.exports?module.exports=b():(a.Packery=a.Packery||{}
7
,a.Packery.Rect=b())}
8
(window,function(){function a(b){for(var c in a.defaults)this[c]=a.defaults[c];for(c in b)this[c]=b[c]}
9
a.defaults={x:0,y:0,width:0,height:0}
10
;var b=a.prototype;return b.contains=function(a){var b=a.width||0,c=a.height||0;return this.x<=a.x&&this.y<=a.y&&this.x+this.width>=a.x+b&&this.y+this.height>=a.y+c}
11
,b.overlaps=function(a){var b=this.x+this.width,c=this.y+this.height,d=a.x+a.width,e=a.y+a.height;return this.x<d&&b>a.x&&this.y<e&&c>a.y}
12
,b.getMaximalFreeRects=function(b){if(!this.overlaps(b))return!1;var c,d=[],e=this.x+this.width,f=this.y+this.height,g=b.x+b.width,h=b.y+b.height;return this.y<b.y&&(c=new a({x:this.x,y:this.y,width:this.width,height:b.y-this.y}
13
),d.push(c)),e>g&&(c=new a({x:g,y:this.y,width:e-g,height:this.height}
14
),d.push(c)),f>h&&(c=new a({x:this.x,y:h,width:this.width,height:f-h}
15
),d.push(c)),this.x<b.x&&(c=new a({x:this.x,y:this.y,width:b.x-this.x,height:this.height}
16
),d.push(c)),d}
17
,b.canFit=function(a){return this.width>=a.width&&this.height>=a.height}
18
,a}
19
),function(a,b){if("function"==typeof define&&define.amd)define("packery/js/packer",["./rect"],b);else if("object"==typeof module&&module.exports)module.exports=b(require("./rect"));else{var c=a.Packery=a.Packery||{}
20
;c.Packer=b(c.Rect)}
21
}
22
(window,function(a){function b(a,b,c){this.width=a||0,this.height=b||0,this.sortDirection=c||"downwardLeftToRight",this.reset()}
23
var c=b.prototype;c.reset=function(){this.spaces=[];var b=new a({x:0,y:0,width:this.width,height:this.height}
24
);this.spaces.push(b),this.sorter=d[this.sortDirection]||d.downwardLeftToRight}
25
,c.pack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b];if(c.canFit(a)){this.placeInSpace(a,c);break}
26
}
27
}
28
,c.columnPack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b],d=c.x<=a.x&&c.x+c.width>=a.x+a.width&&c.height>=a.height-.01;if(d){a.y=c.y,this.placed(a);break}
29
}
30
}
31
,c.rowPack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b],d=c.y<=a.y&&c.y+c.height>=a.y+a.height&&c.width>=a.width-.01;if(d){a.x=c.x,this.placed(a);break}
32
}
33
}
34
,c.placeInSpace=function(a,b){a.x=b.x,a.y=b.y,this.placed(a)}
35
,c.placed=function(a){for(var b=[],c=0;c<this.spaces.length;c++){var d=this.spaces[c],e=d.getMaximalFreeRects(a);e?b.push.apply(b,e):b.push(d)}
36
this.spaces=b,this.mergeSortSpaces()}
37
,c.mergeSortSpaces=function(){b.mergeRects(this.spaces),this.spaces.sort(this.sorter)}
38
,c.addSpace=function(a){this.spaces.push(a),this.mergeSortSpaces()}
39
,b.mergeRects=function(a){var b=0,c=a[b];a:for(;c;){for(var d=0,e=a[b+d];e;){if(e==c)d++;else{if(e.contains(c)){a.splice(b,1),c=a[b];continue a}
40
c.contains(e)?a.splice(b+d,1):d++}
...
</html>