(function(){function t(t){var e,i,n,o,s,h;"undefined"!=typeof $?(this.opt=$.extend({container:null,tail:null,autoStart:!0,initCallback:function(){},nextCallback:function(t){},doneCallback:function(){},resetCallback:function(){},pullToRefreshCallback:function(){},pullToRefresh:!1,pullToRefreshDom:null},t),null===this.opt.container&&(this.opt.container=window),this.dom={container:null,tail:null},this.runtime={processNext:!1,done:!1,page:1,started:!1},(e=this).dom.container=$(this.opt.container),this.dom.tail=$(this.opt.tail),this.dom.pullToRefresh=null,this.dom.container.on("scroll",function(){e._nextCheck()}),this.opt.initCallback(),this.opt.autoStart&&(this.runtime.started=!0,e._nextCheck()),this.opt.pullToRefresh&&(e.dom.pullToRefresh=$(this.opt.pullToRefreshDom),i=e.dom.pullToRefresh.height(),n=null,o={x:0,y:0},s=99999,h=0,e.dom.container.on("touchstart",function(t){t=t.originalEvent,h=0,s=99999,"up"==(n=e.dom.container.scrollTop()<=0?"up":n)&&(o.x=t.changedTouches[0].pageX,o.y=t.changedTouches[0].pageY,e.dom.pullToRefresh.find(".status").hide(),e.dom.pullToRefresh.find(".status.pull").show())}),e.dom.container.on("touchmove",function(t){if((t=t.originalEvent).preventDefault(),"up"==n){if(0=e.width+i.width?!1:t)&&2*Math.abs(e.y-i.y)>=e.height+i.height?!1:t},_nextCheck:function(){this.runtime.started&&!this.runtime.done&&!this.runtime.processNext&&this._isTailOnScreen()&&this._next()},_next:function(){this.runtime.processNext=!0,this.opt.nextCallback(this.runtime.page)},check:function(){this._nextCheck()},nextDone:function(){this.runtime.processNext=!1,this.runtime.page++,this._nextCheck()},done:function(){this.runtime.done=!0,this.opt.doneCallback()},reset:function(){this.opt.resetCallback(),this.runtime.processNext=!1,this.runtime.done=!1,this.runtime.page=1,this._nextCheck()},start:function(){this.runtime.started=!0,this._nextCheck()},setPage:function(t){this.runtime.page=t},pullToRefreshDone:function(){this.dom.pullToRefresh.css({marginTop:-this.dom.pullToRefresh.height()+"px"}),this.reset()}},"undefined"!=typeof module&&"object"==typeof exports&&define.cmd?module.exports=t:"function"==typeof define&&define.amd?define(function(){return t}):this.InfiniteScroller=t}).call(function(){return this||("undefined"!=typeof window?window:global)}());