Jquery.lazyload+masonry improved picture Waterfall Flow Code _ Image effect

Source: Internet
Author: User

The

Implementation method is as follows: (only jquery is here, the relevant HTML code please make up your mind, I will not hair, haha)

/** * Automatic refresh * @type {*|jquery|
HtmlElement} */var $container = $ (' #main '); $container. imagesloaded (function () {$container. Masonry ({itemselector: '. Item ', columnwidth:205, Gutterwid
Th:10, isanimated:true});
});
var pre_href; Scroll $ (window). Scroll (function () {//when scrolling to the bottom 100 pixel, load new content if ($ (document). Height ()-$ (this). ScrollTop ()-$ (this). h
  Eight () <100) {ajax_load_data ();
 
}
});
  function Ajax_load_data () {var href = $ (' #page-nav '). Find ('. Nextprev '). attr (' href ');
    if (href && href!= pre_href) {console.log (' href = ' +href);
 
    pre_href = href; $.ajax ({url:href,//Gets the address of the element list data:{' act ': ' Ajax_wap_index '}, DataType: ' JSON ', type: ' Post ', b
      Eforesend:function () {show_loading_body ();
      }, Complete:function () {show_loading_body (); }, Success:function (data) {if (data.status!= undefined && data.status = ' OK ') {if (data.ht ml) {var $bOxes = $ (data.html);
              $container. Append ($boxes). Masonry ("appended", $boxes, true);//Append Element $container. imagesloaded (function () {
            $container. Masonry (); //After the picture is loaded, an automatic rearrangement is achieved. "Here is the emphasis"} if (Data.str_pages) {$ (' #page-nav '). HTML (data.str_pages);//Set the address of the next paging.
  "You can add"}}});
 }
}

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.