jquery Waterfall Stream

Source: Internet
Author: User

<div id= "Container" >
<div class= "box" >
<div class= "Content" >

</div>
</div>


$ (document). Ready (function () {
$ (window). On ("Load", function () {
Imglocation ();
var dataimg={"Data": [{"SCR": "Test0.jpg"},{"SCR": "Test1.jpg"},{"SCR": "Test2.jpg"},{"SCR": "Test3.jpg"},{"SCR": " Test4.jpg "},{" SCR ":" Test5.jpg "},
{"SCR": "Test6.jpg"},{"SCR": "Test7.jpg"},{"SCR": "Test0.jpg"},{"SCR": "Test1.jpg"},{"SCR": "Test2.jpg"},{"SCR": " Test3.jpg "},{" SCR ":" Test4.jpg "}]};
Window.onscroll = function () {
if (Scrollside ())
{
Console.log ("World wolrd wolrd")
$.each (Dataimg.data,function (index,value) {
var box = $ ("<div>"). addclass ("box"). AppendTo ($ ("#container"));
var content = $ ("<div>"). AddClass ("Content"). AppendTo (box);
Console.log ("url" + "./images/" +$ (value). attr ("SCR"));
var img = $ ("});
Imglocation ();
}
}
});
});

function Scrollside () {
var box = $ (". box");
var box2= box.last ();
var lastboxheight = Box.last (). Get (0). Offsettop+math.floor (Box.last (). Height ()/2);
var documentheight = $ (document). width ();
var scrollheight = $ (window). scrolltop ();
Return (lastboxheight<documentheight+scrollheight)? True:false;
}

function Imglocation () {
var box = $ (". box");
Console.log ("box" +box.length);
var boxwidth = box.eq (0). width ();
var num = Math.floor ($ (window). Width ()/boxwidth);
var boxarr = [];
Box.each (function (index,value) {
var boxhegiht = box.eq (index). Height ();
if (index<num)
{
Boxarr[index] = boxhegiht;
}else{
var minboxheight = Math.min.apply (Null,boxarr);
var minboxindex = $.inarray (Minboxheight,boxarr);
$ (value). css ({
"Position": "Absolute",
"Top": minboxheight,
' Left ': Box.eq (Minboxindex). Position (). Left
});
Boxarr[minboxindex] +=box.eq (index). Height ();
}
});
}

jquery Waterfall Stream

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.