Popular Waterfall Flow page layout for unlimited loading (jquery)

Source: Internet
Author: User

Today to share with you a Waterfall Flow page layout, first with you to analyze the idea of implementation

Main idea: First, according to the width of the screen and the width of a single floating layer to determine the number of floating layer

        

var $boxs = $ ("#main >div")        var boxw = $boxs. EQ (0  ). Outerwidth ();         var clos = Math.floor ($ (window). Width ()/Boxw);        $ ("#main"). Width (boxw*clos). CSS ('margin' ,'0 auto');

Second, use absolute positioning to determine the position of the floating layer, where I put a picture in the floating layer to show the effect

      

varHarr=[]; $boxs. Each (function (index, Element) {varH=$boxs. EQ (index). Outerheight (); if(index<Clos) {Harr[index]=h; }                Else{                    varMinh=math.min.apply (NULL, HARR); varminhindex=$.inarray (Minh,harr); $ (Element). css ({'position':'Absolute',                        'Top': minh+'px',                        ' Left': minhindex*boxw+'px'}) Harr[minhindex]+=$boxs. EQ (index). Outerheight (); }

Third, according to the screen display height + scroll bar height and the last floating layer of the top value to determine the execution of the scrolling event

        

$ (window). Scroll (function () {if(checkscroll) { for(varI=1;i<8; i++){                varobox=$ ("<div>"). AddClass ("Box"). AppendTo ($ ("#main")); varopic=$ ("<div>"). AddClass ("pic"). AppendTo ($ (obox)); $(""). attr ('src','images/'+ i +". jpg"). AppendTo ($ (OPIC));            } waterfall (); }}) function Checkscroll () {varlasttop=$ ("#main >div"). Last (). Offset (). Top+=math.floor ($ ("#main >div"). Last (). Outerheight ()/2); varscrolltop=$ (window). scrolltop (); varDocumeth=$ (window). Height (); return(Lasttop>scrolltop+documeth)?true:false; }

For example, click here for an example (more refresh next page to see the full effect)

      

Popular Waterfall Flow page layout for unlimited loading (jquery)

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.