Changesets · Branches · Tags · Compare
| Changeset | 2a7edf4adfadc44249e16c2888f9ea7a4d83ca93294ae30230b4240687eeb7c6 |
|---|---|
| Author | cubiq <matteo@cubiq.org> · 2014-01-08 18:48 +01:00 |
| Committer | cubiq <matteo@cubiq.org> · 2014-01-08 18:48 +01:00 |
| Parents | 0a2801d9d66c |
2 files changed
modified .gitignore +2 −1
| @@ -1,3 +1,4 @@ | ||
| 1 | 1 | .DS_Store |
| 2 | 2 | ._* |
| 3 | -node_modules | |
| No newline at the end of the file | ||
| 3 | +node_modules | |
| 4 | +dist | |
| No newline at the end of the file |
deleted dist/iscroll-infinite-min.js +0 −2
| @@ -1,2 +0,0 @@ | ||
| 1 | -/*! iScroll v5.1.0 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */ | |
| 2 | -!function(t,i,e){function s(t,e){this.wrapper="string"==typeof t?i.querySelector(t):t,this.scroller=this.wrapper.children[0],this.scrollerStyle=this.scroller.style,this.options={mouseWheelSpeed:20,snapThreshold:.334,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};for(var s in e)this.options[s]=e[s];this.translateZ=this.options.HWCompositing&&o.hasPerspective?" translateZ(0)":"",this.options.useTransition=o.hasTransition&&this.options.useTransition,this.options.useTransform=o.hasTransform&&this.options.useTransform,this.options.eventPassthrough=this.options.eventPassthrough===!0?"vertical":this.options.eventPassthrough,this.options.preventDefault=!this.options.eventPassthrough&&this.options.preventDefault,this.options.scrollY="vertical"==this.options.eventPassthrough?!1:this.options.scrollY,this.options.scrollX="horizontal"==this.options.eventPassthrough?!1: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?o.ease[this.options.bounceEasing]||o.ease.circular:this.options.bounceEasing,this.options.resizePolling=void 0===this.options.resizePolling?60:this.options.resizePolling,this.options.tap===!0&&(this.options.tap="tap"),this.options.invertWheelDirection=this.options.invertWheelDirection?-1:1,this.options.infiniteElements&&(this.options.probeType=3),3==this.options.probeType&&(this.options.useTransition=!1),this.x=0,this.y=0,this.directionX=0,this.directionY=0,this._events={},this._init(),this.refresh(),this.scrollTo(this.options.startX,this.options.startY),this.enable()}var n=t.requestAnimationFrame||t.webkitRequestAnimationFrame||t.mozRequestAnimationFrame||t.oRequestAnimationFrame||t.msRequestAnimationFrame||function(i){t.setTimeout(i,1e3/60)},o=function(){function s(t){return h===!1?!1:""===h?t:h+t.charAt(0).toUpperCase()+t.substr(1)}var n={},o=i.createElement("div").style,h=function(){for(var t,i=["t","webkitT","MozT","msT","OT"],e=0,s=i.length;s>e;e++)if(t=i[e]+"ransform",t in o)return i[e].substr(0,i[e].length-1);return!1}();n.getTime=Date.now||function(){return(new Date).getTime()},n.extend=function(t,i){for(var e in i)t[e]=i[e]},n.addEvent=function(t,i,e,s){t.addEventListener(i,e,!!s)},n.removeEvent=function(t,i,e,s){t.removeEventListener(i,e,!!s)},n.momentum=function(t,i,s,n,o){var h,r,a=t-i,l=e.abs(a)/s,c=6e-4;return h=t+l*l/(2*c)*(0>a?-1:1),r=l/c,n>h?(h=o?n-o/2.5*(l/8):n,a=e.abs(h-t),r=a/l):h>0&&(h=o?o/2.5*(l/8):0,a=e.abs(t)+h,r=a/l),{destination:e.round(h),duration:r}};var r=s("transform");return n.extend(n,{hasTransform:r!==!1,hasPerspective:s("perspective")in o,hasTouch:"ontouchstart"in t,hasPointer:navigator.msPointerEnabled,hasTransition:s("transition")in o}),n.isBadAndroid=/Android /.test(t.navigator.appVersion)&&!/Chrome\/\d/.test(t.navigator.appVersion),n.extend(n.style={},{transform:r,transitionTimingFunction:s("transitionTimingFunction"),transitionDuration:s("transitionDuration"),transitionDelay:s("transitionDelay"),transformOrigin:s("transformOrigin")}),n.hasClass=function(t,i){var e=new RegExp("(^|\\s)"+i+"(\\s|$)");return e.test(t.className)},n.addClass=function(t,i){if(!n.hasClass(t,i)){var e=t.className.split(" ");e.push(i),t.className=e.join(" ")}},n.removeClass=function(t,i){if(n.hasClass(t,i)){var e=new RegExp("(^|\\s)"+i+"(\\s|$)","g");t.className=t.className.replace(e," ")}},n.offset=function(t){for(var i=-t.offsetLeft,e=-t.offsetTop;t=t.offsetParent;)i-=t.offsetLeft,e-=t.offsetTop;return{left:i,top:e}},n.preventDefaultException=function(t,i){for(var e in i)if(i[e].test(t[e]))return!0;return!1},n.extend(n.eventType={},{touchstart:1,touchmove:1,touchend:1,mousedown:2,mousemove:2,mouseup:2,MSPointerDown:3,MSPointerMove:3,MSPointerUp:3}),n.extend(n.ease={},{quadratic:{style:"cubic-bezier(0.25, 0.46, 0.45, 0.94)",fn:function(t){return t*(2-t)}},circular:{style:"cubic-bezier(0.1, 0.57, 0.1, 1)",fn:function(t){return e.sqrt(1- --t*t)}},back:{style:"cubic-bezier(0.175, 0.885, 0.32, 1.275)",fn:function(t){var i=4;return(t-=1)*t*((i+1)*t+i)+1}},bounce:{style:"",fn:function(t){return(t/=1)<1/2.75?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}},elastic:{style:"",fn:function(t){var i=.22,s=.4;return 0===t?0:1==t?1:s*e.pow(2,-10*t)*e.sin(2*(t-i/4)*e.PI/i)+1}}}),n.tap=function(t,e){var s=i.createEvent("Event");s.initEvent(e,!0,!0),s.pageX=t.pageX,s.pageY=t.pageY,t.target.dispatchEvent(s)},n.click=function(t){var e,s=t.target;"SELECT"!=s.tagName&&"INPUT"!=s.tagName&&"TEXTAREA"!=s.tagName&&(e=i.createEvent("MouseEvents"),e.initMouseEvent("click",!0,!0,t.view,1,s.screenX,s.screenY,s.clientX,s.clientY,t.ctrlKey,t.altKey,t.shiftKey,t.metaKey,0,null),e._constructed=!0,s.dispatchEvent(e))},n}();s.prototype={version:"5.1.0",_init:function(){this._initEvents(),this.options.mouseWheel&&this._initWheel(),this.options.snap&&this._initSnap(),this.options.keyBindings&&this._initKeys(),this.options.infiniteElements&&this._initInfinite()},destroy:function(){this._initEvents(!0),this._execEvent("destroy")},_transitionEnd:function(t){t.target==this.scroller&&this.isInTransition&&(this._transitionTime(),this.resetPosition(this.options.bounceTime)||(this.isInTransition=!1,this._execEvent("scrollEnd")))},_start:function(t){if(!(1!=o.eventType[t.type]&&0!==t.button||!this.enabled||this.initiated&&o.eventType[t.type]!==this.initiated)){!this.options.preventDefault||o.isBadAndroid||o.preventDefaultException(t.target,this.options.preventDefaultException)||t.preventDefault();var i,s=t.touches?t.touches[0]:t;this.initiated=o.eventType[t.type],this.moved=!1,this.distX=0,this.distY=0,this.directionX=0,this.directionY=0,this.directionLocked=0,this._transitionTime(),this.startTime=o.getTime(),this.options.useTransition&&this.isInTransition?(this.isInTransition=!1,i=this.getComputedPosition(),this._translate(e.round(i.x),e.round(i.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=s.pageX,this.pointY=s.pageY,this._execEvent("beforeScrollStart")}},_move:function(t){if(this.enabled&&o.eventType[t.type]===this.initiated){this.options.preventDefault&&t.preventDefault();var i,s,n,h,r=t.touches?t.touches[0]:t,a=r.pageX-this.pointX,l=r.pageY-this.pointY,c=o.getTime();if(this.pointX=r.pageX,this.pointY=r.pageY,this.distX+=a,this.distY+=l,n=e.abs(this.distX),h=e.abs(this.distY),!(c-this.endTime>300&&10>n&&10>h)){if(this.directionLocked||this.options.freeScroll||(this.directionLocked=n>h+this.options.directionLockThreshold?"h":h>=n+this.options.directionLockThreshold?"v":"n"),"h"==this.directionLocked){if("vertical"==this.options.eventPassthrough)t.preventDefault();else if("horizontal"==this.options.eventPassthrough)return this.initiated=!1,void 0;l=0}else if("v"==this.directionLocked){if("horizontal"==this.options.eventPassthrough)t.preventDefault();else if("vertical"==this.options.eventPassthrough)return this.initiated=!1,void 0;a=0}a=this.hasHorizontalScroll?a:0,l=this.hasVerticalScroll?l:0,i=this.x+a,s=this.y+l,(i>0||i<this.maxScrollX)&&(i=this.options.bounce?this.x+a/3:i>0?0:this.maxScrollX),(s>0||s<this.maxScrollY)&&(s=this.options.bounce?this.y+l/3:s>0?0:this.maxScrollY),this.directionX=a>0?-1:0>a?1:0,this.directionY=l>0?-1:0>l?1:0,this.moved||this._execEvent("scrollStart"),this.moved=!0,this._translate(i,s),c-this.startTime>300&&(this.startTime=c,this.startX=this.x,this.startY=this.y,1==this.options.probeType&&this._execEvent("scroll")),this.options.probeType>1&&this._execEvent("scroll")}}},_end:function(t){if(this.enabled&&o.eventType[t.type]===this.initiated){this.options.preventDefault&&!o.preventDefaultException(t.target,this.options.preventDefaultException)&&t.preventDefault();var i,s,n=(t.changedTouches?t.changedTouches[0]:t,o.getTime()-this.startTime),h=e.round(this.x),r=e.round(this.y),a=e.abs(h-this.startX),l=e.abs(r-this.startY),c=0,p="";if(this.isInTransition=0,this.initiated=0,this.endTime=o.getTime(),!this.resetPosition(this.options.bounceTime)){if(this.scrollTo(h,r),!this.moved)return this.options.tap&&o.tap(t,this.options.tap),this.options.click&&o.click(t),this._execEvent("scrollCancel"),void 0;if(this._events.flick&&200>n&&100>a&&100>l)return this._execEvent("flick"),void 0;if(this.options.momentum&&300>n&&(i=this.hasHorizontalScroll?o.momentum(this.x,this.startX,n,this.maxScrollX,this.options.bounce?this.wrapperWidth:0):{destination:h,duration:0},s=this.hasVerticalScroll?o.momentum(this.y,this.startY,n,this.maxScrollY,this.options.bounce?this.wrapperHeight:0):{destination:r,duration:0},h=i.destination,r=s.destination,c=e.max(i.duration,s.duration),this.isInTransition=1),this.options.snap){var u=this._nearestSnap(h,r);this.currentPage=u,c=this.options.snapSpeed||e.max(e.max(e.min(e.abs(h-u.x),1e3),e.min(e.abs(r-u.y),1e3)),300),h=u.x,r=u.y,this.directionX=0,this.directionY=0,p=this.options.bounceEasing}return h!=this.x||r!=this.y?((h>0||h<this.maxScrollX||r>0||r<this.maxScrollY)&&(p=o.ease.quadratic),this.scrollTo(h,r,c,p),void 0):(this._execEvent("scrollEnd"),void 0)}}},_resize:function(){var t=this;clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(function(){t.refresh()},this.options.resizePolling)},resetPosition:function(t){var i=this.x,e=this.y;return t=t||0,!this.hasHorizontalScroll||this.x>0?i=0:this.x<this.maxScrollX&&(i=this.maxScrollX),!this.hasVerticalScroll||this.y>0?e=0:this.y<this.maxScrollY&&(e=this.maxScrollY),i==this.x&&e==this.y?!1:(this.scrollTo(i,e,t,this.options.bounceEasing),!0)},disable:function(){this.enabled=!1},enable:function(){this.enabled=!0},refresh:function(){this.wrapper.offsetHeight;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;var t;this.options.infiniteElements&&(this.options.infiniteLimit=this.options.infiniteLimit||e.floor(2147483645/this.infiniteElementHeight),t=-this.options.infiniteLimit*this.infiniteElementHeight+this.wrapperHeight),this.maxScrollY=void 0!==t?t:this.wrapperHeight-this.scrollerHeight,this.hasHorizontalScroll=this.options.scrollX&&this.maxScrollX<0,this.hasVerticalScroll=this.options.scrollY&&this.maxScrollY<0,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,this.wrapperOffset=o.offset(this.wrapper),this._execEvent("refresh"),this.resetPosition()},on:function(t,i){this._events[t]||(this._events[t]=[]),this._events[t].push(i)},_execEvent:function(t){if(this._events[t]){var i=0,e=this._events[t].length;if(e)for(;e>i;i++)this._events[t][i].apply(this,[].slice.call(arguments,1))}},scrollBy:function(t,i,e,s){t=this.x+t,i=this.y+i,e=e||0,this.scrollTo(t,i,e,s)},scrollTo:function(t,i,e,s){s=s||o.ease.circular,this.isInTransition=this.options.useTransition&&e>0,!e||this.options.useTransition&&s.style?(this._transitionTimingFunction(s.style),this._transitionTime(e),this._translate(t,i)):this._animate(t,i,e,s.fn)},scrollToElement:function(t,i,s,n,h){if(t=t.nodeType?t:this.scroller.querySelector(t)){var r=o.offset(t);r.left-=this.wrapperOffset.left,r.top-=this.wrapperOffset.top,s===!0&&(s=e.round(t.offsetWidth/2-this.wrapper.offsetWidth/2)),n===!0&&(n=e.round(t.offsetHeight/2-this.wrapper.offsetHeight/2)),r.left-=s||0,r.top-=n||0,r.left=r.left>0?0:r.left<this.maxScrollX?this.maxScrollX:r.left,r.top=r.top>0?0:r.top<this.maxScrollY?this.maxScrollY:r.top,i=void 0===i||null===i||"auto"===i?e.max(e.abs(this.x-r.left),e.abs(this.y-r.top)):i,this.scrollTo(r.left,r.top,i,h)}},_transitionTime:function(t){t=t||0,this.scrollerStyle[o.style.transitionDuration]=t+"ms",!t&&o.isBadAndroid&&(this.scrollerStyle[o.style.transitionDuration]="0.001s")},_transitionTimingFunction:function(t){this.scrollerStyle[o.style.transitionTimingFunction]=t},_translate:function(t,i){this.options.useTransform?this.scrollerStyle[o.style.transform]="translate("+t+"px,"+i+"px)"+this.translateZ:(t=e.round(t),i=e.round(i),this.scrollerStyle.left=t+"px",this.scrollerStyle.top=i+"px"),this.x=t,this.y=i},_initEvents:function(i){var e=i?o.removeEvent:o.addEvent,s=this.options.bindToWrapper?this.wrapper:t;e(t,"orientationchange",this),e(t,"resize",this),this.options.click&&e(this.wrapper,"click",this,!0),this.options.disableMouse||(e(this.wrapper,"mousedown",this),e(s,"mousemove",this),e(s,"mousecancel",this),e(s,"mouseup",this)),o.hasPointer&&!this.options.disablePointer&&(e(this.wrapper,"MSPointerDown",this),e(s,"MSPointerMove",this),e(s,"MSPointerCancel",this),e(s,"MSPointerUp",this)),o.hasTouch&&!this.options.disableTouch&&(e(this.wrapper,"touchstart",this),e(s,"touchmove",this),e(s,"touchcancel",this),e(s,"touchend",this)),e(this.scroller,"transitionend",this),e(this.scroller,"webkitTransitionEnd",this),e(this.scroller,"oTransitionEnd",this),e(this.scroller,"MSTransitionEnd",this)},getComputedPosition:function(){var i,e,s=t.getComputedStyle(this.scroller,null);return this.options.useTransform?(s=s[o.style.transform].split(")")[0].split(", "),i=+(s[12]||s[4]),e=+(s[13]||s[5])):(i=+s.left.replace(/[^-\d.]/g,""),e=+s.top.replace(/[^-\d.]/g,"")),{x:i,y:e}},_initWheel:function(){o.addEvent(this.wrapper,"wheel",this),o.addEvent(this.wrapper,"mousewheel",this),o.addEvent(this.wrapper,"DOMMouseScroll",this),this.on("destroy",function(){o.removeEvent(this.wrapper,"wheel",this),o.removeEvent(this.wrapper,"mousewheel",this),o.removeEvent(this.wrapper,"DOMMouseScroll",this)})},_wheel:function(t){if(this.enabled){t.preventDefault(),t.stopPropagation();var i,s,n,o,h=this;if(void 0===this.wheelTimeout&&h._execEvent("scrollStart"),clearTimeout(this.wheelTimeout),this.wheelTimeout=setTimeout(function(){h._execEvent("scrollEnd"),h.wheelTimeout=void 0},400),"deltaX"in t)i=-t.deltaX,s=-t.deltaY;else if("wheelDeltaX"in t)i=t.wheelDeltaX/120*this.options.mouseWheelSpeed,s=t.wheelDeltaY/120*this.options.mouseWheelSpeed;else if("wheelDelta"in t)i=s=t.wheelDelta/120*this.options.mouseWheelSpeed;else{if(!("detail"in t))return;i=s=-t.detail/3*this.options.mouseWheelSpeed}if(i*=this.options.invertWheelDirection,s*=this.options.invertWheelDirection,this.hasVerticalScroll||(i=s,s=0),this.options.snap)return n=this.currentPage.pageX,o=this.currentPage.pageY,i>0?n--:0>i&&n++,s>0?o--:0>s&&o++,this.goToPage(n,o),void 0;n=this.x+e.round(this.hasHorizontalScroll?i:0),o=this.y+e.round(this.hasVerticalScroll?s:0),n>0?n=0:n<this.maxScrollX&&(n=this.maxScrollX),o>0?o=0:o<this.maxScrollY&&(o=this.maxScrollY),this.scrollTo(n,o,0),this.options.probeType>1&&this._execEvent("scroll")}},_initSnap:function(){this.currentPage={},"string"==typeof this.options.snap&&(this.options.snap=this.scroller.querySelectorAll(this.options.snap)),this.on("refresh",function(){var t,i,s,n,o,h,r=0,a=0,l=0,c=this.options.snapStepX||this.wrapperWidth,p=this.options.snapStepY||this.wrapperHeight;if(this.pages=[],this.wrapperWidth&&this.wrapperHeight&&this.scrollerWidth&&this.scrollerHeight){if(this.options.snap===!0)for(s=e.round(c/2),n=e.round(p/2);l>-this.scrollerWidth;){for(this.pages[r]=[],t=0,o=0;o>-this.scrollerHeight;)this.pages[r][t]={x:e.max(l,this.maxScrollX),y:e.max(o,this.maxScrollY),width:c,height:p,cx:l-s,cy:o-n},o-=p,t++;l-=c,r++}else for(h=this.options.snap,t=h.length,i=-1;t>r;r++)(0===r||h[r].offsetLeft<=h[r-1].offsetLeft)&&(a=0,i++),this.pages[a]||(this.pages[a]=[]),l=e.max(-h[r].offsetLeft,this.maxScrollX),o=e.max(-h[r].offsetTop,this.maxScrollY),s=l-e.round(h[r].offsetWidth/2),n=o-e.round(h[r].offsetHeight/2),this.pages[a][i]={x:l,y:o,width:h[r].offsetWidth,height:h[r].offsetHeight,cx:s,cy:n},l>this.maxScrollX&&a++;this.goToPage(this.currentPage.pageX||0,this.currentPage.pageY||0,0),this.options.snapThreshold%1===0?(this.snapThresholdX=this.options.snapThreshold,this.snapThresholdY=this.options.snapThreshold):(this.snapThresholdX=e.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].width*this.options.snapThreshold),this.snapThresholdY=e.round(this.pages[this.currentPage.pageX][this.currentPage.pageY].height*this.options.snapThreshold))}}),this.on("flick",function(){var t=this.options.snapSpeed||e.max(e.max(e.min(e.abs(this.x-this.startX),1e3),e.min(e.abs(this.y-this.startY),1e3)),300);this.goToPage(this.currentPage.pageX+this.directionX,this.currentPage.pageY+this.directionY,t)})},_nearestSnap:function(t,i){if(!this.pages.length)return{x:0,y:0,pageX:0,pageY:0};var s=0,n=this.pages.length,o=0;if(e.abs(t-this.absStartX)<this.snapThresholdX&&e.abs(i-this.absStartY)<this.snapThresholdY)return this.currentPage;for(t>0?t=0:t<this.maxScrollX&&(t=this.maxScrollX),i>0?i=0:i<this.maxScrollY&&(i=this.maxScrollY);n>s;s++)if(t>=this.pages[s][0].cx){t=this.pages[s][0].x;break}for(n=this.pages[s].length;n>o;o++)if(i>=this.pages[0][o].cy){i=this.pages[0][o].y;break}return s==this.currentPage.pageX&&(s+=this.directionX,0>s?s=0:s>=this.pages.length&&(s=this.pages.length-1),t=this.pages[s][0].x),o==this.currentPage.pageY&&(o+=this.directionY,0>o?o=0:o>=this.pages[0].length&&(o=this.pages[0].length-1),i=this.pages[0][o].y),{x:t,y:i,pageX:s,pageY:o}},goToPage:function(t,i,s,n){n=n||this.options.bounceEasing,t>=this.pages.length?t=this.pages.length-1:0>t&&(t=0),i>=this.pages[t].length?i=this.pages[t].length-1:0>i&&(i=0);var o=this.pages[t][i].x,h=this.pages[t][i].y;s=void 0===s?this.options.snapSpeed||e.max(e.max(e.min(e.abs(o-this.x),1e3),e.min(e.abs(h-this.y),1e3)),300):s,this.currentPage={x:o,y:h,pageX:t,pageY:i},this.scrollTo(o,h,s,n)},next:function(t,i){var e=this.currentPage.pageX,s=this.currentPage.pageY;e++,e>=this.pages.length&&this.hasVerticalScroll&&(e=0,s++),this.goToPage(e,s,t,i)},prev:function(t,i){var e=this.currentPage.pageX,s=this.currentPage.pageY;e--,0>e&&this.hasVerticalScroll&&(e=0,s--),this.goToPage(e,s,t,i)},_initKeys:function(){var i,e={pageUp:33,pageDown:34,end:35,home:36,left:37,up:38,right:39,down:40};if("object"==typeof this.options.keyBindings)for(i in this.options.keyBindings)"string"==typeof this.options.keyBindings[i]&&(this.options.keyBindings[i]=this.options.keyBindings[i].toUpperCase().charCodeAt(0));else this.options.keyBindings={};for(i in e)this.options.keyBindings[i]=this.options.keyBindings[i]||e[i];o.addEvent(t,"keydown",this),this.on("destroy",function(){o.removeEvent(t,"keydown",this)})},_key:function(t){if(this.enabled){var i,s=this.options.snap,n=s?this.currentPage.pageX:this.x,h=s?this.currentPage.pageY:this.y,r=o.getTime(),a=this.keyTime||0,l=.25;switch(this.options.useTransition&&this.isInTransition&&(i=this.getComputedPosition(),this._translate(e.round(i.x),e.round(i.y)),this.isInTransition=!1),this.keyAcceleration=200>r-a?e.min(this.keyAcceleration+l,50):0,t.keyCode){case this.options.keyBindings.pageUp:this.hasHorizontalScroll&&!this.hasVerticalScroll?n+=s?1:this.wrapperWidth:h+=s?1:this.wrapperHeight;break;case this.options.keyBindings.pageDown:this.hasHorizontalScroll&&!this.hasVerticalScroll?n-=s?1:this.wrapperWidth:h-=s?1:this.wrapperHeight;break;case this.options.keyBindings.end:n=s?this.pages.length-1:this.maxScrollX,h=s?this.pages[0].length-1:this.maxScrollY;break;case this.options.keyBindings.home:n=0,h=0;break;case this.options.keyBindings.left:n+=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.up:h+=s?1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.right:n-=s?-1:5+this.keyAcceleration>>0;break;case this.options.keyBindings.down:h-=s?1:5+this.keyAcceleration>>0;break;default:return}if(s)return this.goToPage(n,h),void 0;n>0?(n=0,this.keyAcceleration=0):n<this.maxScrollX&&(n=this.maxScrollX,this.keyAcceleration=0),h>0?(h=0,this.keyAcceleration=0):h<this.maxScrollY&&(h=this.maxScrollY,this.keyAcceleration=0),this.scrollTo(n,h,0),this.keyTime=r}},_animate:function(t,i,e,s){function h(){var u,f,d,g=o.getTime();return g>=p?(r.isAnimating=!1,r._translate(t,i),r.resetPosition(r.options.bounceTime)||r._execEvent("scrollEnd"),void 0):(g=(g-c)/e,d=s(g),u=(t-a)*d+a,f=(i-l)*d+l,r._translate(u,f),r.isAnimating&&n(h),3==r.options.probeType&&r._execEvent("scroll"),void 0)}var r=this,a=this.x,l=this.y,c=o.getTime(),p=c+e;this.isAnimating=!0,h()},_initInfinite:function(){var t=this.options.infiniteElements;this.infiniteElements="string"==typeof t?i.querySelectorAll(t):t,this.infiniteLength=this.infiniteElements.length,this.infiniteMaster=this.infiniteElements[0],this.infiniteElementHeight=this.infiniteMaster.offsetHeight,this.infiniteHeight=this.infiniteLength*this.infiniteElementHeight,this.options.cacheSize=this.options.cacheSize||1e3,this.infiniteCacheBuffer=e.round(this.options.cacheSize/4),this.options.dataset.call(this,0,this.options.cacheSize),this.on("refresh",function(){var t=e.ceil(this.wrapperHeight/this.infiniteElementHeight);this.infiniteUpperBufferSize=e.floor((this.infiniteLength-t)/2),this.reorderInfinite()}),this.on("scroll",this.reorderInfinite)},reorderInfinite:function(){for(var t=(-this.y+this.wrapperHeight/2,e.max(e.floor(-this.y/this.infiniteElementHeight)-this.infiniteUpperBufferSize,0)),i=e.floor(t/this.infiniteLength),s=t-i*this.infiniteLength,n=0,o=0,h=[],r=e.floor(t/this.infiniteCacheBuffer);o<this.infiniteLength;)n=o*this.infiniteElementHeight+i*this.infiniteHeight,s>o&&(n+=this.infiniteElementHeight*this.infiniteLength),this.infiniteElements[o]._top!==n&&(this.infiniteElements[o]._phase=n/this.infiniteElementHeight,this.infiniteElements[o]._phase<this.options.infiniteLimit&&(this.infiniteElements[o]._top=n,this.infiniteElements[o].style.top=n+"px",h.push(this.infiniteElements[o]))),o++;this.cachePhase!=r&&(0===r||t-this.infiniteCacheBuffer>0)&&this.options.dataset.call(this,e.max(r*this.infiniteCacheBuffer-this.infiniteCacheBuffer,0),this.options.cacheSize),this.cachePhase=r,this.updateContent(h)},updateContent:function(t){if(void 0!==this.infiniteCache)for(var i=0,e=t.length;e>i;i++)this.options.dataFiller.call(this,t[i],this.infiniteCache[t[i]._phase])},updateCache:function(t,i){var e=void 0===this.infiniteCache;this.infiniteCache={};for(var s=0,n=i.length;n>s;s++)this.infiniteCache[t++]=i[s];e&&this.updateContent(this.infiniteElements)},handleEvent:function(t){switch(t.type){case"touchstart":case"MSPointerDown":case"mousedown":this._start(t);break;case"touchmove":case"MSPointerMove":case"mousemove":this._move(t);break;case"touchend":case"MSPointerUp":case"mouseup":case"touchcancel":case"MSPointerCancel":case"mousecancel":this._end(t);break;case"orientationchange":case"resize":this._resize();break;case"transitionend":case"webkitTransitionEnd":case"oTransitionEnd":case"MSTransitionEnd":this._transitionEnd(t);break;case"wheel":case"DOMMouseScroll":case"mousewheel":this._wheel(t);break;case"keydown":this._key(t);break;case"click":t._constructed||(t.preventDefault(),t.stopPropagation())}}},s.utils=o,"undefined"!=typeof module&&module.exports?module.exports=s:t.IScroll=s}(window,document,Math); | |
| No newline at the end of the file |