masonry+infinitescroll实现无限加载分页

在我的博客中之前已经分别讲过masonry和infinitescroll插件,以及详尽的demo。这里讲的重点是二者的结合实现无限加载分页,话不多说,直接上代码。

$(function(){
            var $container = $('#masonry');
            $container.imagesLoaded( function(){
                $container.masonry({
                    itemSelector : '.box',
                    gutterWidth : 20,
                    isAnimated: true,
                });
            });

            infiniteScroll = function() {
            // infinite scrolling
            var $container = $('#masonry');
            $container.infinitescroll({
                binder: $('#conScroll'),
                navSelector  : '#page-nav',    // selector for the paged navigation
                nextSelector : '#page-nav a',  // selector for the NEXT link (to page 2)
                itemSelector : '.box',         // selector for all items you'll retrieve
                pixelsFromNavToBottom: 150,
                extraScrollPx: 50,
                // debug        : true,
                prefill      : true,
                bufferPx     : 1,              //提示语展现的时长,数字越大,展现时间越短
                path : function(page){
                    return 'image.html';
                },
                loading: {
                    finishedMsg: 'no more comments!',
                    msgText: 'onload old comments',
                    img: 'images/loading-dark.gif'
                }
                },       
                function( nextComments ) {
                    var $nextComm = $( nextComments );
                    $container.masonry( 'appended', $nextComm, true );  //这里需要特别注意
                });
            }
            infiniteScroll();
        });

demo下载地址 http://download.csdn.net/detail/jiangjundriver/9871462

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值