$ (window). Load (function (e) {
Waterfall ();
var dataint={' data ': [{' src ': ' 1.jpg '},{' src ': ' 2.jpg '},{' src ': ' 3.jpg '},{' src ': ' 4.jpg '}]};
$ (window). Scroll (function () {
if (checkscrollside) {
var $main =$ ("#main");
$.each (Dataint.data,function (i) {
var $oPin =$ (' <div> '). addclass ("pin"). AppendTo ($main);
var $oBox =$ (' <div> '). addclass ("box"). AppendTo ($oPin);
var $oImg =$ (' ');
$oImg. attr ("src", './images/' +$ (This). attr ("src")). AppendTo ($oBox);
});
Waterfall ();
};
});
function Waterfall () {
var $main =$ ("#main");
var $box =$ (". box");
var $pin =$ (". Pin");
var $img = $pin. Find ("img");
var pinw= $pin. EQ (0). Outerwidth ();
var ww=$ (window). width ();
var col=math.floor (WW/PINW);
$main. css ({"width": col*pinw, "margin": "0 Auto"});
var pinarr=[]; Defining an array does not require a dollar symbol
$pin. Each (function (i) {
var pinh= $pin. EQ (i). Outerheight ();
if (I<col) {
Pinarr[i]=pinh;
}else{
var minh=math.min.apply (Null,pinarr);
var index=$.inarray (Minh,pinarr);
var pinl= $pin. EQ (index). Position (). Left; Use. Offset (). Left will have 15 deviations
$ (this). css ({"position": "Absolute", "top": MinH, "left":p inl});
pinarr[index]+= $pin. EQ (i). Outerheight ();
}
});
}
function Checkscrollside () {
var $pin =$ (". Pin");
var documenth=$ (document). Height ();
var scrolltop=$ (window). Srcolltop ();
var lastpinh= $pin. EQ ($pin. length-1). Offset (). Top+math.floor ($pin. EQ ($pin. length-1). Outerheight ()/2);
Return (lastpinh<documenth+scrolltop)? True:false;
}
})