text: !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t=t||self).Scroller=i()}(this,function(){"use strict";function _(t){return"number"==typeof t}function y(t,i,e){return void 0===e&&(e=0),Math.max(Math.min(t,i),e)}function e(){}function u(t){return Math.pow(t-1,3)+1}function m(t){return(t/=.5)<1?.5*Math.pow(t,3):.5*(Math.pow(t-2,3)+2)}var d=Date.now||function(){return+new Date},i=Math.max,h=Math.round,b=Math.abs,n=Math.floor,c=Math.ceil,o=Object.assign||function(t,i){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),o=1;o<arguments.length;o++){var _=arguments[o];if(null!=_)for(var s in _)Object.prototype.hasOwnProperty.call(_,s)&&(e[s]=_[s])}return e},r=window,T={},s=1,L=function(){var e=r.requestAnimationFrame||r.webkitRequestAnimationFrame||r.mozRequestAnimationFrame||r.oRequestAnimationFrame,t=!!e;if(e&&!/requestAnimationFrame\(\)\s*\{\s*\[native code\]\s*\}/i.test(e.toString())&&(t=!1),t)return function(t,i){e(t,i)};var o,_={},s=1,l=d();return function(t,i){var e=s++;return _[e]=t,null==o&&(o=setInterval(function(){var t=d(),i=_;for(var e in _={},i)i.hasOwnProperty(e)&&(i[e](t),l=t);"number"==typeof o&&2500<t-l&&(clearInterval(o),o=null)},1e3/60)),e}}();function g(t){var i=null!=T[t];return i&&(T[t]=null),i}function v(l,r,n,h,c,a){var p=d(),f=p,u=0,m=0,g=s++;if(a=a||document.body,g%20==0){var t={};for(var i in T)t[i]=!0;T=t}var v=function(t){var i=!0!==t,e=d();if(!T[g]||r&&!r(g))return T[g]=null,void(n&&n(60-m/((e-p)/1e3),g,!1));if(i)for(var o=Math.round((e-f)/(1e3/60))-1,_=0;_<Math.min(o,4);_++)v(!0),m++;h&&1<(u=(e-p)/h)&&(u=1);var s=c?c(u):u;!1!==l(s,e,i)&&1!==u||!i?i&&(f=e,L(v,a)):(T[g]=null,n&&n(60-m/((e-p)/1e3),g,1===u||null==h))};return T[g]=!0,L(v,a),g}function t(t,i){void 0===i&&(i={}),this.options={scrollingX:!0,scrollingY:!0,animating:!0,animationDuration:250,bouncing:!0,locking:!0,paging:!1,snapping:!1,zooming:!1,minZoom:.5,maxZoom:3,speedMultiplier:1,scrollingComplete:e,penetrationDeceleration:.03,penetrationAcceleration:.08},this.__isSingleTouch=!1,this.__isTracking=!1,this.__didDecelerationComplete=!1,this.__isGesturing=!1,this.__isDragging=!1,this.__isDecelerating=0,this.__isAnimating=0,this.__interruptedAnimation=!1,this.__clientLeft=0,this.__clientTop=0,this.__clientWidth=0,this.__clientHeight=0,this.__contentWidth=0,this.__contentHeight=0,this.__snapWidth=100,this.__snapHeight=100,this.__refreshActive=!1,this.__zoomLevel=1,this.__scrollLeft=0,this.__scrollTop=0,this.__maxScrollLeft=0,this.__maxScrollTop=0,this.__scheduledLeft=0,this.__scheduledTop=0,this.__scheduledZoom=0,this.__positions=[],this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=0,this.__maxDecelerationScrollTop=0,this.__decelerationVelocityX=0,this.__decelerationVelocityY=0,this.__callback=t,o(this.options,i)}return t.prototype.setDimensions=function(t,i,e,o){_(t)&&(this.__clientWidth=t),_(i)&&(this.__clientHeight=i),_(e)&&(this.__contentWidth=e),_(o)&&(this.__contentHeight=o),this.__computeScrollMax(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)},t.prototype.setPosition=function(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.__clientLeft=t,this.__clientTop=i},t.prototype.setSnapSize=function(t,i){this.__snapWidth=t,this.__snapHeight=i},t.prototype.activatePullToRefresh=function(t,i,e,o){this.__refreshHeight=t,this.__refreshActivate=i,this.__refreshDeactivate=e,this.__refreshStart=o},t.prototype.triggerPullToRefresh=function(){this.__publish(this.__scrollLeft,-this.__refreshHeight,this.__zoomLevel,!0),this.__refreshStart&&this.__refreshStart()},t.prototype.finishPullToRefresh=function(){this.__refreshActive=!1,this.__refreshDeactivate&&this.__refreshDeactivate(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0)},t.prototype.getValues=function(){return{left:this.__scrollLeft,top:this.__scrollTop,zoom:this.__zoomLevel}},t.prototype.getScrollMax=function(){return{left:this.__maxScrollLeft,top:this.__maxScrollTop}},t.prototype.zoomTo=function(t,i,e,o,_){var s=this.options;if(!s.zooming)throw new Error("Zooming is not enabled!");_&&(this.__zoomComplete=_),this.__stopDecelerating();var l=this.__zoomLevel;null==e&&(e=this.__clientWidth/2),null==o&&(o=this.__clientHeight/2),t=y(t,s.maxZoom,s.minZoom),this.__computeScrollMax(t);var r=(e+this.__scrollLeft)*t/l-e,n=(o+this.__scrollTop)*t/l-o;r=y(r,this.__maxScrollLeft),n=y(n,this.__maxScrollTop),this.__publish(r,n,t,i)},t.prototype.zoomBy=function(t,i,e,o,_){this.zoomTo(this.__zoomLevel*t,i,e,o,_)},t.prototype.scrollTo=function(t,i,e,o){var _=this.options;if(this.__stopDecelerating(),null!=o&&o!==this.__zoomLevel){if(!_.zooming)throw new Error("Zooming is not enabled!");t*=o,i*=o,this.__computeScrollMax(o)}else o=this.__zoomLevel;if(_.scrollingX){var s=this.__clientWidth,l=this.__snapWidth;_.paging?t=h(t/s)*s:_.snapping&&(t=h(t/l)*l)}else t=this.__scrollLeft;if(_.scrollingY){var r=this.__clientHeight,n=this.__snapHeight;_.paging?i=h(i/r)*r:_.snapping&&(i=h(i/n)*n)}else i=this.__scrollTop;t=y(this.__maxScrollLeft,t),i=y(this.__maxScrollTop,i),t===this.__scrollLeft&&i===this.__scrollTop&&(e=!1),this.__isTracking||this.__publish(t,i,o,e)},t.prototype.scrollBy=function(t,i,e){void 0===t&&(t=0),void 0===i&&(i=0);var o=this.__isAnimating?this.__scheduledLeft:this.__scrollLeft,_=this.__isAnimating?this.__scheduledTop:this.__scrollTop;this.scrollTo(o+t,_+i,e)},t.prototype.doMouseZoom=function(t,i,e,o){var _=0<t?.97:1.03;return this.zoomTo(this.__zoomLevel*_,!1,e-this.__clientLeft,o-this.__clientTop)},t.prototype.doTouchStart=function(t,i){if(null==t.length)throw new Error("Invalid touch list: "+t);if("number"!=typeof i)throw new Error("Invalid timestamp value: "+i);var e,o,_=this.options;this.__interruptedAnimation=!0,this.__isDecelerating&&(this.__stopDecelerating(),this.__interruptedAnimation=!0),this.__isAnimating&&(g(this.__isAnimating),this.__isAnimating=0,this.__interruptedAnimation=!0);var s=1===t.length;if(s){var l=t[0];e=l.pageX,o=l.pageY}else{var r=t[0],n=t[1];e=b(r.pageX+n.pageX)/2,o=b(r.pageY+n.pageY)/2}this.__initialTouchLeft=e,this.__initialTouchTop=o,this.__zoomLevelStart=this.__zoomLevel,this.__lastTouchLeft=e,this.__lastTouchTop=o,this.__lastTouchMove=i,this.__lastScale=1,this.__enableScrollX=!s&&_.scrollingX,this.__enableScrollY=!s&&_.scrollingY,this.__isTracking=!0,this.__didDecelerationComplete=!1,this.__isDragging=!s,this.__isSingleTouch=s,this.__positions=[]},t.prototype.doTouchMove=function(t,i,e){if(null==t.length)throw new Error("Invalid touch list: "+t);if("number"!=typeof i)throw new Error("Invalid timestamp value: "+i);if(this.__isTracking){var o,_,s=this.options;if(2===t.length){var l=t[0],r=t[1];o=b(l.pageX+r.pageX)/2,_=b(l.pageY+r.pageY)/2}else{var n=t[0];o=n.pageX,_=n.pageY}var h=this.__positions;if(this.__isDragging){var c=o-this.__lastTouchLeft,a=_-this.__lastTouchTop,p=this.__scrollLeft,f=this.__scrollTop,u=this.__zoomLevel;if(null!=e&&s.zooming){var m=u;if(u=u/this.__lastScale*e,m!==(u=y(u,s.maxZoom,s.minZoom))){var g=o-this.__clientLeft,v=_-this.__clientTop;p=(g+p)*u/m-g,f=(v+f)*u/m-v,this.__computeScrollMax(u)}}if(this.__enableScrollX){p-=c*s.speedMultiplier;var d=this.__maxScrollLeft;(d<p||p<0)&&(s.bouncing?p+=c/2*s.speedMultiplier:p=d<p?d:0)}if(this.__enableScrollY){f-=a*s.speedMultiplier;var T=this.__maxScrollTop;(T<f||f<0)&&(s.bouncing?(f+=a/2*s.speedMultiplier,this.__enableScrollX||null==this.__refreshHeight||(!this.__refreshActive&&f<=-this.__refreshHeight?(this.__refreshActive=!0,this.__refreshActivate&&this.__refreshActivate()):this.__refreshActive&&f>-this.__refreshHeight&&(this.__refreshActive=!1,this.__refreshDeactivate&&this.__refreshDeactivate()))):f=T<f?T:0)}60<h.length&&h.splice(0,30),h.push(p,f,i),this.__publish(p,f,u)}else{var L=s.locking?3:0,S=b(o-this.__initialTouchLeft),D=b(_-this.__initialTouchTop);this.__enableScrollX=s.scrollingX&&L<=S,this.__enableScrollY=s.scrollingY&&L<=D,h.push(this.__scrollLeft,this.__scrollTop,i),this.__isDragging=(this.__enableScrollX||this.__enableScrollY)&&(5<=S||5<=D),this.__isDragging&&(this.__interruptedAnimation=!1)}this.__lastTouchLeft=o,this.__lastTouchTop=_,this.__lastTouchMove=i,"number"==typeof e&&(this.__lastScale=e)}},t.prototype.doTouchEnd=function(t){if("number"!=typeof t)throw new Error("Invalid timestamp value: "+t);if(this.__isTracking){var i=this.options;if(this.__isTracking=!1,this.__isDragging)if(this.__isDragging=!1,this.__isSingleTouch&&i.animating&&t-this.__lastTouchMove<=100){for(var e=this.__positions,o=e.length-1,_=o,s=o;0<s&&e[s]>this.__lastTouchMove-100;s-=3)_=s;if(_!==o){var l=e[o]-e[_],r=this.__scrollLeft-e[_-2],n=this.__scrollTop-e[_-1];this.__decelerationVelocityX=r/l*(1e3/60),this.__decelerationVelocityY=n/l*(1e3/60);var h=i.paging||i.snapping?4:1;b(this.__decelerationVelocityX)>h||b(this.__decelerationVelocityY)>h?this.__refreshActive||this.__startDeceleration(t):i.scrollingComplete()}else i.scrollingComplete()}else 100<t-this.__lastTouchMove&&i.scrollingComplete();this.__isDecelerating||(this.__refreshActive&&this.__refreshStart?(this.__publish(this.__scrollLeft,-this.__refreshHeight,this.__zoomLevel,!0),this.__refreshStart&&this.__refreshStart()):((this.__interruptedAnimation||this.__isDragging)&&i.scrollingComplete(),this.scrollTo(this.__scrollLeft,this.__scrollTop,!0,this.__zoomLevel),this.__refreshActive&&(this.__refreshActive=!1,this.__refreshDeactivate&&this.__refreshDeactivate()))),this.__positions.length=0}},t.prototype.__publish=function(t,i,e,o){var _=this,s=this.options,l=this.__isAnimating;if(l&&(g(l),this.__isAnimating=0),o&&s.animating){this.__scheduledLeft=t,this.__scheduledTop=i,this.__scheduledZoom=e;var r=this.__scrollLeft,n=this.__scrollTop,h=this.__zoomLevel,c=t-r,a=i-n,p=e-h,f=l?u:m;this.__isAnimating=v(function(t,i,e){e&&(_.__scrollLeft=r+c*t,_.__scrollTop=n+a*t,_.__zoomLevel=h+p*t,_.__callback&&_.__callback(_.__scrollLeft,_.__scrollTop,_.__zoomLevel))},function(t){return _.__isAnimating===t},function(t,i,e){i===_.__isAnimating&&(_.__isAnimating=0),(_.__didDecelerationComplete||e)&&s.scrollingComplete(),s.zooming&&(_.__computeScrollMax(),_.__zoomComplete&&(_.__zoomComplete(),_.__zoomComplete=null))},s.animationDuration,f)}else this.__scheduledLeft=this.__scrollLeft=t,this.__scheduledTop=this.__scrollTop=i,this.__scheduledZoom=this.__zoomLevel=e,this.__callback&&this.__callback(t,i,e),s.zooming&&(this.__computeScrollMax(),this.__zoomComplete&&(this.__zoomComplete(),this.__zoomComplete=null))},t.prototype.__computeScrollMax=function(t){null==t&&(t=this.__zoomLevel),this.__maxScrollLeft=i(this.__contentWidth*t-this.__clientWidth,0),this.__maxScrollTop=i(this.__contentHeight*t-this.__clientHeight,0)},t.prototype.__startDeceleration=function(t){var o=this,_=this.options;if(_.paging){var i=y(this.__scrollLeft,this.__maxScrollLeft),e=y(this.__scrollTop,this.__maxScrollTop),s=this.__clientWidth,l=this.__clientHeight;this.__minDecelerationScrollLeft=n(i/s)*s,this.__minDecelerationScrollTop=n(e/l)*l,this.__maxDecelerationScrollLeft=c(i/s)*s,this.__maxDecelerationScrollTop=c(e/l)*l}else this.__minDecelerationScrollLeft=0,this.__minDecelerationScrollTop=0,this.__maxDecelerationScrollLeft=this.__maxScrollLeft,this.__maxDecelerationScrollTop=this.__maxScrollTop;var r=_.snapping?4:.001;this.__isDecelerating=v(function(t,i,e){return o.__stepThroughDeceleration(e)},function(){var t=b(o.__decelerationVelocityX)>=r||b(o.__decelerationVelocityY)>=r;return t||(o.__didDecelerationComplete=!0),t},function(t,i,e){o.__isDecelerating=0,o.__didDecelerationComplete&&_.scrollingComplete(),o.scrollTo(o.__scrollLeft,o.__scrollTop,_.snapping)})},t.prototype.__stepThroughDeceleration=function(t){var i=this.options,e=this.__scrollLeft+this.__decelerationVelocityX,o=this.__scrollTop+this.__decelerationVelocityY;if(!i.bouncing){var _=y(this.__maxDecelerationScrollLeft,e,this.__minDecelerationScrollLeft);_!==e&&(e=_,this.__decelerationVelocityX=0);var s=y(this.__maxDecelerationScrollTop,o,this.__minDecelerationScrollTop);s!==o&&(o=s,this.__decelerationVelocityY=0)}if(t?this.__publish(e,o,this.__zoomLevel):(this.__scrollLeft=e,this.__scrollTop=o),i.paging||(this.__decelerationVelocityX*=.95,this.__decelerationVelocityY*=.95),i.bouncing){var l=0,r=0,n=this,h=n.__minDecelerationScrollLeft,c=n.__maxDecelerationScrollLeft,a=n.__minDecelerationScrollTop,p=n.__maxDecelerationScrollTop,f=n.__decelerationVelocityX,u=n.__decelerationVelocityY,m=n.options,g=m.penetrationDeceleration,v=m.penetrationAcceleration;e<h?l=h-e:c<e&&(l=c-e),o<a?r=a-o:p<o&&(r=p-o),0!==l&&(l*f<=0?this.__decelerationVelocityX+=l*g:this.__decelerationVelocityX=l*v),0!==r&&(r*u<=0?this.__decelerationVelocityY+=r*g:this.__decelerationVelocityY=r*v)}},t.prototype.__stopDecelerating=function(){var t=this.__isDecelerating;t&&(g(t),this.__isDecelerating=0)},t});
  