您的位置:首页 > 移动开发

移动端滑动加载更多

2016-01-04 14:21 435 查看
1 、 滑动到底部再加载数据

$(function(){

         $(window).scroll(function(){

                   var scrollH = document.documentElement.scrollHeight;

                    var clientH = document.documentElement.clientHeight;

                        if (scrollH == (document.documentElement.scrollTop | document.body.scrollTop) + clientH){
                                  //加载新数据

                                 alert(“加载新数据”);                        

                            }
                          });

});

2 、 滑动一个屏幕再加载新的图片

$(function(){
$(window).scroll(

function(){
var heightwindow = $(window).height();
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
var heightwindowsishewuru = Math.round(heightwindow/100) * 100;

if((document.body.scrollTop % heightwindowsishewuru  == 0  && document.body.scrollTop != 0 && document.documentElement.scrollTop == 0)  ||

(document.body.scrollTop == 0 && document.documentElement.scrollTop % heightwindowsishewuru == 0  && document.documentElement.scrollTop != 0)){  //当往下滑一个屏幕的时

候再加载
alert("加载新的图片");
}

});
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: