text: /*! iScroll v5.2.0-snapshot ~ (c) 2008-2017 Matteo Spinelli ~ http://cubiq.org/license */
  (function(a,d,g){function h(r,s){for(var t in this.wrapper='string'==typeof r?d.querySelector(r):r,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={zoomMin:1,zoomMax:4,startZoom:1,resizeScrollbars:!0,mouseWheelSpeed:20,snapThreshold:0.334,disablePointer:!q.hasPointer,disableTouch:q.hasPointer||!q.hasTouch,disableMouse:q.hasPointer||q.hasTouch,startX:0,startY:0,scrollY:!0,directionLockThreshold:5,momentum:!0,bounce:!0,bounceTime:600,bounceEasing:'',preventDefault:!0,preventDefaultException:{tagName:/^(INPUT|TEXTAREA|BUTTON|SELECT)$/},HWCompositing:!0,useTransition:!0,useTransform:!0,bindToWrapper:'undefined'==typeof a.onmousedown},s)this.options[t]=s[t];this.translateZ=this.options.HWCompositing&&q.hasPerspective?' translateZ(0)':'',this.options.useTransition=q.hasTransition&&this.options.useTransition,this.options.useTransform=q.hasTransform&&this.options.useTransform,this.options.eventPassthrough=!0===this.options.eventPassthrough?'vertical':this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY='vertical'!=this.options.eventPassthrough&&this.options.scrollY,this.options.scrollX='horizontal'!=this.options.eventPassthrough&&this.options.scrollX,this.options.freeScroll=this.options.freeScroll&&!this.options.eventPassthrough,this.options.directionLockThreshold=this.options.eventPassthrough?0:this.options.directionLockThreshold,this.options.bounceEasing='string'==typeof this.options.bounceEasing?q.ease[this.options.bounceEasing]||q.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,!0===this.options.tap&&(this.options.tap='tap'),this.options.useTransition||this.options.useTransform||/relative|absolute/i.test(this.scrollerStyle.position)||(this.scrollerStyle.position='relative'),'scale'==this.options.shrinkScrollbars&&(this.options.useTransition=!1),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this.scale=g.min(g.max(this.options.startZoom,this.options.zoomMin),this.options.zoomMax),this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}function j(r,s,t){var u=d.createElement('div'),v=d.createElement('div');return!0===t&&(u.style.cssText='position:absolute;z-index:9999',v.style.cssText='-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;position:absolute;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);border-radius:3px'),v.className='iScrollIndicator','h'==r?(!0===t&&(u.style.cssText+=';height:7px;left:2px;right:2px;bottom:0',v.style.height='100%'),u.className='iScrollHorizontalScrollbar'):(!0===t&&(u.style.cssText+=';width:7px;bottom:2px;top:2px;right:1px',v.style.width='100%'),u.className='iScrollVerticalScrollbar'),u.style.cssText+=';overflow:hidden',s||(u.style.pointerEvents='none'),u.appendChild(v),u}function o(r,s){for(var t in this.wrapper='string'==typeof s.el?d.querySelector(s.el):s.el,this.wrapperStyle=this.wrapper.style,this.indicator=this.wrapper.children[0],this.indicatorStyle=this.indicator.style,this.scroller=r,this.options={listenX:!0,listenY:!0,interactive:!1,resize:!0,defaultScrollbars:!1,shrink:!1,fade:!1,speedRatioX:0,speedRatioY:0},s)this.options[t]=s[t];if(this.sizeRatioX=1,this.sizeRatioY=1,this.maxPosX=0,this.maxPosY=0,this.options.interactive&&(!this.options.disableTouch&&(q.addEvent(this.indicator,'touchstart',this),q.addEvent(a,'touchend',this)),!this.options.disablePointer&&(q.addEvent(this.indicator,q.prefixPointerEvent('pointerdown'),this),q.addEvent(a,q.prefixPointerEvent('pointerup'),this)),!this.options.disableMouse&&(q.addEvent(this.indicator,'mousedown',this),q.addEvent(a,'mouseup',this))),this.options.fade){this.wrapperStyle[q.style.transform]=this.scroller.translateZ;var u=q.style.transitionDuration;if(!u)return;this.wrapperStyle[u]=q.isBadAndroid?'0.0001ms':'0ms';var v=this;q.isBadAndroid&&p(function(){'0.0001ms'===v.wrapperStyle[u]&&(v.wrapperStyle[u]='0s')}),this.wrapperStyle.opacity='0'}}var p=a.requestAnimationFrame||a.webkitRequestAnimationFrame||a.mozRequestAnimationFrame||a.oRequestAnimationFrame||a.msRequestAnimationFrame||function(r){a.setTimeout(r,1e3/60)},q=function(){function r(w){return!1!==u&&(''===u?w:u+w.charAt(0).toUpperCase()+w.substr(1))}var s={},t=d.createElement('div').style,u=function(){for(var z,w=['t','webkitT','MozT','msT','OT'],A=0,B=w.length;A<B;A++)if(z=w[A]+'ransform',z in t)return w[A].substr(0,w[A].length-1);return!1}();s.getTime=Date.now||function(){return new Date().getTime()},s.extend=function(w,z){for(var A in z)w[A]=z[A]},s.addEvent=function(w,z,A,B){w.addEventListener(z,A,!!B)},s.removeEvent=function(w,z,A,B){w.removeEventListener(z,A,!!B)},s.prefixPointerEvent=function(w){return a.MSPointerEvent?'MSPointer'+w.charAt(7).toUpperCase()+w.substr(8):w},s.momentum=function(w,z,A,B,C,D){var G,H,E=w-z,F=g.abs(E)/A;return D=void 0===D?6e-4:D,G=w+F*F/(2*D)*(0>E?-1:1),H=F/D,G<B?(G=C?B-C/2.5*(F/8):B,E=g.abs(G-w),H=E/F):0<G&&(G=C?C/2.5*(F/8):0,E=g.abs(w)+G,H=E/F),{destination:g.round(G),duration:H}};var v=r('transform');return s.extend(s,{hasTransform:!1!==v,hasPerspective:r('perspective')in t,hasTouch:'ontouchstart'in a,hasPointer:!!(a.PointerEvent||a.MSPointerEvent),hasTransition:r('transition')in t}),s.isBadAndroid=function(){var w=a.navigator.appVersion;if(/Android/.test(w)&&!/Chrome\/\d/.test(w)){var z=w.match(/Safari\/(\d+.\d)/);return z&&'object'==typeof z&&2<=z.length?535.19>parseFloat(z[1]):!0}return!1}(),s.extend(s.style={},{transform:v,transitionTimingFunction:r('transitionTimingFunction'),transitionDuration:r('transitionDuration'),transitionDelay:r('transitionDelay'),transformOrigin:r('transformOrigin'),touchAction:r('touchAction')}),s.hasClass=function(w,z){var A=new RegExp('(^|\\s)'+z+'(\\s|$)');return A.test(w.className)},s.addClass=function(w,z){if(!s.hasClass(w,z)){var A=w.className.split(' ');A.push(z),w.className=A.join(' ')}},s.removeClass=function(w,z){if(s.hasClass(w,z)){var A=new RegExp('(^|\\s)'+z+'(\\s|$)','g');w.className=w.className.replace(A,' ')}},s.offset=function(w){for(var z=-w.offsetLeft,A=-w.offsetTop;w=w.offsetParent;)z-=w.offsetLeft,A-=w.offsetTop;return{left:z,top:A}},s.preventDefaultException=function(w,z){for(var A in z)if(z[A].test(w[A]))return!0;return!1},s.extend(s.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,pointerdown:3,pointermove:3,pointerup:3,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),s.extend(s.ease={},{quadratic:{style:'cubic-bezier(0.25, 0.46, 0.45, 0.94)',fn:function(w){return w*(2-w)}},circular:{style:'cubic-bezier(0.1, 0.57, 0.1, 1)',fn:function(w){return g.sqrt(1- --w*w)}},back:{style:'cubic-bezier(0.175, 0.885, 0.32, 1.275)',fn:function(w){var z=4;return--w*w*((z+1)*w+z)+1}},bounce:{style:'',fn:function(w){return(w/=1)<1/2.75?7.5625*w*w:w<2/2.75?7.5625*(w-=1.5/2.75)*w+0.75:w<2.5/2.75?7.5625*(w-=2.25/2.75)*w+0.9375:7.5625*(w-=2.625/2.75)*w+0.984375}},elastic:{style:'',fn:function(w){var z=0.22;return 0===w?0:1==w?1:0.4*g.pow(2,-10*w)*g.sin((w-z/4)*(2*g.PI)/z)+1}}}),s.tap=function(w,z){var A=d.createEvent('Event');A.initEvent(z,!0,!0),A.pageX=w.pageX,A.pageY=w.pageY,w.target.dispatchEvent(A)},s.click=function(w){var A,z=w.target;/(SELECT|INPUT|TEXTAREA)/i.test(z.tagName)||(A=d.createEvent(a.MouseEvent?'MouseEvents':'Event'),A.initEvent('click',!0,!0),A.view=w.view||a,A.detail=1,A.screenX=z.screenX||0,A.screenY=z.screenY||0,A.clientX=z.clientX||0,A.clientY=z.clientY||0,A.ctrlKey=!!w.ctrlKey,A.altKey=!!w.altKey,A.shiftKey=!!w.shiftKey,A.metaKey=!!w.metaKey,A.button=0,A.relatedTarget=null,A._constructed=!0,z.dispatchEvent(A))},s.getTouchAction=function(w,z){var A='none';return'vertical'===w?A='pan-y':'horizontal'==w&&(A='pan-x'),z&&'none'!=A&&(A+=' pinch-zoom'),A},s.getRect=function(w){if(w instanceof SVGElement){var z=w.getBoundingClientRect();return{top:z.top,left:z.left,width:z.width,height:z.height}}return{top:w.offsetTop,left:w.offsetLeft,width:w.offsetWidth,height:w.offsetHeight}},s}();h.prototype={version:'5.2.0-snapshot',_init:function(){this._initEvents(),this.options.zoom&&this._initZoom(),(this.options.scrollbars||this.options.indicators)&&this._initIndicators(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys()},destroy:function(){this._initEvents(!0),clearTimeout(this.resizeTimeout),this.resizeTimeout=null,this._execEvent('destroy')},_transitionEnd:function(r){r.target==this.scroller&&this.isInTransition&&(this._transitionTime(),!this.resetPosition(this.options.bounceTime)&&(this.isInTransition=!1,this._execEvent('scrollEnd')))},_start:function(r){if(1!=q.eventType[r.type]){var s;if(s=r.which?r.button:2>r.button?0:4==r.button?1:2,0!==s)return}if(this.enabled&&(!this.initiated||q.eventType[r.type]===this.initiated)){!this.options.preventDefault||q.isBadAndroid||q.preventDefaultException(r.target,this.options.preventDefaultException)||r.preventDefault();var u,t=r.touches?r.touches[0]:r;this.initiated=q.eventType[r.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this.startTime=q.getTime(),this.options.useTransition&&this.isInTransition?(this._transitionTime(),this.isInTransition=!1,u=this.getComputedPosition(),this._translate(g.round(u.x),g.round(u.y)),this._execEvent('scrollEnd')):!this.options.useTransition&&this.isAnimating&&(this.isAnimating=!1,this._execEvent('scrollEnd')),this.startX=this.x,this.startY=this.y,this.absStartX=this.x,this.absStartY=this.y,this.pointX=t.pageX,this.pointY=t.pageY,this._execEvent('beforeScrollStart')}},_move:function(r){if(this.enabled&&q.eventType[r.type]===this.initiated){this.options.preventDefault&&r.preventDefault();var w,z,A,B,s=r.touches?r.touches[0]:r,t=s.pageX-this.pointX,u=s.pageY-this.pointY,v=q.getTime();if(this.pointX=s.pageX,this.pointY=s.pageY,this.distX+=t,this.distY+=u,A=g.abs(this.distX),B=g.abs(this.distY),!(300<v-this.endTime&&10>A&&10>B)){if(this.directionLocked||this.options.freeScroll||(A>B+this.options.directionLockThreshold?this.directionLocked='h':B>=A+this.options.directionLockThreshold?this.directionLocked='v':this.directionLocked='n'),'h'==this.directionLocked){if('vertical'==this.options.eventPassthrough)r.preventDefault();else if('horizontal'==this.options.eventPassthrough)return void(this.initiated=!1);u=0}else if('v'==this.directionLocked){if('horizontal'==this.options.eventPassthrough)r.preventDefault();else if('vertical'==this.options.eventPassthrough)return void(this.initiated=!1);t=0}t=this.hasHorizontalScroll?t:0,u=this.hasVerticalScroll?u:0,w=this.x+t,z=this.y+u,(0<w||w<this.maxScrollX)&&(w=this.options.bounce?this.x+t/3:0<w?0:this.maxScrollX),(0<z||z<this.maxScrollY)&&(z=this.options.bounce?this.y+u/3:0<z?0:this.maxScrollY),this.directionX=0<t?-1:0>t?1:0,this.directionY=0<u?-1:0>u?1:0,this.moved||this._execEvent('scrollStart'),this.moved=!0,this._translate(w,z),300<v-this.startTime&&(this.startTime=v,this.startX=this.x,this.startY=this.y)}}},_end:function(r){if(this.enabled&&q.eventType[r.type]===this.initiated){this.options.preventDefault&&!q.preventDefaultException(r.target,this.options.preventDefaultException)&&r.preventDefault();var t,u,s=r.changedTouches?r.changedTouches[0]:r,v=q.getTime()-this.startTime,w=g.round(this.x),z=g.round(this.y),A=g.abs(w-this.startX),B=g.abs(z-this.startY),C=0,D='';if(this.isInTransition=0,this.initiated=0,this.endTime=q.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(w,z),!this.moved)return this.options.tap&&q.tap(r,this.options.tap),this.options.click&&q.click(r),void this._execEvent('scrollCancel');if(this._events.flick&&200>v&&100>A&&100>B)return void this._execEvent('flick');if(this.options.momentum&&300>v&&(t=this.hasHorizontalScroll?q.momentum(this.x,this.startX,v,this.maxScrollX,this.options.bounce?this.wrapperWidth:0,this.options.deceleration):{destination:w,duration:0},u=this.hasVerticalScroll?q.momentum(this.y,this.startY,v,this.maxScrollY,this.options.bounce?this.wrapperHeight:0,this.options.deceleration):{destination:z,duration:0},w=t.destination,z=u.destination,C=g.max(t.duration,u.duration),this.isInTransition=1),this.options.snap){var E=this._nearestSnap(w,z);this.currentPage=E,C=this.options.snapSpeed||g.max(g.max(g.min(g.abs(w-E.x),1e3),g.min(g.abs(z-E.y),1e3)),300),w=E.x,z=E.y,this.directionX=0,this.directionY=0,D=this.options.bounceEasing}return w!=this.x||z!=this.y?((0<w||w<this.maxScrollX||0<z||z<this.maxScrollY)&&(D=q.ease.quadratic),void this.scrollTo(w,z,C,D)):void this._execEvent('scrollEnd')}}},_resize:function(){var r=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){r.refresh()},this.options.resizePolling)},resetPosition:function(r){var s=this.x,t=this.y;return(r=r||0,!this.hasHorizontalScroll||0<this.x?s=0:this.x<this.maxScrollX&&(s=this.maxScrollX),!this.hasVerticalScroll||0<this.y?t=0:this.y<this.maxScrollY&&(t=this.maxScrollY),s!=this.x||t!=this.y)&&(this.scrollTo(s,t,r,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){q.getRect(this.wrapper),this.wrapperWidth=this.wrapper.clientWidth,this.wrapperHeight=this.wrapper.clientHeight;var r=q.getRect(this.scroller);this.scrollerWidth=g.round(r.width*this.scale),this.scrollerHeight=g.round(r.height*this.scale),this.maxScrollX=this.wrapperWidth-this.scrollerWidth,this.maxScrollY=this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&0>this.maxScrollX,this.hasVerticalScroll=this.options.scrollY&&0>this.maxScrollY,this.hasHorizontalScroll||(this.maxScrollX=0,this.scrollerWidth=this.wrapperWidth),this.hasVerticalScroll||(this.maxScrollY=0,this.scrollerHeight=this.wrapperHeight),this.endTime=0,this.directionX=0,this.directionY=0,q.hasPointer&&!this.options.disablePointer&&(this.wrapper.style[q.style.touchAction]=q.getTouchAction(this.options.eventPassthrough,!0),!this.wrapper.style[q.style.touchAction]&&(this.wrapper.style[q.style.touchAction]=q.getTouchAction(this.options.eventPassthrough,!1))),this.wrapperOffset=q.offset(this.wrapper),this._execEvent('refresh'),this.resetPosition()},on:function(r,s){this._events[r]||(this._events[r]=[]),this._events[r].push(s)},off:function(r,s){if(this._events[r]){var t=this._events[r].indexOf(s);-1<t&&this._events[r].splice(t,1)}},_execEvent:function(r){if(this._events[r]){var s=0,t=this._events[r].length;if(t)for(;s<t;s++)this._events[r][s].apply(this,[].slice.call(arguments,1))}},scrollBy:function(r,s,t,u){r=this.x+r,s=this.y+s,t=t||0,this.scrollTo(r,s,t,u)},scrollTo:function(r,s,t,u){u=u||q.ease.circular,this.isInTransition=this.options.useTransition&&0<t;var v=this.options.useTransition&&u.style;!t||v?(v&&(this._transitionTimingFunction(u.style),this._transitionTime(t)),this._translate(r,s)):this._animate(r,s,t,u.fn)},scrollToElement:function(r,s,t,u,v){if(r=r.nodeType?r:this.scroller.querySelector(r),!!r){var w=q.offset(r);w.left-=this.wrapperOffset.left,w.top-=this.wrapperOffset.top;var z=q.getRect(r),A=q.getRect(this.wrapper);!0===t&&(t=g.round(z.width/2-A.width/2)),!0===u&&(u=g.round(z.height/2-A.height/2)),w.left-=t||0,w.top-=u||0,w.left=0<w.left?0:w.left<this.maxScrollX?this.maxScrollX:w.left,w.top=0<w.top?0:w.top<this.maxScrollY?this.maxScrollY:w.top,s=void 0===s||null===s||'auto'===s?g.max(g.abs(this.x-w.left),g.abs(this.y-w.top)):s,this.scrollTo(w.left,w.top,s,v)}},_transitionTime:function(r){if(this.options.useTransition){r=r||0;var s=q.style.transitionDuration;if(s){if(this.scrollerStyle[s]=r+'ms',!r&&q.isBadAndroid){this.scrollerStyle[s]='0.0001ms';var t=this;p(function(){'0.0001ms'===t.scrollerStyle[s]&&(t.scrollerStyle[s]='0s')})}if(this.indicators)for(var u=this.indicators.length;u--;)this.indicators[u].transitionTime(r)}}},_transitionTimingFunction:function(r){if(this.scrollerStyle[q.style.transitionTimingFunction]=r,this.indicators)for(var s=this.indicators.length;s--;)this.indicators[s].transitionTimingFunction(r)},_translate:function(r,s){if(this.options.useTransform?this.scrollerStyle[q.style.transform]='translate('+r+'px,'+s+'px) scale('+this.scale+') '+this.translateZ:(r=g.round(r),s=g.round(s),this.scrollerStyle.left=r+'px',this.scrollerStyle.top=s+'px'),this.x=r,this.y=s,this.indicators)for(var t=this.indicators.length;t--;)this.indicators[t].updatePosition()},_initEvents:function(r){var s=r?q.removeEvent:q.addEvent,t=this.options.bindToWrapper?this.wrapper:a;s(a,'orientationchange',this),s(a,'resize',this),this.options.click&&s(this.wrapper,'click',this,!0),this.options.disableMouse||(s(this.wrapper,'mousedown',this),s(t,'mousemove',this),s(t,'mousecancel',this),s(t,'mouseup',this)),q.hasPointer&&!this.options.disablePointer&&(s(this.wrapper,q.prefixPointerEvent('pointerdown'),this),s(t,q.prefixPointerEvent('pointermove'),this),s(t,q.prefixPointerEvent('pointercancel'),this),s(t,q.prefixPointerEvent('pointerup'),this)),q.hasTouch&&!this.options.disableTouch&&(s(this.wrapper,'touchstart',this),s(t,'touchmove',this),s(t,'touchcancel',this),s(t,'touchend',this)),s(this.scroller,'transitionend',this),s(this.scroller,'webkitTransitionEnd',this),s(this.scroller,'oTransitionEnd',this),s(this.scroller,'MSTransitionEnd',this)},getComputedPosition:function(){var s,t,r=a.getComputedStyle(this.scroller,null);return this.options.useTransform?(r=r[q.style.transform].split(')')[0].split(', '),s=+(r[12]||r[4]),t=+(r[13]||r[5])):(s=+r.left.replace(/[^-\d.]/g,''),t=+r.top.replace(/[^-\d.]/g,'')),{x:s,y:t}},_initIndicators:function(){function r(A){if(w.indicators)for(var B=w.indicators.length;B--;)A.call(w.indicators[B])}var v,s=this.options.interactiveScrollbars,t='string'!=typeof this.options.scrollbars,u=[],w=this;this.indicators=[],this.options.scrollbars&&(this.options.scrollY&&(v={el:j('v',s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:t,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenX:!1},this.wrapper.appendChild(v.el),u.push(v)),this.options.scrollX&&(v={el:j('h',s,this.options.scrollbars),interactive:s,defaultScrollbars:!0,customStyle:t,resize:this.options.resizeScrollbars,shrink:this.options.shrinkScrollbars,fade:this.options.fadeScrollbars,listenY:!1},this.wrapper.appendChild(v.el),u.push(v))),this.options.indicators&&(u=u.concat(this.options.indicators));for(var z=u.length;z--;)this.indicators.push(new o(this,u[z]));this.options.fadeScrollbars&&(this.on('scrollEnd',function(){r(function(){this.fade()})}),this.on('scrollCancel',function(){r(function(){this.fade()})}),this.on('scrollStart',function(){r(function(){this.fade(1)})}),this.on('beforeScrollStart',function(){r(function(){this.fade(1,!0)})})),this.on('refresh',function(){r(function(){this.refresh()})}),this.on('destroy',function(){r(function(){this.destroy()}),delete this.indicators})},_initZoom:function(){this.scrollerStyle[q.style.transformOrigin]='0 0'},_zoomStart:function(r){var s=g.abs(r.touches[0].pageX-r.touches[1].pageX),t=g.abs(r.touches[0].pageY-r.touches[1].pageY);this.touchesDistanceStart=g.sqrt(s*s+t*t),this.startScale=this.scale,this.originX=g.abs(r.touches[0].pageX+r.touches[1].pageX)/2+this.wrapperOffset.left-this.x,this.originY=g.abs(r.touches[0].pageY+r.touches[1].pageY)/2+this.wrapperOffset.top-this.y,this._execEvent('zoomStart')},_zoom:function(r){if(this.enabled&&q.eventType[r.type]===this.initiated){this.options.preventDefault&&r.preventDefault();var w,z,A,s=g.abs(r.touches[0].pageX-r.touches[1].pageX),t=g.abs(r.touches[0].pageY-r.touches[1].pageY),u=g.sqrt(s*s+t*t),v=1/this.touchesDistanceStart*u*this.startScale;this.scaled=!0,v<this.options.zoomMin?v=0.5*this.options.zoomMin*g.pow(2,v/this.options.zoomMin):v>this.options.zoomMax&&(v=2*this.options.zoomMax*g.pow(0.5,this.options.zoomMax/v)),w=v/this.startScale,z=this.originX-this.originX*w+this.startX,A=this.originY-this.originY*w+this.startY,this.scale=v,this.scrollTo(z,A,0)}},_zoomEnd:function(r){if(this.enabled&&q.eventType[r.type]===this.initiated){this.options.preventDefault&&r.preventDefault();var s,t,u;this.isInTransition=0,this.initiated=0,this.scale>this.options.zoomMax?this.scale=this.options.zoomMax:this.scale<this.options.zoomMin&&(this.scale=this.options.zoomMin),this.refresh(),u=this.scale/this.startScale,s=this.originX-this.originX*u+this.startX,t=this.originY-this.originY*u+this.startY,0<s?s=0:s<this.maxScrollX&&(s=this.maxScrollX),0<t?t=0:t<this.maxScrollY&&(t=this.maxScrollY),(this.x!=s||this.y!=t)&&this.scrollTo(s,t,this.options.bounceTime),this.scaled=!1,this._execEvent('zoomEnd')}},zoom:function(r,s,t,u){if(r<this.options.zoomMin?r=this.options.zoomMin:r>this.options.zoomMax&&(r=this.options.zoomMax),r!=this.scale){var v=r/this.scale;s=void 0===s?this.wrapperWidth/2:s,t=void 0===t?this.wrapperHeight/2:t,u=void 0===u?300:u,s=s+this.wrapperOffset.left-this.x,t=t+this.wrapperOffset.top-this.y,s=s-s*v+this.x,t=t-t*v+this.y,this.scale=r,this.refresh(),0<s?s=0:s<this.maxScrollX&&(s=this.maxScrollX),0<t?t=0:t<this.maxScrollY&&(t=this.maxScrollY),this.scrollTo(s,t,u)}},_wheelZoom:function(r){var s,t,u=this;if(clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){u._execEvent('zoomEnd')},400),'deltaX'in r)s=-r.deltaY/g.abs(r.deltaY);else if('wheelDeltaX'in r)s=r.wheelDeltaY/g.abs(r.wheelDeltaY);else if('wheelDelta'in r)s=r.wheelDelta/g.abs(r.wheelDelta);else if('detail'in r)s=-r.detail/g.abs(r.wheelDelta);else return;t=this.scale+s/5,this.zoom(t,r.pageX,r.pageY,0)},_initWheel:function(){q.addEvent(this.wrapper,'wheel',this),q.addEvent(this.wrapper,'mousewheel',this),q.addEvent(this.wrapper,'DOMMouseScroll',this),this.on('destroy',function(){clearTimeout(this.wheelTimeout),this.wheelTimeout=null,q.removeEvent(this.wrapper,'wheel',this),q.removeEvent(this.wrapper,'mousewheel',this),q.removeEvent(this.wrapper,'DOMMouseScroll',this)})},_wheel:function(r){if(this.enabled){r.preventDefault();var s,t,u,v,w=this;if(void 0===this.wheelTimeout&&w._execEvent('scrollStart'),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){w.options.snap||w._execEvent('scrollEnd'),w.wheelTimeout=void 0},400),'deltaX'in r)1===r.deltaMode?(s=-r.deltaX*this.options.mouseWheelSpeed,t=-r.deltaY*this.options.mouseWheelSpeed):(s=-r.deltaX,t=-r.deltaY);else if('wheelDeltaX'in r)s=r.wheelDeltaX/120*this.options.mouseWheelSpeed,t=r.wheelDeltaY/120*this.options.mouseWheelSpeed;else if('wheelDelta'in r)s=t=r.wheelDelta/120*this.options.mouseWheelSpeed;else if('detail'in r)s=t=-r.detail/3*this.options.mouseWheelSpeed;else return;return s*=this.options.invertWheelDirection,t*=this.options.invertWheelDirection,this.hasVerticalScroll||(s=t,t=0),this.options.snap?(u=this.currentPage.pageX,v=this.currentPage.pageY,0<s?u--:0>s&&u++,0<t?v--:0>t&&v++,void this.goToPage(u,v)):void(u=this.x+g.round(this.hasHorizontalScroll?s:0),v=this.y+g.round(this.hasVerticalScroll?t:0),this.directionX=0<s?-1:0>s?1:0,this.directionY=0<t?-1:0>t?1:0,0<u?u=0:u<this.maxScrollX&&(u=this.maxScrollX),0<v?v=0:v<this.maxScrollY&&(v=this.maxScrollY),this.scrollTo(u,v,0))}},_initSnap:function(){this.currentPage={},'string'==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on('refresh',function(){var s,u,v,w,A,D,E,r=0,t=0,z=0,B=this.options.snapStepX||this.wrapperWidth,C=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(!0===this.options.snap)for(v=g.round(B/2),w=g.round(C/2);z>-this.scrollerWidth;){for(this.pages[r]=[],s=0,A=0;A>-this.scrollerHeight;)this.pages[r][s]={x:g.max(z,this.maxScrollX),y:g.max(A,this.maxScrollY),width:B,height:C,cx:z-v,cy:A-w},A-=C,s++;z-=B,r++}else for(D=this.options.snap,s=D.length,u=-1;r<s;r++)E=q.getRect(D[r]),(0==r||E.left<=q.getRect(D[r-1]).left)&&(t=0,u++),this.pages[t]||(this.pages[t]=[]),z=g.max(-E.left,this.maxScrollX),A=g.max(-E.top,this.maxScrollY),v=z-g.round(E.width/2),w=A-g.round(E.height/2),this.pages[t][u]={x:z,y:A,width:E.width,height:E.height,cx:v,cy:w},z>this.maxScrollX&&t++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),0==this.options.snapThreshold%1?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=g.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=g.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on('flick',function(){var r=this.options.snapSpeed||g.max(g.max(g.min(g.abs(this.x-this.startX),1e3),g.min(g.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,r)})},_nearestSnap:function(r,s){if(!this.pages.length)return{x:0,y:0,pageX:0,pageY:0};var t=0,u=this.pages.length,v=0;if(g.abs(r-this.absStartX)<this.snapThresholdX&&g.abs(s-this.absStartY)<this.snapThresholdY)return this.currentPage;for(0<r?r=0:r<this.maxScrollX&&(r=this.maxScrollX),0<s?s=0:s<this.maxScrollY&&(s=this.maxScrollY);t<u;t++)if(r>=this.pages[t][0].cx){r=this.pages[t][0].x;break}for(u=this.pages[t].length;v<u;v++)if(s>=this.pages[0][v].cy){s=this.pages[0][v].y;break}return t==this.currentPage.pageX&&(t+=this.directionX,0>t?t=0:t>=this.pages.length&&(t=this.pages.length-1),r=this.pages[t][0].x),v==this.currentPage.pageY&&(v+=this.directionY,0>v?v=0:v>=this.pages[0].length&&(v=this.pages[0].length-1),s=this.pages[0][v].y),{x:r,y:s,pageX:t,pageY:v}},goToPage:function(r,s,t,u){u=u||this.options.bounceEasing,r>=this.pages.length?r=this.pages.length-1:0>r&&(r=0),s>=this.pages[r].length?s=this.pages[r].length-1:0>s&&(s=0);var v=this.pages[r][s].x,w=this.pages[r][s].y;t=t===void 0?this.options.snapSpeed||g.max(g.max(g.min(g.abs(v-this.x),1e3),g.min(g.abs(w-this.y),1e3)),300):t,this.currentPage={x:v,y:w,pageX:r,pageY:s},this.scrollTo(v,w,t,u)},next:function(r,s){var t=this.currentPage.pageX,u=this.currentPage.pageY;t++,t>=this.pages.length&&this.hasVerticalScroll&&(t=0,u++),this.goToPage(t,u,r,s)},prev:function(r,s){var t=this.currentPage.pageX,u=this.currentPage.pageY;t--,0>t&&this.hasVerticalScroll&&(t=0,u--),this.goToPage(t,u,r,s)},_initKeys:function(){var s={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40},t;if('object'==typeof this.options.keyBindings)for(t in this.options.keyBindings)'string'==typeof this.options.keyBindings[t]&&(this.options.keyBindings[t]=this.options.keyBindings[t].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(t in s)this.options.keyBindings[t]=this.options.keyBindings[t]||s[t];q.addEvent(a,'keydown',this),this.on('destroy',function(){q.removeEvent(a,'keydown',this)})},_key:function(r){if(this.enabled){var A,s=this.options.snap,t=s?this.currentPage.pageX:this.x,u=s?this.currentPage.pageY:this.y,v=q.getTime(),w=this.keyTime||0;switch(this.options.useTransition&&this.isInTransition&&(A=this.getComputedPosition(),this._translate(g.round(A.x),g.round(A.y)),this.isInTransition=!1),this.keyAcceleration=200>v-w?g.min(this.keyAcceleration+0.25,50):0,r.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?t+=s?1:this.wrapperWidth:u+=s?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?t-=s?1:this.wrapperWidth:u-=s?1:this.wrapperHeight;break;case this.options.keyBindings.end:t=s?this.pages.length-1:this.maxScrollX,u=s?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:t=0,u=0;break;case this.options.keyBindings.left:t+=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:u+=s?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:t-=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:u-=s?1:5+this.keyAcceleration>>0;break;default:return;}return s?void this.goToPage(t,u):void(0<t?(t=0,this.keyAcceleration=0):t<this.maxScrollX&&(t=this.maxScrollX,this.keyAcceleration=0),0<u?(u=0,this.keyAcceleration=0):u<this.maxScrollY&&(u=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(t,u,0),this.keyTime=v)}},_animate:function(r,s,t,u){function v(){var E,F,G,D=q.getTime();return D>=B+t?(w.isAnimating=!1,w._translate(r,s),void(w.resetPosition(w.options.bounceTime)||w._execEvent('scrollEnd'))):void(D=(D-B)/t,G=u(D),E=(r-z)*G+z,F=(s-A)*G+A,w._translate(E,F),w.isAnimating&&p(v))}var w=this,z=this.x,A=this.y,B=q.getTime();this.isAnimating=!0,v()},handleEvent:function(r){switch(r.type){case'touchstart':case'pointerdown':case'MSPointerDown':case'mousedown':this._start(r),this.options.zoom&&r.touches&&1<r.touches.length&&this._zoomStart(r);break;case'touchmove':case'pointermove':case'MSPointerMove':case'mousemove':if(this.options.zoom&&r.touches&&r.touches[1])return void this._zoom(r);this._move(r);break;case'touchend':case'pointerup':case'MSPointerUp':case'mouseup':case'touchcancel':case'pointercancel':case'MSPointerCancel':case'mousecancel':if(this.scaled)return void this._zoomEnd(r);this._end(r);break;case'orientationchange':case'resize':this._resize();break;case'transitionend':case'webkitTransitionEnd':case'oTransitionEnd':case'MSTransitionEnd':this._transitionEnd(r);break;case'wheel':case'DOMMouseScroll':case'mousewheel':if('zoom'==this.options.wheelAction)return void this._wheelZoom(r);this._wheel(r);break;case'keydown':this._key(r);}}},o.prototype={handleEvent:function(r){switch(r.type){case'touchstart':case'pointerdown':case'MSPointerDown':case'mousedown':this._start(r);break;case'touchmove':case'pointermove':case'MSPointerMove':case'mousemove':this._move(r);break;case'touchend':case'pointerup':case'MSPointerUp':case'mouseup':case'touchcancel':case'pointercancel':case'MSPointerCancel':case'mousecancel':this._end(r);}},destroy:function(){this.options.fadeScrollbars&&(clearTimeout(this.fadeTimeout),this.fadeTimeout=null),this.options.interactive&&(q.removeEvent(this.indicator,'touchstart',this),q.removeEvent(this.indicator,q.prefixPointerEvent('pointerdown'),this),q.removeEvent(this.indicator,'mousedown',this),q.removeEvent(a,'touchmove',this),q.removeEvent(a,q.prefixPointerEvent('pointermove'),this),q.removeEvent(a,'mousemove',this),q.removeEvent(a,'touchend',this),q.removeEvent(a,q.prefixPointerEvent('pointerup'),this),q.removeEvent(a,'mouseup',this)),this.options.defaultScrollbars&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(r){var s=r.touches?r.touches[0]:r;r.preventDefault(),r.stopPropagation(),this.transitionTime(),this.initiated=!0,this.moved=!1,this.lastPointX=s.pageX,this.lastPointY=s.pageY,this.startTime=q.getTime(),this.options.disableTouch||q.addEvent(a,'touchmove',this),this.options.disablePointer||q.addEvent(a,q.prefixPointerEvent('pointermove'),this),this.options.disableMouse||q.addEvent(a,'mousemove',this),this.scroller._execEvent('beforeScrollStart')},_move:function(r){var t,u,v,w,s=r.touches?r.touches[0]:r,z=q.getTime();this.moved||this.scroller._execEvent('scrollStart'),this.moved=!0,t=s.pageX-this.lastPointX,this.lastPointX=s.pageX,u=s.pageY-this.lastPointY,this.lastPointY=s.pageY,v=this.x+t,w=this.y+u,this._pos(v,w),r.preventDefault(),r.stopPropagation()},_end:function(r){if(this.initiated){if(this.initiated=!1,r.preventDefault(),r.stopPropagation(),q.removeEvent(a,'touchmove',this),q.removeEvent(a,q.prefixPointerEvent('pointermove'),this),q.removeEvent(a,'mousemove',this),this.scroller.options.snap){var s=this.scroller._nearestSnap(this.scroller.x,this.scroller.y),t=this.options.snapSpeed||g.max(g.max(g.min(g.abs(this.scroller.x-s.x),1e3),g.min(g.abs(this.scroller.y-s.y),1e3)),300);(this.scroller.x!=s.x||this.scroller.y!=s.y)&&(this.scroller.directionX=0,this.scroller.directionY=0,this.scroller.currentPage=s,this.scroller.scrollTo(s.x,s.y,t,this.scroller.options.bounceEasing))}this.moved&&this.scroller._execEvent('scrollEnd')}},transitionTime:function(r){r=r||0;var s=q.style.transitionDuration;if(s&&(this.indicatorStyle[s]=r+'ms',!r&&q.isBadAndroid)){this.indicatorStyle[s]='0.0001ms';var t=this;p(function(){'0.0001ms'===t.indicatorStyle[s]&&(t.indicatorStyle[s]='0s')})}},transitionTimingFunction:function(r){this.indicatorStyle[q.style.transitionTimingFunction]=r},refresh:function(){this.transitionTime(),this.indicatorStyle.display=this.options.listenX&&!this.options.listenY?this.scroller.hasHorizontalScroll?'block':'none':this.options.listenY&&!this.options.listenX?this.scroller.hasVerticalScroll?'block':'none':this.scroller.hasHorizontalScroll||this.scroller.hasVerticalScroll?'block':'none',this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll?(q.addClass(this.wrapper,'iScrollBothScrollbars'),q.removeClass(this.wrapper,'iScrollLoneScrollbar'),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right='8px':this.wrapper.style.bottom='8px')):(q.removeClass(this.wrapper,'iScrollBothScrollbars'),q.addClass(this.wrapper,'iScrollLoneScrollbar'),this.options.defaultScrollbars&&this.options.customStyle&&(this.options.listenX?this.wrapper.style.right='2px':this.wrapper.style.bottom='2px')),q.getRect(this.wrapper),this.options.listenX&&(this.wrapperWidth=this.wrapper.clientWidth,this.options.resize?(this.indicatorWidth=g.max(g.round(this.wrapperWidth*this.wrapperWidth/(this.scroller.scrollerWidth||this.wrapperWidth||1)),8),this.indicatorStyle.width=this.indicatorWidth+'px'):this.indicatorWidth=this.indicator.clientWidth,this.maxPosX=this.wrapperWidth-this.indicatorWidth,'clip'==this.options.shrink?(this.minBoundaryX=-this.indicatorWidth+8,this.maxBoundaryX=this.wrapperWidth-8):(this.minBoundaryX=0,this.maxBoundaryX=this.maxPosX),this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX),this.options.listenY&&(this.wrapperHeight=this.wrapper.clientHeight,this.options.resize?(this.indicatorHeight=g.max(g.round(this.wrapperHeight*this.wrapperHeight/(this.scroller.scrollerHeight||this.wrapperHeight||1)),8),this.indicatorStyle.height=this.indicatorHeight+'px'):this.indicatorHeight=this.indicator.clientHeight,this.maxPosY=this.wrapperHeight-this.indicatorHeight,'clip'==this.options.shrink?(this.minBoundaryY=-this.indicatorHeight+8,this.maxBoundaryY=this.wrapperHeight-8):(this.minBoundaryY=0,this.maxBoundaryY=this.maxPosY),this.maxPosY=this.wrapperHeight-this.indicatorHeight,this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY),this.updatePosition()},updatePosition:function(){var r=this.options.listenX&&g.round(this.sizeRatioX*this.scroller.x)||0,s=this.options.listenY&&g.round(this.sizeRatioY*this.scroller.y)||0;this.options.ignoreBoundaries||(r<this.minBoundaryX?('scale'==this.options.shrink&&(this.width=g.max(this.indicatorWidth+r,8),this.indicatorStyle.width=this.width+'px'),r=this.minBoundaryX):r>this.maxBoundaryX?'scale'==this.options.shrink?(this.width=g.max(this.indicatorWidth-(r-this.maxPosX),8),this.indicatorStyle.width=this.width+'px',r=this.maxPosX+this.indicatorWidth-this.width):r=this.maxBoundaryX:'scale'==this.options.shrink&&this.width!=this.indicatorWidth&&(this.width=this.indicatorWidth,this.indicatorStyle.width=this.width+'px'),s<this.minBoundaryY?('scale'==this.options.shrink&&(this.height=g.max(this.indicatorHeight+3*s,8),this.indicatorStyle.height=this.height+'px'),s=this.minBoundaryY):s>this.maxBoundaryY?'scale'==this.options.shrink?(this.height=g.max(this.indicatorHeight-3*(s-this.maxPosY),8),this.indicatorStyle.height=this.height+'px',s=this.maxPosY+this.indicatorHeight-this.height):s=this.maxBoundaryY:'scale'==this.options.shrink&&this.height!=this.indicatorHeight&&(this.height=this.indicatorHeight,this.indicatorStyle.height=this.height+'px')),this.x=r,this.y=s,this.scroller.options.useTransform?this.indicatorStyle[q.style.transform]='translate('+r+'px,'+s+'px)'+this.scroller.translateZ:(this.indicatorStyle.left=r+'px',this.indicatorStyle.top=s+'px')},_pos:function(r,s){0>r?r=0:r>this.maxPosX&&(r=this.maxPosX),0>s?s=0:s>this.maxPosY&&(s=this.maxPosY),r=this.options.listenX?g.round(r/this.sizeRatioX):this.scroller.x,s=this.options.listenY?g.round(s/this.sizeRatioY):this.scroller.y,this.scroller.scrollTo(r,s)},fade:function(r,s){if(!s||this.visible){clearTimeout(this.fadeTimeout),this.fadeTimeout=null;var t=r?250:500,u=r?0:300;r=r?'1':'0',this.wrapperStyle[q.style.transitionDuration]=t+'ms',this.fadeTimeout=setTimeout(function(v){this.wrapperStyle.opacity=v,this.visible=+v}.bind(this,r),u)}}},h.utils=q,'undefined'!=typeof module&&module.exports?module.exports=h:'function'==typeof define&&define.amd?define(function(){return h}):a.IScroll=h})(window,document,Math);
  