var IScroll=function(k,n,h){function p(a,b){this.wrapper=typeof a=="string"?n.querySelector(a):a;this.scroller=this.wrapper.children[0];this.scrollerStyle=this.scroller.style;this.options={resizeIndicator:true,mouseWheelSpeed:20,snapThreshold:0.334,startX:0,startY:0,scrollY:true,directionLockThreshold:5,momentum:true,bounce:true,bounceTime:600,bounceEasing:"",preventDefault:true,HWCompositing:true,useTransition:true,useTransform:true,pageScroll:false};for(var d in b)this.options[d]=b[d];this.translateZ=
this.options.HWCompositing&&f.hasPerspective?" translateZ(0)":"";this.options.useTransition=f.hasTransition&&this.options.useTransition;this.options.useTransform=f.hasTransform&&this.options.useTransform;this.options.eventPassthrough=this.options.eventPassthrough===true?"vertical":this.options.eventPassthrough;this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault;this.options.scrollY=this.options.eventPassthrough=="vertical"?false:this.options.scrollY;this.options.scrollX=
this.options.eventPassthrough=="horizontal"?false: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=typeof this.options.bounceEasing=="string"?f.ease[this.options.bounceEasing]||f.ease.circular:this.options.bounceEasing;this.options.resizePolling=this.options.resizePolling===undefined?60:this.options.resizePolling;if(this.options.tap===
true)this.options.tap="tap";this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1;this.directionY=this.directionX=this.y=this.x=0;this._events={};this._init();this.refresh();this.scrollTo(this.options.startX,this.options.startY);this.enable()}function s(a,b,d){var e=n.createElement("div"),j=n.createElement("div");if(d===true){e.style.cssText="position:absolute;z-index:9999";j.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"}j.className=
"iScrollIndicator";if(a=="h"){if(d===true){e.style.cssText+=";height:7px;left:2px;right:2px;bottom:0";j.style.height="100%"}e.className="iScrollHorizontalScrollbar"}else{if(d===true){e.style.cssText+=";width:7px;bottom:2px;top:2px;right:1px";j.style.width="100%"}e.className="iScrollVerticalScrollbar"}if(!b)e.style.pointerEvents="none";e.appendChild(j);return e}function q(a,b){this.wrapper=typeof b.el=="string"?n.querySelector(b.el):b.el;this.indicator=this.wrapper.children[0];this.indicatorStyle=
this.indicator.style;this.scroller=a;this.options={listenX:true,listenY:true,interactive:false,resize:true,defaultScrollbars:false,speedRatioX:0,speedRatioY:0};for(var d in b)this.options[d]=b[d];this.sizeRatioY=this.sizeRatioX=1;this.maxPosY=this.maxPosX=0;if(this.options.interactive){f.addEvent(this.indicator,"touchstart",this);f.addEvent(this.indicator,"MSPointerDown",this);f.addEvent(this.indicator,"mousedown",this);f.addEvent(k,"touchend",this);f.addEvent(k,"MSPointerUp",this);f.addEvent(k,"mouseup",
this)}}var t=k.requestAnimationFrame||k.webkitRequestAnimationFrame||k.mozRequestAnimationFrame||k.oRequestAnimationFrame||k.msRequestAnimationFrame||function(a){k.setTimeout(a,1E3/60)},f=function(){function a(c){if(e===false)return false;if(e==="")return c;return e+c.charAt(0).toUpperCase()+c.substr(1)}var b={},d=n.createElement("div").style,e=function(){for(var c=["t","webkitT","MozT","msT","OT"],g,i=0,l=c.length;i<l;i++){g=c[i]+"ransform";if(g in d)return c[i].substr(0,c[i].length-1)}return false}();
b.getTime=Date.now||function(){return(new Date).getTime()};b.extend=function(c,g){for(var i in g)c[i]=g[i]};b.addEvent=function(c,g,i,l){c.addEventListener(g,i,!!l)};b.removeEvent=function(c,g,i,l){c.removeEventListener(g,i,!!l)};b.momentum=function(c,g,i,l,o){g=c-g;i=h.abs(g)/i;var m;m=c+i*i/0.0012*(g<0?-1:1);g=i/6.0E-4;if(m<l){m=o?l-o/2.5*(i/8):l;g=h.abs(m-c);g=g/i}else if(m>0){m=o?o/2.5*(i/8):0;g=h.abs(c)+m;g=g/i}return{destination:h.round(m),duration:g}};var j=a("transform");b.extend(b,{hasTransform:j!==
false,hasPerspective:a("perspective")in d,hasTouch:"ontouchstart"in k,hasPointer:navigator.msPointerEnabled,hasTransition:a("transition")in d});b.isAndroidBrowser=/Android/.test(k.navigator.appVersion)&&/Version\/\d/.test(k.navigator.appVersion);b.extend(b.style={},{transform:j,transitionTimingFunction:a("transitionTimingFunction"),transitionDuration:a("transitionDuration"),transformOrigin:a("transformOrigin")});b.hasClass=function(c,g){return RegExp("(^|\\s)"+g+"(\\s|$)").test(c.className)};b.addClass=
function(c,g){if(!b.hasClass(c,g)){var i=c.className.split(" ");i.push(g);c.className=i.join(" ")}};b.removeClass=function(c,g){if(b.hasClass(c,g))c.className=c.className.replace(RegExp("(^|\\s)"+g+"(\\s|$)","g"),"")};b.offset=function(c){for(var g=-c.offsetLeft,i=-c.offsetTop;c=c.offsetParent;){g-=c.offsetLeft;i-=c.offsetTop}return{left:g,top:i}};b.extend(b.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3});b.extend(b.ease=
{},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(c){return c*(2-c)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(c){return h.sqrt(1- --c*c)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(c){return(c-=1)*c*(5*c+4)+1}},bounce:{style:"",fn:function(c){return(c/=1)<1/2.75?7.5625*c*c:c<2/2.75?7.5625*(c-=1.5/2.75)*c+0.75:c<2.5/2.75?7.5625*(c-=2.25/2.75)*c+0.9375:7.5625*(c-=2.625/2.75)*c+0.984375}},elastic:{style:"",fn:function(c){if(c===0)return 0;
if(c==1)return 1;return 0.4*h.pow(2,-10*c)*h.sin((c-0.055)*2*h.PI/0.22)+1}}});b.tap=function(c,g){var i=n.createEvent("Event");i.initEvent(g,true,true);i.pageX=c.pageX;i.pageY=c.pageY;c.target.dispatchEvent(i)};b.click=function(c){var g=c.target,i;if(g.tagName!="SELECT"&&g.tagName!="INPUT"&&g.tagName!="TEXTAREA"){i=n.createEvent("MouseEvents");i.initMouseEvent("click",true,true,c.view,1,g.screenX,g.screenY,g.clientX,g.clientY,c.ctrlKey,c.altKey,c.shiftKey,c.metaKey,0,null);i._constructed=true;g.dispatchEvent(i)}};
return b}();p.prototype={version:"5.0.4",_init:function(){this._initEvents();if(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(true);this._execEvent("destroy")},_transitionEnd:function(a){if(a.target==this.scroller){this._transitionTime(0);this.resetPosition(this.options.bounceTime)||this._execEvent("scrollEnd")}},_start:function(a){if(f.eventType[a.type]!=
1)if(a.button!==0)return;if(!(!this.enabled||this.initiated&&f.eventType[a.type]!==this.initiated)){this.options.preventDefault&&!f.isAndroidBrowser&&a.preventDefault();var b=a.touches?a.touches[0]:a;this.initiated=f.eventType[a.type];this.moved=false;this.directionLocked=this.directionY=this.directionX=this.distY=this.distX=0;this._transitionTime();this.isAnimating=false;this.startTime=f.getTime();if(this.options.useTransition&&this.isInTransition){a=this.getComputedPosition();this._translate(h.round(a.x),
h.round(a.y));this.isInTransition=false}this.startX=this.x;this.startY=this.y;this.absStartX=this.x;this.absStartY=this.y;this.pointX=b.pageX;this.pointY=b.pageY;this._execEvent("scrollStart")}},_move:function(a){if(!(!this.enabled||f.eventType[a.type]!==this.initiated)){if(this.options.preventDefault)this.options.pageScroll||a.preventDefault();var b=a.touches?a.touches[0]:a,d=this.hasHorizontalScroll?b.pageX-this.pointX:0,e=this.hasVerticalScroll?b.pageY-this.pointY:0,j=f.getTime(),c;this.pointX=
b.pageX;this.pointY=b.pageY;this.distX+=d;this.distY+=e;b=h.abs(this.distX);c=h.abs(this.distY);if(!(j-this.endTime>300&&b<10&&c<10)){if(!this.directionLocked&&!this.options.freeScroll)this.directionLocked=b>c+this.options.directionLockThreshold?"h":c>=b+this.options.directionLockThreshold?"v":"n";if(this.directionLocked=="h"){if(this.options.eventPassthrough=="vertical")this.options.pageScroll||a.preventDefault();else if(this.options.eventPassthrough=="horizontal"){this.initiated=false;return}e=
0}else if(this.directionLocked=="v"){if(this.options.eventPassthrough=="horizontal")this.options.pageScroll||a.preventDefault();else if(this.options.eventPassthrough=="vertical"){this.initiated=false;return}d=0}a=this.x+d;b=this.y+e;if(a>0||a<this.maxScrollX)a=this.options.bounce?this.x+d/3:a>0?0:this.maxScrollX;if(b>0||b<this.maxScrollY)b=this.options.bounce?this.y+e/3:b>0?0:this.maxScrollY;this.directionX=d>0?-1:d<0?1:0;this.directionY=e>0?-1:e<0?1:0;this.moved=true;this._translate(a,b);if(j-this.startTime>
300){this.startTime=j;this.startX=this.x;this.startY=this.y}}}},_end:function(a){if(!(!this.enabled||f.eventType[a.type]!==this.initiated)){this.options.preventDefault&&a.preventDefault();var b;b=f.getTime()-this.startTime;var d=h.round(this.x),e=h.round(this.y),j=h.abs(d-this.startX),c=h.abs(e-this.startY),g=0,i="";this.scrollTo(d,e);this.initiated=this.isInTransition=0;this.endTime=f.getTime();if(!this.resetPosition(this.options.bounceTime))if(this.moved)if(this._events.flick&&b<200&&j<100&&c<100)this._execEvent("flick");
else{if(this.options.momentum&&b<300){a=this.hasHorizontalScroll?f.momentum(this.x,this.startX,b,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:d,duration:0};b=this.hasVerticalScroll?f.momentum(this.y,this.startY,b,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:e,duration:0};d=a.destination;e=b.destination;g=h.max(a.duration,b.duration);this.isInTransition=1}if(this.options.snap){this.currentPage=e=this._nearestSnap(d,e);d=e.x;e=e.y;g=this.options.snapSpeed||
h.max(h.max(h.min(j,1E3),h.min(j,1E3)),300);this.directionY=this.directionX=0;i=this.options.bounceEasing}if(d!=this.x||e!=this.y){if(d>0||d<this.maxScrollX||e>0||e<this.maxScrollY)i=f.ease.quadratic;this.scrollTo(d,e,g,i)}else this._execEvent("scrollEnd")}else{this.options.tap&&f.tap(a,this.options.tap);this.options.click&&f.click(a)}}},_resize:function(){var a=this;clearTimeout(this.resizeTimeout);this.resizeTimeout=setTimeout(function(){a.refresh()},this.options.resizePolling)},resetPosition:function(a){var b=
this.x,d=this.y;a=a||0;if(!this.hasHorizontalScroll||this.x>0)b=0;else if(this.x<this.maxScrollX)b=this.maxScrollX;if(!this.hasVerticalScroll||this.y>0)d=0;else if(this.y<this.maxScrollY)d=this.maxScrollY;if(b==this.x&&d==this.y)return false;this.scrollTo(b,d,a,this.options.bounceEasing);return true},disable:function(){this.enabled=false},enable:function(){this.enabled=true},refresh:function(){this.wrapperWidth=this.wrapper.clientWidth;this.wrapperHeight=this.wrapper.clientHeight;this.scrollerWidth=
this.scroller.offsetWidth;this.scrollerHeight=this.scroller.offsetHeight;this.maxScrollX=this.wrapperWidth-this.scrollerWidth;this.maxScrollY=this.wrapperHeight-this.scrollerHeight;this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0;this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0;if(!this.hasHorizontalScroll){this.maxScrollX=0;this.scrollerWidth=this.wrapperWidth}if(!this.hasVerticalScroll){this.maxScrollY=0;this.scrollerHeight=this.wrapperHeight}this.directionY=this.directionX=
this.endTime=0;this.wrapperOffset=f.offset(this.wrapper);this._execEvent("refresh");this.resetPosition();if(this.options.snap){var a=this._nearestSnap(this.x,this.y);if(!(this.x==a.x&&this.y==a.y)){this.currentPage=a;this.scrollTo(a.x,a.y)}}},on:function(a,b){this._events[a]||(this._events[a]=[]);this._events[a].push(b)},_execEvent:function(a){if(this._events[a]){var b=0,d=this._events[a].length;if(d)for(;b<d;b++)this._events[a][b].call(this)}},scrollBy:function(a,b,d,e){a=this.x+a;b=this.y+b;d=d||
0;this.scrollTo(a,b,d,e)},scrollTo:function(a,b,d,e){e=e||f.ease.circular;if(!d||this.options.useTransition&&e.style){this._transitionTimingFunction(e.style);this._transitionTime(d);this._translate(a,b)}else this._animate(a,b,d,e.fn)},scrollToElement:function(a,b,d,e,j){if(a=a.nodeType?a:this.scroller.querySelector(a)){var c=f.offset(a);c.left-=this.wrapperOffset.left;c.top-=this.wrapperOffset.top;if(d===true)d=h.round(a.offsetWidth/2-this.wrapper.offsetWidth/2);if(e===true)e=h.round(a.offsetHeight/
2-this.wrapper.offsetHeight/2);c.left-=d||0;c.top-=e||0;c.left=c.left>0?0:c.left<this.maxScrollX?this.maxScrollX:c.left;c.top=c.top>0?0:c.top<this.maxScrollY?this.maxScrollY:c.top;b=b===undefined||b===null||b==="auto"?h.max(h.abs(c.left)*2,h.abs(c.top)*2):b;this.scrollTo(c.left,c.top,b,j)}},_transitionTime:function(a){a=a||0;this.scrollerStyle[f.style.transitionDuration]=a+"ms";this.indicator1&&this.indicator1.transitionTime(a);this.indicator2&&this.indicator2.transitionTime(a)},_transitionTimingFunction:function(a){this.scrollerStyle[f.style.transitionTimingFunction]=
a;this.indicator1&&this.indicator1.transitionTimingFunction(a);this.indicator2&&this.indicator2.transitionTimingFunction(a)},_translate:function(a,b){if(this.options.useTransform)this.scrollerStyle[f.style.transform]="translate("+a+"px,"+b+"px)"+this.translateZ;else{a=h.round(a);b=h.round(b);this.scrollerStyle.left=a+"px";this.scrollerStyle.top=b+"px"}this.x=a;this.y=b;this.indicator1&&this.indicator1.updatePosition();this.indicator2&&this.indicator2.updatePosition()},_initEvents:function(a){a=a?
f.removeEvent:f.addEvent;var b=this.options.bindToWrapper?this.wrapper:k;a(k,"orientationchange",this);a(k,"resize",this);a(this.wrapper,"mousedown",this);a(b,"mousemove",this);a(b,"mousecancel",this);a(b,"mouseup",this);if(f.hasPointer){a(this.wrapper,"MSPointerDown",this);a(b,"MSPointerMove",this);a(b,"MSPointerCancel",this);a(b,"MSPointerUp",this)}if(f.hasTouch){a(this.wrapper,"touchstart",this);a(b,"touchmove",this);a(b,"touchcancel",this);a(b,"touchend",this)}a(this.scroller,"transitionend",
this);a(this.scroller,"webkitTransitionEnd",this);a(this.scroller,"oTransitionEnd",this);a(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var a=k.getComputedStyle(this.scroller,null),b;if(this.options.useTransform){a=a[f.style.transform].split(")")[0].split(", ");b=+(a[12]||a[4]);a=+(a[13]||a[5])}else{b=+a.left.replace(/[^-\d]/g,"");a=+a.top.replace(/[^-\d]/g,"")}return{x:b,y:a}},_initIndicators:function(){var a=this.options.interactiveScrollbars,b=typeof this.options.scrollbars!=
"string",d,e;if(this.options.scrollbars){if(this.options.scrollY){d={el:s("v",a,this.options.scrollbars),interactive:a,defaultScrollbars:true,customStyle:b,resize:this.options.resizeIndicator,listenX:false};this.wrapper.appendChild(d.el)}if(this.options.scrollX){e={el:s("h",a,this.options.scrollbars),interactive:a,defaultScrollbars:true,customStyle:b,resize:this.options.resizeIndicator,listenY:false};this.wrapper.appendChild(e.el)}}else{d=this.options.indicators.length?this.options.indicators[0]:
this.options.indicators;e=this.options.indicators[1]&&this.options.indicators[1]}if(d)this.indicator1=new q(this,d);if(e)this.indicator2=new q(this,e);this.on("refresh",function(){this.indicator1&&this.indicator1.refresh();this.indicator2&&this.indicator2.refresh()});this.on("destroy",function(){if(this.indicator1){this.indicator1.destroy();this.indicator1=null}if(this.indicator2){this.indicator2.destroy();this.indicator2=null}})},_initWheel:function(){f.addEvent(this.wrapper,"mousewheel",this);f.addEvent(this.wrapper,
"DOMMouseScroll",this);this.on("destroy",function(){f.removeEvent(this.wrapper,"mousewheel",this);f.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(a){if(this.enabled){var b,d=this;clearTimeout(this.wheelTimeout);this.wheelTimeout=setTimeout(function(){d._execEvent("scrollEnd")},400);a.preventDefault();if("wheelDeltaX"in a){b=a.wheelDeltaX/120;a=a.wheelDeltaY/120}else if("wheelDelta"in a)b=a=a.wheelDelta/120;else if("detail"in a)b=a=-a.detail/3;else return;b*=this.options.mouseWheelSpeed;
a*=this.options.mouseWheelSpeed;this.hasVerticalScroll||(b=a);b=this.x+(this.hasHorizontalScroll?b*this.options.invertWheelDirection:0);a=this.y+(this.hasVerticalScroll?a*this.options.invertWheelDirection:0);if(b>0)b=0;else if(b<this.maxScrollX)b=this.maxScrollX;if(a>0)a=0;else if(a<this.maxScrollY)a=this.maxScrollY;this.scrollTo(b,a,0)}},_initSnap:function(){this.currentPage={};if(typeof this.options.snap=="string")this.options.snap=this.scroller.querySelectorAll(this.options.snap);this.on("refresh",
function(){var a=0,b,d=0,e,j,c,g=0,i;e=this.options.snapStepX||this.wrapperWidth;var l=this.options.snapStepY||this.wrapperHeight;this.pages=[];if(this.options.snap===true){j=h.round(e/2);for(c=h.round(l/2);g>-this.scrollerWidth;){this.pages[a]=[];for(i=b=0;i>-this.scrollerHeight;){this.pages[a][b]={x:h.max(g,this.maxScrollX),y:h.max(i,this.maxScrollY),width:e,height:l,cx:g-j,cy:i-c};i-=l;b++}g-=e;a++}}else{l=this.options.snap;b=l.length;for(e=-1;a<b;a++){if(a===0||l[a].offsetLeft<=l[a-1].offsetLeft){d=
0;e++}this.pages[d]||(this.pages[d]=[]);g=h.max(-l[a].offsetLeft,this.maxScrollX);i=h.max(-l[a].offsetTop,this.maxScrollY);j=g-h.round(l[a].offsetWidth/2);c=i-h.round(l[a].offsetHeight/2);this.pages[d][e]={x:g,y:i,width:l[a].offsetWidth,height:l[a].offsetHeight,cx:j,cy:c};g>this.maxScrollX&&d++}}this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0);if(this.options.snapThreshold%1===0)this.snapThresholdY=this.snapThresholdX=this.options.snapThreshold;else{this.snapThresholdX=h.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*
this.options.snapThreshold);this.snapThresholdY=h.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold)}});this.on("flick",function(){this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,this.options.snapSpeed||h.max(h.max(h.min(h.abs(this.x-this.startX),1E3),h.min(h.abs(this.y-this.startY),1E3)),300))})},_nearestSnap:function(a,b){var d=0,e=this.pages.length,j=0;if(h.abs(a-this.absStartX)<this.snapThresholdX&&h.abs(b-
this.absStartY)<this.snapThresholdY)return this.currentPage;if(a>0)a=0;else if(a<this.maxScrollX)a=this.maxScrollX;if(b>0)b=0;else if(b<this.maxScrollY)b=this.maxScrollY;for(;d<e;d++)if(a>=this.pages[d][0].cx){a=this.pages[d][0].x;break}for(e=this.pages[d].length;j<e;j++)if(b>=this.pages[0][j].cy){b=this.pages[0][j].y;break}if(d==this.currentPage.pageX){d+=this.directionX;if(d<0)d=0;else if(d>=this.pages.length)d=this.pages.length-1;a=this.pages[d][0].x}if(j==this.currentPage.pageY){j+=this.directionY;
if(j<0)j=0;else if(j>=this.pages[0].length)j=this.pages[0].length-1;b=this.pages[0][j].y}return{x:a,y:b,pageX:d,pageY:j}},goToPage:function(a,b,d,e){e=e||this.options.bounceEasing;if(a>=this.pages.length)a=this.pages.length-1;else if(a<0)a=0;if(b>=this.pages[0].length)b=this.pages[0].length-1;else if(b<0)b=0;var j=this.pages[a][b].x,c=this.pages[a][b].y;d=d===undefined?this.options.snapSpeed||h.max(h.max(h.min(h.abs(j-this.x),1E3),h.min(h.abs(c-this.y),1E3)),300):d;this.currentPage={x:j,y:c,pageX:a,
pageY:b};this.scrollTo(j,c,d,e)},next:function(a,b){var d=this.currentPage.pageX,e=this.currentPage.pageY;d++;if(d>=this.pages.length&&this.hasVerticalScroll){d=0;e++}this.goToPage(d,e,a,b)},prev:function(a,b){var d=this.currentPage.pageX,e=this.currentPage.pageY;d--;if(d<0&&this.hasVerticalScroll){d=0;e--}this.goToPage(d,e,a,b)},_initKeys:function(){var a={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40},b;if(typeof this.options.keyBindings=="object")for(b in this.options.keyBindings){if(typeof this.options.keyBindings[b]==
"string")this.options.keyBindings[b]=this.options.keyBindings[b].toUpperCase().charCodeAt(0)}else this.options.keyBindings={};for(b in a)this.options.keyBindings[b]=this.options.keyBindings[b]||a[b];f.addEvent(k,"keydown",this);this.on("destroy",function(){f.removeEvent(k,"keydown",this)})},_key:function(a){if(this.enabled){var b=this.options.snap,d=b?this.currentPage.pageX:this.x,e=b?this.currentPage.pageY:this.y,j=f.getTime(),c=this.keyTime||0,g;if(this.options.useTransition&&this.isInTransition){g=
this.getComputedPosition();this._translate(h.round(g.x),h.round(g.y));this.isInTransition=false}this.keyAcceleration=j-c<200?h.min(this.keyAcceleration+0.25,50):0;switch(a.keyCode){case this.options.keyBindings.pageUp:if(this.hasHorizontalScroll&&!this.hasVerticalScroll)d+=b?1:this.wrapperWidth;else e+=b?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:if(this.hasHorizontalScroll&&!this.hasVerticalScroll)d-=b?1:this.wrapperWidth;else e-=b?1:this.wrapperHeight;break;case this.options.keyBindings.end:d=
b?this.pages.length-1:this.maxScrollX;e=b?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:e=d=0;break;case this.options.keyBindings.left:d+=b?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:e+=b?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:d-=b?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:e-=b?1:5+this.keyAcceleration>>0}if(b)this.goToPage(d,e);else{if(d>0)this.keyAcceleration=d=0;else if(d<this.maxScrollX){d=
this.maxScrollX;this.keyAcceleration=0}if(e>0)this.keyAcceleration=e=0;else if(e<this.maxScrollY){e=this.maxScrollY;this.keyAcceleration=0}this.scrollTo(d,e,0);this.keyTime=j}}},_animate:function(a,b,d,e){function j(){var m=f.getTime(),r;if(m>=o){c.isAnimating=false;c._translate(a,b);c.resetPosition(c.options.bounceTime)||c._execEvent("scrollEnd")}else{m=(m-l)/d;r=e(m);m=(a-g)*r+g;c._translate(m,(b-i)*r+i);c.isAnimating&&t(j)}}var c=this,g=this.x,i=this.y,l=f.getTime(),o=l+d;this.isAnimating=true;
j()},handleEvent:function(a){switch(a.type){case "touchstart":case "MSPointerDown":case "mousedown":this._start(a);break;case "touchmove":case "MSPointerMove":case "mousemove":this._move(a);break;case "touchend":case "MSPointerUp":case "mouseup":case "touchcancel":case "MSPointerCancel":case "mousecancel":this._end(a);break;case "orientationchange":case "resize":this._resize();break;case "transitionend":case "webkitTransitionEnd":case "oTransitionEnd":case "MSTransitionEnd":this._transitionEnd(a);
break;case "DOMMouseScroll":case "mousewheel":this._wheel(a);break;case "keydown":this._key(a)}}};q.prototype={handleEvent:function(a){switch(a.type){case "touchstart":case "MSPointerDown":case "mousedown":this._start(a);break;case "touchmove":case "MSPointerMove":case "mousemove":this._move(a);break;case "touchend":case "MSPointerUp":case "mouseup":case "touchcancel":case "MSPointerCancel":case "mousecancel":this._end(a)}},destroy:function(){if(this.options.interactive){f.removeEvent(this.indicator,
"touchstart",this);f.removeEvent(this.indicator,"MSPointerDown",this);f.removeEvent(this.indicator,"mousedown",this);f.removeEvent(k,"touchmove",this);f.removeEvent(k,"MSPointerMove",this);f.removeEvent(k,"mousemove",this);f.removeEvent(k,"touchend",this);f.removeEvent(k,"MSPointerUp",this);f.removeEvent(k,"mouseup",this)}this.options.defaultScrollbars&&this.wrapper.parentNode.removeChild(this.wrapper)},_start:function(a){var b=a.touches?a.touches[0]:a;a.preventDefault();a.stopPropagation();this.transitionTime(0);
this.initiated=true;this.moved=false;this.lastPointX=b.pageX;this.lastPointY=b.pageY;this.startTime=f.getTime();f.addEvent(k,"touchmove",this);f.addEvent(k,"MSPointerMove",this);f.addEvent(k,"mousemove",this);this.scroller._execEvent("scrollStart")},_move:function(a){var b=a.touches?a.touches[0]:a,d,e;f.getTime();this.moved=true;d=b.pageX-this.lastPointX;this.lastPointX=b.pageX;e=b.pageY-this.lastPointY;this.lastPointY=b.pageY;this._pos(this.x+d,this.y+e);a.preventDefault();a.stopPropagation()},_end:function(a){if(this.initiated){this.initiated=
false;a.preventDefault();a.stopPropagation();f.removeEvent(k,"touchmove",this);f.removeEvent(k,"MSPointerMove",this);f.removeEvent(k,"mousemove",this);this.moved&&this.scroller._execEvent("scrollEnd")}},transitionTime:function(a){a=a||0;this.indicatorStyle[f.style.transitionDuration]=a+"ms"},transitionTimingFunction:function(a){this.indicatorStyle[f.style.transitionTimingFunction]=a},refresh:function(){this.transitionTime(0);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";if(this.scroller.hasHorizontalScroll&&this.scroller.hasVerticalScroll){f.addClass(this.wrapper,"iScrollBothScrollbars");f.removeClass(this.wrapper,"iScrollLoneScrollbar");if(this.options.defaultScrollbars&&this.options.customStyle)if(this.options.listenX)this.wrapper.style.right=
"8px";else this.wrapper.style.bottom="8px"}else{f.removeClass(this.wrapper,"iScrollBothScrollbars");f.addClass(this.wrapper,"iScrollLoneScrollbar");if(this.options.defaultScrollbars&&this.options.customStyle)if(this.options.listenX)this.wrapper.style.right="2px";else this.wrapper.style.bottom="2px"}if(this.options.listenX){this.wrapperWidth=this.wrapper.clientWidth;if(this.options.resize){this.indicatorWidth=h.max(h.round(this.wrapperWidth*this.wrapperWidth/this.scroller.scrollerWidth),8);this.indicatorStyle.width=
this.indicatorWidth+"px"}else this.indicatorWidth=this.indicator.clientWidth;this.maxPosX=this.wrapperWidth-this.indicatorWidth;this.sizeRatioX=this.options.speedRatioX||this.scroller.maxScrollX&&this.maxPosX/this.scroller.maxScrollX}if(this.options.listenY){this.wrapperHeight=this.wrapper.clientHeight;if(this.options.resize){this.indicatorHeight=h.max(h.round(this.wrapperHeight*this.wrapperHeight/this.scroller.scrollerHeight),8);this.indicatorStyle.height=this.indicatorHeight+"px"}else this.indicatorHeight=
this.indicator.clientHeight;this.maxPosY=this.wrapperHeight-this.indicatorHeight;this.sizeRatioY=this.options.speedRatioY||this.scroller.maxScrollY&&this.maxPosY/this.scroller.maxScrollY}this.updatePosition()},updatePosition:function(){var a=h.round(this.sizeRatioX*this.scroller.x)||0,b=h.round(this.sizeRatioY*this.scroller.y)||0;if(!this.options.ignoreBoundaries){if(a<0)a=0;else if(a>this.maxPosX)a=this.maxPosX;if(b<0)b=0;else if(b>this.maxPosY)b=this.maxPosY}this.x=a;this.y=b;if(this.scroller.options.useTransform)this.indicatorStyle[f.style.transform]=
"translate("+a+"px,"+b+"px)"+this.scroller.translateZ;else{this.indicatorStyle.left=a+"px";this.indicatorStyle.top=b+"px"}},_pos:function(a,b){if(a<0)a=0;else if(a>this.maxPosX)a=this.maxPosX;if(b<0)b=0;else if(b>this.maxPosY)b=this.maxPosY;a=this.options.listenX?h.round(a/this.sizeRatioX):this.scroller.x;b=this.options.listenY?h.round(b/this.sizeRatioY):this.scroller.y;this.scroller.scrollTo(a,b)}};p.ease=f.ease;return p}(window,document,Math);