滑动插件scroll.js

来源:互联网 发布:mac在哪里新建文件夹 编辑:程序博客网 时间:2024/05/29 17:41
(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;})();
0 0
原创粉丝点击