(function(){
var Roll = function(pgno,pageSize){
this.page_num = pgno?pgno:1;
this.pageSize = pageSize?pageSize:3;
this.isEnd = false;
};
Roll.prototype = {
init : function(){
this.loadContents();
this._addEvents();
},
_addEvents : function(){
var _this = this;
//增加滚条事件
addEventListener("scroll",function(){
_this.adapterScroll();
},false);
},
adapterScroll : function(){
//内容可视区域的高度
var h = document.documentElement.clientHeight;
//Safarichorme ff ie
var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
var scrollHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
var pos = h + scrollTop;
//用户代理头
var ua = navigator.userAgent.toLowerCase();
if(ua && ua.indexOf('safari') != -1){
//检索值没有出现返回-1 indexOf对大小写敏感
isSafariMobile = /{ipod|iphone}*/.test(ua);
if(isSafariMobile){
pos = pos + 50;
}
}else{
pos = pos + 50;
}
if(pos>= scrollHeight){
this.loadContents();
}
},
loadContents : function(){
if(this.isEnd)
return;
if(this.page_num>1)
this.onLoadContents();
this.page_num++;
},
onLoadContents : function(){
}
};
window.Roll = Roll;
})();
滑动插件scroll.js
最新推荐文章于 2022-05-17 22:41:16 发布