jquery上拉加载更多原理:
其实就是判断下 当前滚动条距离底部的距离
滚动条距离底部小于一个值时候 我们执行加载内容
下面上jquery代码://$(window).height() 可视区域高度
//$(window).scrollTop() 滚动条滚动高度(不包括可视高度)
//$(document).height() 网页整体高度 整体高度= ( 可视区域高度 + 滚动条可动高度 ) 这个滚动条可动高度指滚动条在底部时候
//滚动条滚动事件
$(window).scroll(function() {
// 总高度 - 可视化高度 判断滚动条滚动到最底端高度
// 滚动条可动高度 / (总高度 - 可视化高度) >= 0.95 在滚动条距离底端5%以内
// 对应公式: $(window).scrollTop()/($(document).height()-$(window).height())
// (总高度 - 可视化高度) - 滚动条可动高度 <= 50 在滚动条距离底端50px以内
// 对应公式: ($(document).height() - $(window).height()) - $(window).scrollTop() <=50
var _windowHeight = 0;
if($(document).height()>=$(window).height()){
_windowHeight=document.body.clientHeight;
}else{//alert($(window).height());
_windowHeight=$(document).height();
};
if ($(window).scrollTop()/($(document).height()-_windowHeight)>=0.80) {
if(load_flg){
load_list();
}
}
});
快试试吧 - -