@egjs/axes
Advanced tools
Comparing version 2.5.13 to 2.5.14-rc
@@ -8,5 +8,5 @@ /* | ||
@version 2.5.13 | ||
@version 2.5.14 | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/hammerjs"),require("@egjs/component")):"function"==typeof define&&define.amd?define(["@egjs/hammerjs","@egjs/component"],e):(t.eg=t.eg||{},t.eg.Axes=e(t.Hammer,t.eg.Component))}(this,function(o,t){"use strict";var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s,d=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t};s="undefined"==typeof window?{}:window;var e=1e5,r=function(){if("undefined"==typeof document)return"";for(var t=(document.head||document.getElementsByTagName("head")[0]).style,e=["transform","webkitTransform","msTransform","mozTransform"],n=0,i=e.length;n<i;n++)if(e[n]in t)return e[n];return""}();function a(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function h(t,e){var n;if(void 0===e&&(e=!1),"string"==typeof t){if(t.match(/^<([a-z]+)\s*([^>]*)>/)){var i=document.createElement("div");i.innerHTML=t,n=a(i.childNodes)}else n=a(document.querySelectorAll(t));e||(n=1<=n.length?n[0]:void 0)}else t===s?n=t:!t.nodeName||1!==t.nodeType&&9!==t.nodeType?"jQuery"in s&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return h(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var p=s.requestAnimationFrame||s.webkitRequestAnimationFrame,u=s.cancelAnimationFrame||s.webkitCancelAnimationFrame;if(p&&!u){var c={},m=p;p=function(e){var n=m(function(t){c[n]&&e(t)});return c[n]=!0,n},u=function(t){delete c[t]}}else p&&u||(p=function(t){return s.setTimeout(function(){t(s.performance&&s.performance.now&&s.performance.now()||(new Date).getTime())},16)},u=s.clearTimeout);function v(t){return g(t,function(t){return E(t)})}function g(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function l(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function f(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function _(t,n){return f(t,function(t,e){return t===n[e]})}function E(t){return Math.round(t*e)/e}function b(t,e,n,i){var s=t,r=[n[0]?e[0]:i?e[0]-i[0]:e[0],n[1]?e[1]:i?e[1]+i[1]:e[1]];return s=Math.max(r[0],s),+E(s=Math.min(r[1],s))}function x(t,e){return t<e[0]||t>e[1]}function I(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function T(t,e,n,i){var s=t,r=e[0],o=e[1],a=o-r;return n[1]&&o<t&&(s=(s-o)%a+r),n[0]&&t<r&&(s=(s-r)%a+o),i?s:+E(s)}function y(t,e,n){return Math.max(Math.min(t,n),e)}var O=function(){function t(t){var e=t.options,n=t.itm,i=t.em,s=t.axm;this.options=e,this.itm=n,this.em=i,this.axm=s,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(r,t,e){var n,o=this;if(void 0!==e)n=e;else{var i=g(t,function(t,e){return n=Math.abs(t-r[e]),i=o.options.deceleration,(s=Math.sqrt(n/i*2))<100?0:s;var n,i,s});n=Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)}return y(n,this.options.minimumDuration,this.options.maximumDuration)},e.createAnimationParam=function(t,e,n){var i=this.axm.get(),s=t,r=n&&n.event||null;return{depaPos:i,destPos:s,duration:y(e,this.options.minimumDuration,this.options.maximumDuration),delta:this.axm.getDelta(i,s),inputEvent:r,input:n&&n.input||null,isTrusted:!!r,done:this.animationEnd}},e.grab=function(t,e){if(this._animateParam&&t.length){var n=this.axm.get(t),i=this.axm.map(n,function(t,e){return T(t,e.range,e.circular,!1)});f(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(s=this._raf,u(s)),this._raf=null,this.em.triggerAnimationEnd(!(!e||!e.event))}var s},e.getEventInfo=function(){return this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent?{input:this._animateParam.input,event:this._animateParam.inputEvent}:null},e.restore=function(t){var e=this.axm.get(),n=this.axm.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axm.filter(this.axm.get(),function(t,e){return I(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return T(t,e.range,e.circular,!1)})),this.itm.setInterrupt(!1),this.em.triggerAnimationEnd(!!t),this.axm.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.itm.setInterrupt(!1),this.em.triggerFinish(t)},e.animateLoop=function(o,a){if(o.duration){this._animateParam=d({},o);var h=this._animateParam,u=this,c=h.depaPos,m=0,l=g(c,function(t,e){return t<=h.destPos[e]?1:-1}),f=(new Date).getTime();h.startTime=f,function t(){u._raf=null;var e=(new Date).getTime(),n=u.easing((e-h.startTime)/o.duration),i=g(c,function(t,e){return t+h.delta[e]*(n-m)});i=u.axm.map(i,function(t,e,n){var i=T(t,e.range,e.circular,!0);return t!==i&&(o.destPos[n]+=-l[n]*(e.range[1]-e.range[0]),c[n]+=-l[n]*(e.range[1]-e.range[0])),i});var s=!u.em.triggerChange(i,!1,v(c));if(c=i,f=e,1<=(m=n)){var r=o.destPos;return _(r,u.axm.get(Object.keys(r)))||u.em.triggerChange(r,!0,v(c)),void a()}s?u.finish(!1):u._raf=p(t)}()}else this.em.triggerChange(o.destPos,!0),a()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=y(e.duration,this.options.minimumDuration,this.options.maximumDuration),e},e.animateTo=function(t,e,n){var i=this,s=this.createAnimationParam(t,e,n),r=d({},s.depaPos),o=this.em.triggerAnimationStart(s),a=this.getUserControll(s);if(!o&&this.axm.every(a.destPos,function(t,e){return I(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!_(a.destPos,r)){var h=n&&n.event||null;this.animateLoop({depaPos:r,destPos:a.destPos,duration:a.duration,delta:this.axm.getDelta(r,a.destPos),isTrusted:!!h,inputEvent:h,input:n&&n.input||null},function(){return i.animationEnd()})}},e.easing=function(t){return 1<t?1:this.options.easing(t)},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t);this.grab(n);var i=this.axm.get(n);if(_(t,i))return this;this.itm.setInterrupt(!0);var s=l(t,function(t,e){return i[e]!==t});return Object.keys(s).length&&(_(s=this.axm.map(s,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:b(t,n,i)}),i)||(0<e?this.animateTo(s,e):(this.em.triggerChange(s),this.finish(!1)))),this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(g(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),P=function(){function t(t){this.axes=t}var e=t.prototype;return e.triggerHold=function(t,e){this.axes.trigger("hold",{pos:t,input:e.input||null,inputEvent:e.event||null,isTrusted:!0})},e.triggerRelease=function(t){t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("release",t)},e.triggerChange=function(t,e,n,i,s){void 0===s&&(s=!1);var r=this.am,o=r.axm,a=r.getEventInfo(),h=o.moveTo(t,e,n),u=i&&i.event||a&&a.event||null,c={pos:h.pos,delta:h.delta,holding:s,inputEvent:u,isTrusted:!!u,input:i&&i.input||a&&a.input||null,set:u?this.createUserControll(h.pos):function(){}},m=this.axes.trigger("change",c);return u&&o.set(c.set().destPos),m},e.triggerAnimationStart=function(t){return t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("animationStart",t)},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this.axes.trigger("animationEnd",{isTrusted:t})},e.triggerFinish=function(t){void 0===t&&(t=!1),this.axes.trigger("finish",{isTrusted:t})},e.createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:d({},t),duration:e};return function(t,e){return t&&(n.destPos=d({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},t}(),D=function(){function t(t){this.options=t,this._prevented=!1}var e=t.prototype;return e.isInterrupting=function(){return this.options.interruptable||this._prevented},e.isInterrupted=function(){return!this.options.interruptable&&this._prevented},e.setInterrupt=function(t){!this.options.interruptable&&(this._prevented=t)},t}(),R=function(){function t(t,e){var n=this;this.axis=t,this.options=e,this._complementOptions(),this._pos=Object.keys(this.axis).reduce(function(t,e){return t[e]=n.axis[e].range[0],t},{})}var e=t.prototype;return e._complementOptions=function(){var s=this;Object.keys(this.axis).forEach(function(i){s.axis[i]=d({range:[0,100],bounce:[0,0],circular:[!1,!1]},s.axis[i]),["bounce","circular"].forEach(function(t){var e=s.axis,n=e[i][t];/string|number|boolean/.test(typeof n)&&(e[i][t]=[n,n])})})},e.getDelta=function(t,e){var n=this.get(t);return g(this.get(e),function(t,e){return t-n[e]})},e.get=function(t){var n=this;return t&&Array.isArray(t)?t.reduce(function(t,e){return e&&e in n._pos&&(t[e]=n._pos[e]),t},{}):d({},this._pos,t||{})},e.moveTo=function(n,i,s){void 0===s&&(s=this._pos);var t=g(this._pos,function(t,e){return e in n&&e in s?n[e]-s[e]:0});return this.set(this.map(n,function(t,e){return e?T(t,e.range,e.circular,i):0})),{pos:d({},this._pos),delta:t}},e.set=function(t){for(var e in t)e&&e in this._pos&&(this._pos[e]=t[e])},e.every=function(t,n){var i=this.axis;return f(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return l(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return g(t,function(t,e){return n(t,i[e],e)})},e.isOutside=function(t){return!this.every(t?this.get(t):this._pos,function(t,e){return!x(t,e.range)})},t}(),C=function(){function t(t){var e=t.options,n=t.itm,i=t.em,s=t.axm,r=t.am;this.isOutside=!1,this.moveDistance=null,this.isStopped=!1,this.options=e,this.itm=n,this.em=i,this.axm=s,this.am=r}var e=t.prototype;return e.atOutside=function(t){var o=this;if(this.isOutside)return this.axm.map(t,function(t,e){var n=e.range[0]-e.bounce[0],i=e.range[1]+e.bounce[1];return i<t?i:t<n?n:t});var a=this.am.easing(1e-5)/1e-5;return this.axm.map(t,function(t,e){var n=e.range[0],i=e.range[1],s=e.bounce,r=e.circular;return r&&(r[0]||r[1])?t:t<n?n-o.am.easing((n-t)/(s[0]*a))*s[0]:i<t?i+o.am.easing((t-i)/(s[1]*a))*s[1]:t})},e.get=function(t){return this.axm.get(t.axes)},e.hold=function(t,e){if(!this.itm.isInterrupted()&&t.axes.length){var n={input:t,event:e};this.isStopped=!1,this.itm.setInterrupt(!0),this.am.grab(t.axes,n),!this.moveDistance&&this.em.triggerHold(this.axm.get(),n),this.isOutside=this.axm.isOutside(t.axes),this.moveDistance=this.axm.get(t.axes)}},e.change=function(t,e,n){if(!this.isStopped&&this.itm.isInterrupting()&&!this.axm.every(n,function(t){return 0===t})){var i,s=this.moveDistance||this.axm.get(t.axes);i=g(s,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(s,function(t,e){return!x(t,e.range)})&&(this.isOutside=!1),s=this.atOutside(s),i=this.atOutside(i),!this.em.triggerChange(i,!1,s,{input:t,event:e},!0)&&(this.isStopped=!0,this.moveDistance=null,this.am.finish(!1))}},e.release=function(t,e,n,i){if(!this.isStopped&&this.itm.isInterrupting()&&this.moveDistance){var s=this.axm.get(t.axes),r=this.axm.get(),o=this.axm.get(this.axm.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?s[n]+t:b(s[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,s,i);0===a&&(o=d({},r));var h={depaPos:r,destPos:o,duration:a,delta:this.axm.getDelta(r,o),inputEvent:e,input:t,isTrusted:!0};this.em.triggerRelease(h),this.moveDistance=null;var u=this.am.getUserControll(h),c=_(u.destPos,r),m={input:t,event:e};c||0===u.duration?(!c&&this.em.triggerChange(u.destPos,!1,r,m,!0),this.itm.setInterrupt(!1),this.axm.isOutside()?this.am.restore(m):this.em.triggerFinish(!0)):this.am.animateTo(u.destPos,u.duration,m)}},t}(),A=function(s){function t(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i=s.call(this)||this;return i.axis=t,i._inputs=[],i.options=d({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4},e),i.itm=new D(i.options),i.axm=new R(i.axis,i.options),i.em=new P(i),i.am=new O(i),i.io=new C(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}n(t,s);var e=t.prototype;return e.connect=function(t,e){var n;if(n="string"==typeof t?t.split(" "):t.concat(),~this._inputs.indexOf(e)&&this.disconnect(e),"hammer"in e){var i=this._inputs.filter(function(t){return t.hammer&&t.element===e.element});i.length&&(e.hammer=i[0].hammer)}return e.mapAxes(n),e.connect(this.io),this._inputs.push(e),this},e.disconnect=function(t){if(t){var e=this._inputs.indexOf(t);0<=e&&(this._inputs[e].disconnect(),this._inputs.splice(e,1))}else this._inputs.forEach(function(t){return t.disconnect()}),this._inputs=[];return this},e.get=function(t){return this.axm.get(t)},e.setTo=function(t,e){return void 0===e&&(e=0),this.am.setTo(t,e),this},e.setBy=function(t,e){return void 0===e&&(e=0),this.am.setBy(t,e),this},e.isBounceArea=function(t){return this.axm.isOutside(t)},e.destroy=function(){this.disconnect(),this.em.destroy()},t.VERSION="2.5.13",t.TRANSFORM=r,t.DIRECTION_NONE=o.DIRECTION_NONE,t.DIRECTION_LEFT=o.DIRECTION_LEFT,t.DIRECTION_RIGHT=o.DIRECTION_RIGHT,t.DIRECTION_UP=o.DIRECTION_UP,t.DIRECTION_DOWN=o.DIRECTION_DOWN,t.DIRECTION_HORIZONTAL=o.DIRECTION_HORIZONTAL,t.DIRECTION_VERTICAL=o.DIRECTION_VERTICAL,t.DIRECTION_ALL=o.DIRECTION_ALL,t}(t),N="PointerEvent"in s||"MSPointerEvent"in s,w="ontouchstart"in s,M="_EGJS_AXES_INPUTTYPE_";function L(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function H(t,e){try{return new o.Manager(t,d({},e))}catch(t){return null}}function j(t){void 0===t&&(t=[]);var e=!1,n=!1,i=!1;return t.forEach(function(t){switch(t){case"mouse":n=!0;break;case"touch":e=w;break;case"pointer":i=N}}),i?o.PointerEventInput:e&&n?o.TouchMouseInput:e?o.TouchInput:n?o.MouseInput:null}function z(t,e,n){return n?!!(e===o.DIRECTION_ALL||e&t&&n&t):!!(e&t)}var S=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,void 0===o.Manager)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=h(t),this.options=d({inputType:["touch","mouse","pointer"],scale:[1,1],thresholdAngle:45,threshold:0,hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onHammerInput=this.onHammerInput.bind(this),this.onPanmove=this.onPanmove.bind(this),this.onPanend=this.onPanend.bind(this)}var e=t.prototype;return e.mapAxes=function(t){var e=!!t[0],n=!!t[1];this._direction=e&&n?o.DIRECTION_ALL:e?o.DIRECTION_HORIZONTAL:n?o.DIRECTION_VERTICAL:o.DIRECTION_NONE,this.axes=t},e.connect=function(t){var e={direction:this._direction,threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[M];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=j(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=H(this.element,d({inputClass:i},this.options.hammerManagerOptions)),this.element[M]=n}return this.panRecognizer=new o.Pan(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=o.DIRECTION_NONE,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[M],this.element=null,this.hammer=null},e.enable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pan").options.enable)},e.removeRecognizer=function(){this.hammer&&this.panRecognizer&&(this.hammer.remove(this.panRecognizer),this.panRecognizer=null)},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?this.observer.hold(this,t):t.isFinal&&this.onPanend(t))},e.onPanmove=function(t){var e=function(t,e){if(e<0||90<e)return o.DIRECTION_NONE;var n=Math.abs(t);return e<n&&n<180-e?o.DIRECTION_VERTICAL:o.DIRECTION_HORIZONTAL}(t.angle,this.options.thresholdAngle),n=this.hammer.session.prevInput;t.offsetY=n?(t.offsetX=t.deltaX-n.deltaX,t.deltaY-n.deltaY):t.offsetX=0;var i=this.getOffset([t.offsetX,t.offsetY],[z(o.DIRECTION_HORIZONTAL,this._direction,e),z(o.DIRECTION_VERTICAL,this._direction,e)]),s=i.some(function(t){return 0!==t});s&&(t.srcEvent.preventDefault(),t.srcEvent.stopPropagation()),(t.preventSystemEvent=s)&&this.observer.change(this,t,L(this.axes,i))},e.onPanend=function(t){var e,n,i,s,r=this.getOffset([Math.abs(t.velocityX)*(t.deltaX<0?-1:1),Math.abs(t.velocityY)*(t.deltaY<0?-1:1)],[z(o.DIRECTION_HORIZONTAL,this._direction),z(o.DIRECTION_VERTICAL,this._direction)]);e=r,n=this.observer.options.deceleration,i=Math.sqrt(e[0]*e[0]+e[1]*e[1]),s=Math.abs(i/-n),r=[e[0]/2*s,e[1]/2*s],this.observer.release(this,t,L(this.axes,r))},e.attachEvent=function(t){this.observer=t,this.hammer.on("hammer.input",this.onHammerInput).on("panstart panmove",this.onPanmove)},e.dettachEvent=function(){this.hammer.off("hammer.input",this.onHammerInput).off("panstart panmove",this.onPanmove),this.observer=null},e.getOffset=function(t,e){var n=[0,0],i=this.options.scale;return e[0]&&(n[0]=t[0]*i[0]),e[1]&&(n[1]=t[1]*i[1]),n},t}(),k=function(i){function t(t,e){var n=i.call(this,t,e)||this;return n.prevQuadrant=null,n.lastDiff=0,n}n(t,i);var e=t.prototype;return e.mapAxes=function(t){this._direction=A.DIRECTION_ALL,this.axes=t},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?(this.observer.hold(this,t),this.onPanstart(t)):t.isFinal&&this.onPanend(t))},e.onPanstart=function(t){var e=this.element.getBoundingClientRect();this.coefficientForDistanceToAngle=360/(e.width*Math.PI),this.rotateOrigin=[e.left+(e.width-1)/2,e.top+(e.height-1)/2],this.prevAngle=null,this.triggerChange(t)},e.onPanmove=function(t){this.triggerChange(t)},e.onPanend=function(t){this.triggerChange(t),this.triggerAnimation(t)},e.triggerChange=function(t){var e=this.getAngle(t.center.x,t.center.y),n=this.getQuadrant(t.center.x,t.center.y),i=this.getDifference(this.prevAngle,e,this.prevQuadrant,n);this.prevAngle=e,this.prevQuadrant=n,0!==i&&(this.lastDiff=i,this.observer.change(this,t,L(this.axes,[-i])))},e.triggerAnimation=function(t){var e=t.velocityX,n=t.velocityY,i=Math.sqrt(e*e+n*n)*(0<this.lastDiff?-1:1),s=i/2*Math.abs(i/-this.observer.options.deceleration);this.observer.release(this,t,L(this.axes,[s*this.coefficientForDistanceToAngle]))},e.getDifference=function(t,e,n,i){return null===t?0:1===n&&4===i?-t-(360-e):4===n&&1===i?360-t+e:e-t},e.getPosFromOrigin=function(t,e){return{x:t-this.rotateOrigin[0],y:this.rotateOrigin[1]-e}},e.getAngle=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,s=n.y,r=180*Math.atan2(s,i)/Math.PI;return r<0?360+r:r},e.getQuadrant=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,s=n.y,r=0;return 0<=i&&0<=s?r=1:i<0&&0<=s?r=2:i<0&&s<0?r=3:0<=i&&s<0&&(r=4),r},t}(S),F=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this._base=null,this._prev=null,this.pinchRecognizer=null,void 0===o.Manager)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=h(t),this.options=d({scale:1,threshold:0,inputType:["touch","pointer"],hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onPinchStart=this.onPinchStart.bind(this),this.onPinchMove=this.onPinchMove.bind(this),this.onPinchEnd=this.onPinchEnd.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){var e={threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[M];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=j(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=H(this.element,d({inputClass:i},this.options.hammerManagerOptions)),this.element[M]=n}return this.pinchRecognizer=new o.Pinch(e),this.hammer.add(this.pinchRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null,this.dettachEvent()),this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[M],this.element=null,this.hammer=null},e.removeRecognizer=function(){this.hammer&&this.pinchRecognizer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null)},e.onPinchStart=function(t){this._base=this.observer.get(this)[this.axes[0]];var e=this.getOffset(t.scale);this.observer.hold(this,t),this.observer.change(this,t,L(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,L(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,L(this.axes,[e])),this.observer.release(this,t,L(this.axes,[0]),0),this._base=null,this._prev=null},e.getOffset=function(t,e){return void 0===e&&(e=1),this._base*(t-e)*this.options.scale},e.attachEvent=function(t){this.observer=t,this.hammer.on("pinchstart",this.onPinchStart).on("pinchmove",this.onPinchMove).on("pinchend",this.onPinchEnd)},e.dettachEvent=function(){this.hammer.off("pinchstart",this.onPinchStart).off("pinchmove",this.onPinchMove).off("pinchend",this.onPinchEnd),this.observer=null,this._prev=null},e.enable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pinch").options.enable)},t}(),K=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=h(t),this.options=d({scale:1,useNormalized:!0},e),this.onWheel=this.onWheel.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onWheel=function(t){var e=this;if(this._isEnabled&&(t.preventDefault(),0!==t.deltaY)){this._isHolded||(this.observer.hold(this,t),this._isHolded=!0);var n=(0<t.deltaY?-1:1)*this.options.scale*(this.options.useNormalized?1:Math.abs(t.deltaY));this.observer.change(this,t,L(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,L(e.axes,[0])))},50)}},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("wheel",this.onWheel),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("wheel",this.onWheel),this._isEnabled=!1,this.observer=null,this._timer&&(clearTimeout(this._timer),this._timer=null)},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),Y=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=h(t),this.options=d({scale:[1,1]},e),this.onKeydown=this.onKeydown.bind(this),this.onKeyup=this.onKeyup.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),"0"!==this.element.getAttribute("tabindex")&&this.element.setAttribute("tabindex","0"),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onKeydown=function(t){if(this._isEnabled){var e=!0,n=1,i=-1;switch(t.keyCode){case 37:case 65:n=-1;break;case 39:case 68:break;case 40:case 83:n=-1,i=1;break;case 38:case 87:i=1;break;default:e=!1}if((-1===i&&!this.axes[0]||1===i&&!this.axes[1])&&(e=!1),e){var s=-1===i?[+this.options.scale[0]*n,0]:[0,+this.options.scale[1]*n];this._isHolded||(this.observer.hold(this,event),this._isHolded=!0),clearTimeout(this._timer),this.observer.change(this,event,L(this.axes,s))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,L(e.axes,[0,0])),e._isHolded=!1},80))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("keydown",this.onKeydown,!1),this.element.addEventListener("keypress",this.onKeydown,!1),this.element.addEventListener("keyup",this.onKeyup,!1),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("keydown",this.onKeydown,!1),this.element.removeEventListener("keypress",this.onKeydown,!1),this.element.removeEventListener("keyup",this.onKeyup,!1),this._isEnabled=!1,this.observer=null},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}();return A.PanInput=S,A.RotatePanInput=k,A.PinchInput=F,A.WheelInput=K,A.MoveKeyInput=Y,A}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@egjs/hammerjs"),require("@egjs/component")):"function"==typeof define&&define.amd?define(["@egjs/hammerjs","@egjs/component"],e):(t.eg=t.eg||{},t.eg.Axes=e(t.Hammer,t.eg.Component))}(this,function(o,t){"use strict";var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s,p=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var s in e=arguments[n])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t};s="undefined"==typeof window?{}:window;var e=1e5,r=function(){if("undefined"==typeof document)return"";for(var t=(document.head||document.getElementsByTagName("head")[0]).style,e=["transform","webkitTransform","msTransform","mozTransform"],n=0,i=e.length;n<i;n++)if(e[n]in t)return e[n];return""}();function a(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function h(t,e){var n;if(void 0===e&&(e=!1),"string"==typeof t){if(t.match(/^<([a-z]+)\s*([^>]*)>/)){var i=document.createElement("div");i.innerHTML=t,n=a(i.childNodes)}else n=a(document.querySelectorAll(t));e||(n=1<=n.length?n[0]:void 0)}else t===s?n=t:!t.nodeName||1!==t.nodeType&&9!==t.nodeType?"jQuery"in s&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return h(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var v=s.requestAnimationFrame||s.webkitRequestAnimationFrame,u=s.cancelAnimationFrame||s.webkitCancelAnimationFrame;if(v&&!u){var c={},m=v;v=function(e){var n=m(function(t){c[n]&&e(t)});return c[n]=!0,n},u=function(t){delete c[t]}}else v&&u||(v=function(t){return s.setTimeout(function(){t(s.performance&&s.performance.now&&s.performance.now()||(new Date).getTime())},16)},u=s.clearTimeout);function g(t){return _(t,function(t){return d(t)})}function _(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function l(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function f(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function E(t,n){return f(t,function(t,e){return t===n[e]})}function d(t){return Math.round(t*e)/e}function b(t,e,n,i){var s=t,r=[n[0]?e[0]:i?e[0]-i[0]:e[0],n[1]?e[1]:i?e[1]+i[1]:e[1]];return s=Math.max(r[0],s),+d(s=Math.min(r[1],s))}function x(t,e){return t<e[0]||t>e[1]}function I(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function T(t,e,n,i){var s=t,r=e[0],o=e[1],a=o-r;return n[1]&&o<t&&(s=(s-o)%a+r),n[0]&&t<r&&(s=(s-r)%a+o),i?s:+d(s)}function y(t,e,n){return Math.max(Math.min(t,n),e)}var O=function(){function t(t){var e=t.options,n=t.itm,i=t.em,s=t.axm;this.options=e,this.itm=n,this.em=i,this.axm=s,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(r,t,e){var n,o=this;if(void 0!==e)n=e;else{var i=_(t,function(t,e){return n=Math.abs(t-r[e]),i=o.options.deceleration,(s=Math.sqrt(n/i*2))<100?0:s;var n,i,s});n=Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)}return y(n,this.options.minimumDuration,this.options.maximumDuration)},e.createAnimationParam=function(t,e,n){var i=this.axm.get(),s=t,r=n&&n.event||null;return{depaPos:i,destPos:s,duration:y(e,this.options.minimumDuration,this.options.maximumDuration),delta:this.axm.getDelta(i,s),inputEvent:r,input:n&&n.input||null,isTrusted:!!r,done:this.animationEnd}},e.grab=function(t,e){if(this._animateParam&&t.length){var n=this.axm.get(t),i=this.axm.map(n,function(t,e){return T(t,e.range,e.circular,!1)});f(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(s=this._raf,u(s)),this._raf=null,this.em.triggerAnimationEnd(!(!e||!e.event))}var s},e.getEventInfo=function(){return this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent?{input:this._animateParam.input,event:this._animateParam.inputEvent}:null},e.restore=function(t){var e=this.axm.get(),n=this.axm.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axm.filter(this.axm.get(),function(t,e){return I(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return T(t,e.range,e.circular,!1)})),this.itm.setInterrupt(!1),this.em.triggerAnimationEnd(!!t),this.axm.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.itm.setInterrupt(!1),this.em.triggerFinish(t)},e.animateLoop=function(s,r){if(s.duration){this._animateParam=p({},s);var h=this._animateParam,u=this,c=h.destPos,m=h.depaPos,l=0,f=_(m,function(t,e){return t<=c[e]?1:-1}),d=(new Date).getTime();h.startTime=d,function t(){u._raf=null;var e=(new Date).getTime(),o=(e-h.startTime)/s.duration,a=u.easing(o),n=u.axm.map(m,function(t,e,n){var i=1<=o?c[n]:t+h.delta[n]*(a-l),s=T(i,e.range,e.circular,!0);if(i!==s){var r=f[n]*(e.range[1]-e.range[0]);c[n]-=r,m[n]-=r}return s}),i=!u.em.triggerChange(n,!1,g(m));if(m=n,d=e,1<=(l=a))return E(c,u.axm.get(Object.keys(c)))||u.em.triggerChange(c,!0,g(m)),void r();i?u.finish(!1):u._raf=v(t)}()}else this.em.triggerChange(s.destPos,!0),r()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=y(e.duration,this.options.minimumDuration,this.options.maximumDuration),e},e.animateTo=function(t,e,n){var i=this,s=this.createAnimationParam(t,e,n),r=p({},s.depaPos),o=this.em.triggerAnimationStart(s),a=this.getUserControll(s);if(!o&&this.axm.every(a.destPos,function(t,e){return I(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!E(a.destPos,r)){var h=n&&n.event||null;this.animateLoop({depaPos:r,destPos:a.destPos,duration:a.duration,delta:this.axm.getDelta(r,a.destPos),isTrusted:!!h,inputEvent:h,input:n&&n.input||null},function(){return i.animationEnd()})}},e.easing=function(t){return 1<t?1:this.options.easing(t)},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t);this.grab(n);var i=this.axm.get(n);if(E(t,i))return this;this.itm.setInterrupt(!0);var s=l(t,function(t,e){return i[e]!==t});return Object.keys(s).length&&(E(s=this.axm.map(s,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:b(t,n,i)}),i)||(0<e?this.animateTo(s,e):(this.em.triggerChange(s),this.finish(!1)))),this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(_(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),P=function(){function t(t){this.axes=t}var e=t.prototype;return e.triggerHold=function(t,e){this.axes.trigger("hold",{pos:t,input:e.input||null,inputEvent:e.event||null,isTrusted:!0})},e.triggerRelease=function(t){t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("release",t)},e.triggerChange=function(t,e,n,i,s){void 0===s&&(s=!1);var r=this.am,o=r.axm,a=r.getEventInfo(),h=o.moveTo(t,e,n),u=i&&i.event||a&&a.event||null,c={pos:h.pos,delta:h.delta,holding:s,inputEvent:u,isTrusted:!!u,input:i&&i.input||a&&a.input||null,set:u?this.createUserControll(h.pos):function(){}},m=this.axes.trigger("change",c);return u&&o.set(c.set().destPos),m},e.triggerAnimationStart=function(t){return t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("animationStart",t)},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this.axes.trigger("animationEnd",{isTrusted:t})},e.triggerFinish=function(t){void 0===t&&(t=!1),this.axes.trigger("finish",{isTrusted:t})},e.createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:p({},t),duration:e};return function(t,e){return t&&(n.destPos=p({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},t}(),D=function(){function t(t){this.options=t,this._prevented=!1}var e=t.prototype;return e.isInterrupting=function(){return this.options.interruptable||this._prevented},e.isInterrupted=function(){return!this.options.interruptable&&this._prevented},e.setInterrupt=function(t){!this.options.interruptable&&(this._prevented=t)},t}(),R=function(){function t(t,e){var n=this;this.axis=t,this.options=e,this._complementOptions(),this._pos=Object.keys(this.axis).reduce(function(t,e){return t[e]=n.axis[e].range[0],t},{})}var e=t.prototype;return e._complementOptions=function(){var s=this;Object.keys(this.axis).forEach(function(i){s.axis[i]=p({range:[0,100],bounce:[0,0],circular:[!1,!1]},s.axis[i]),["bounce","circular"].forEach(function(t){var e=s.axis,n=e[i][t];/string|number|boolean/.test(typeof n)&&(e[i][t]=[n,n])})})},e.getDelta=function(t,e){var n=this.get(t);return _(this.get(e),function(t,e){return t-n[e]})},e.get=function(t){var n=this;return t&&Array.isArray(t)?t.reduce(function(t,e){return e&&e in n._pos&&(t[e]=n._pos[e]),t},{}):p({},this._pos,t||{})},e.moveTo=function(n,i,s){void 0===s&&(s=this._pos);var t=_(this._pos,function(t,e){return e in n&&e in s?n[e]-s[e]:0});return this.set(this.map(n,function(t,e){return e?T(t,e.range,e.circular,i):0})),{pos:p({},this._pos),delta:t}},e.set=function(t){for(var e in t)e&&e in this._pos&&(this._pos[e]=t[e])},e.every=function(t,n){var i=this.axis;return f(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return l(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return _(t,function(t,e){return n(t,i[e],e)})},e.isOutside=function(t){return!this.every(t?this.get(t):this._pos,function(t,e){return!x(t,e.range)})},t}(),C=function(){function t(t){var e=t.options,n=t.itm,i=t.em,s=t.axm,r=t.am;this.isOutside=!1,this.moveDistance=null,this.isStopped=!1,this.options=e,this.itm=n,this.em=i,this.axm=s,this.am=r}var e=t.prototype;return e.atOutside=function(t){var o=this;if(this.isOutside)return this.axm.map(t,function(t,e){var n=e.range[0]-e.bounce[0],i=e.range[1]+e.bounce[1];return i<t?i:t<n?n:t});var a=this.am.easing(1e-5)/1e-5;return this.axm.map(t,function(t,e){var n=e.range[0],i=e.range[1],s=e.bounce,r=e.circular;return r&&(r[0]||r[1])?t:t<n?n-o.am.easing((n-t)/(s[0]*a))*s[0]:i<t?i+o.am.easing((t-i)/(s[1]*a))*s[1]:t})},e.get=function(t){return this.axm.get(t.axes)},e.hold=function(t,e){if(!this.itm.isInterrupted()&&t.axes.length){var n={input:t,event:e};this.isStopped=!1,this.itm.setInterrupt(!0),this.am.grab(t.axes,n),!this.moveDistance&&this.em.triggerHold(this.axm.get(),n),this.isOutside=this.axm.isOutside(t.axes),this.moveDistance=this.axm.get(t.axes)}},e.change=function(t,e,n){if(!this.isStopped&&this.itm.isInterrupting()&&!this.axm.every(n,function(t){return 0===t})){var i,s=this.moveDistance||this.axm.get(t.axes);i=_(s,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(s,function(t,e){return!x(t,e.range)})&&(this.isOutside=!1),s=this.atOutside(s),i=this.atOutside(i),!this.em.triggerChange(i,!1,s,{input:t,event:e},!0)&&(this.isStopped=!0,this.moveDistance=null,this.am.finish(!1))}},e.release=function(t,e,n,i){if(!this.isStopped&&this.itm.isInterrupting()&&this.moveDistance){var s=this.axm.get(t.axes),r=this.axm.get(),o=this.axm.get(this.axm.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?s[n]+t:b(s[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,s,i);0===a&&(o=p({},r));var h={depaPos:r,destPos:o,duration:a,delta:this.axm.getDelta(r,o),inputEvent:e,input:t,isTrusted:!0};this.em.triggerRelease(h),this.moveDistance=null;var u=this.am.getUserControll(h),c=E(u.destPos,r),m={input:t,event:e};c||0===u.duration?(!c&&this.em.triggerChange(u.destPos,!1,r,m,!0),this.itm.setInterrupt(!1),this.axm.isOutside()?this.am.restore(m):this.em.triggerFinish(!0)):this.am.animateTo(u.destPos,u.duration,m)}},t}(),A=function(s){function t(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i=s.call(this)||this;return i.axis=t,i._inputs=[],i.options=p({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4},e),i.itm=new D(i.options),i.axm=new R(i.axis,i.options),i.em=new P(i),i.am=new O(i),i.io=new C(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}n(t,s);var e=t.prototype;return e.connect=function(t,e){var n;if(n="string"==typeof t?t.split(" "):t.concat(),~this._inputs.indexOf(e)&&this.disconnect(e),"hammer"in e){var i=this._inputs.filter(function(t){return t.hammer&&t.element===e.element});i.length&&(e.hammer=i[0].hammer)}return e.mapAxes(n),e.connect(this.io),this._inputs.push(e),this},e.disconnect=function(t){if(t){var e=this._inputs.indexOf(t);0<=e&&(this._inputs[e].disconnect(),this._inputs.splice(e,1))}else this._inputs.forEach(function(t){return t.disconnect()}),this._inputs=[];return this},e.get=function(t){return this.axm.get(t)},e.setTo=function(t,e){return void 0===e&&(e=0),this.am.setTo(t,e),this},e.setBy=function(t,e){return void 0===e&&(e=0),this.am.setBy(t,e),this},e.isBounceArea=function(t){return this.axm.isOutside(t)},e.destroy=function(){this.disconnect(),this.em.destroy()},t.VERSION="2.5.14",t.TRANSFORM=r,t.DIRECTION_NONE=o.DIRECTION_NONE,t.DIRECTION_LEFT=o.DIRECTION_LEFT,t.DIRECTION_RIGHT=o.DIRECTION_RIGHT,t.DIRECTION_UP=o.DIRECTION_UP,t.DIRECTION_DOWN=o.DIRECTION_DOWN,t.DIRECTION_HORIZONTAL=o.DIRECTION_HORIZONTAL,t.DIRECTION_VERTICAL=o.DIRECTION_VERTICAL,t.DIRECTION_ALL=o.DIRECTION_ALL,t}(t),N="PointerEvent"in s||"MSPointerEvent"in s,w="ontouchstart"in s,M="_EGJS_AXES_INPUTTYPE_";function L(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function H(t,e){try{return new o.Manager(t,p({},e))}catch(t){return null}}function j(t){void 0===t&&(t=[]);var e=!1,n=!1,i=!1;return t.forEach(function(t){switch(t){case"mouse":n=!0;break;case"touch":e=w;break;case"pointer":i=N}}),i?o.PointerEventInput:e&&n?o.TouchMouseInput:e?o.TouchInput:n?o.MouseInput:null}function z(t,e,n){return n?!!(e===o.DIRECTION_ALL||e&t&&n&t):!!(e&t)}var S=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,void 0===o.Manager)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=h(t),this.options=p({inputType:["touch","mouse","pointer"],scale:[1,1],thresholdAngle:45,threshold:0,hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onHammerInput=this.onHammerInput.bind(this),this.onPanmove=this.onPanmove.bind(this),this.onPanend=this.onPanend.bind(this)}var e=t.prototype;return e.mapAxes=function(t){var e=!!t[0],n=!!t[1];this._direction=e&&n?o.DIRECTION_ALL:e?o.DIRECTION_HORIZONTAL:n?o.DIRECTION_VERTICAL:o.DIRECTION_NONE,this.axes=t},e.connect=function(t){var e={direction:this._direction,threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[M];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=j(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=H(this.element,p({inputClass:i},this.options.hammerManagerOptions)),this.element[M]=n}return this.panRecognizer=new o.Pan(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=o.DIRECTION_NONE,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[M],this.element=null,this.hammer=null},e.enable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pan").options.enable)},e.removeRecognizer=function(){this.hammer&&this.panRecognizer&&(this.hammer.remove(this.panRecognizer),this.panRecognizer=null)},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?this.observer.hold(this,t):t.isFinal&&this.onPanend(t))},e.onPanmove=function(t){var e=function(t,e){if(e<0||90<e)return o.DIRECTION_NONE;var n=Math.abs(t);return e<n&&n<180-e?o.DIRECTION_VERTICAL:o.DIRECTION_HORIZONTAL}(t.angle,this.options.thresholdAngle),n=this.hammer.session.prevInput;t.offsetY=n?(t.offsetX=t.deltaX-n.deltaX,t.deltaY-n.deltaY):t.offsetX=0;var i=this.getOffset([t.offsetX,t.offsetY],[z(o.DIRECTION_HORIZONTAL,this._direction,e),z(o.DIRECTION_VERTICAL,this._direction,e)]),s=i.some(function(t){return 0!==t});s&&(t.srcEvent.preventDefault(),t.srcEvent.stopPropagation()),(t.preventSystemEvent=s)&&this.observer.change(this,t,L(this.axes,i))},e.onPanend=function(t){var e,n,i,s,r=this.getOffset([Math.abs(t.velocityX)*(t.deltaX<0?-1:1),Math.abs(t.velocityY)*(t.deltaY<0?-1:1)],[z(o.DIRECTION_HORIZONTAL,this._direction),z(o.DIRECTION_VERTICAL,this._direction)]);e=r,n=this.observer.options.deceleration,i=Math.sqrt(e[0]*e[0]+e[1]*e[1]),s=Math.abs(i/-n),r=[e[0]/2*s,e[1]/2*s],this.observer.release(this,t,L(this.axes,r))},e.attachEvent=function(t){this.observer=t,this.hammer.on("hammer.input",this.onHammerInput).on("panstart panmove",this.onPanmove)},e.dettachEvent=function(){this.hammer.off("hammer.input",this.onHammerInput).off("panstart panmove",this.onPanmove),this.observer=null},e.getOffset=function(t,e){var n=[0,0],i=this.options.scale;return e[0]&&(n[0]=t[0]*i[0]),e[1]&&(n[1]=t[1]*i[1]),n},t}(),k=function(i){function t(t,e){var n=i.call(this,t,e)||this;return n.prevQuadrant=null,n.lastDiff=0,n}n(t,i);var e=t.prototype;return e.mapAxes=function(t){this._direction=A.DIRECTION_ALL,this.axes=t},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?(this.observer.hold(this,t),this.onPanstart(t)):t.isFinal&&this.onPanend(t))},e.onPanstart=function(t){var e=this.element.getBoundingClientRect();this.coefficientForDistanceToAngle=360/(e.width*Math.PI),this.rotateOrigin=[e.left+(e.width-1)/2,e.top+(e.height-1)/2],this.prevAngle=null,this.triggerChange(t)},e.onPanmove=function(t){this.triggerChange(t)},e.onPanend=function(t){this.triggerChange(t),this.triggerAnimation(t)},e.triggerChange=function(t){var e=this.getAngle(t.center.x,t.center.y),n=this.getQuadrant(t.center.x,t.center.y),i=this.getDifference(this.prevAngle,e,this.prevQuadrant,n);this.prevAngle=e,this.prevQuadrant=n,0!==i&&(this.lastDiff=i,this.observer.change(this,t,L(this.axes,[-i])))},e.triggerAnimation=function(t){var e=t.velocityX,n=t.velocityY,i=Math.sqrt(e*e+n*n)*(0<this.lastDiff?-1:1),s=i/2*Math.abs(i/-this.observer.options.deceleration);this.observer.release(this,t,L(this.axes,[s*this.coefficientForDistanceToAngle]))},e.getDifference=function(t,e,n,i){return null===t?0:1===n&&4===i?-t-(360-e):4===n&&1===i?360-t+e:e-t},e.getPosFromOrigin=function(t,e){return{x:t-this.rotateOrigin[0],y:this.rotateOrigin[1]-e}},e.getAngle=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,s=n.y,r=180*Math.atan2(s,i)/Math.PI;return r<0?360+r:r},e.getQuadrant=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,s=n.y,r=0;return 0<=i&&0<=s?r=1:i<0&&0<=s?r=2:i<0&&s<0?r=3:0<=i&&s<0&&(r=4),r},t}(S),F=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this._base=null,this._prev=null,this.pinchRecognizer=null,void 0===o.Manager)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=h(t),this.options=p({scale:1,threshold:0,inputType:["touch","pointer"],hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onPinchStart=this.onPinchStart.bind(this),this.onPinchMove=this.onPinchMove.bind(this),this.onPinchEnd=this.onPinchEnd.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){var e={threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[M];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=j(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=H(this.element,p({inputClass:i},this.options.hammerManagerOptions)),this.element[M]=n}return this.pinchRecognizer=new o.Pinch(e),this.hammer.add(this.pinchRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null,this.dettachEvent()),this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[M],this.element=null,this.hammer=null},e.removeRecognizer=function(){this.hammer&&this.pinchRecognizer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null)},e.onPinchStart=function(t){this._base=this.observer.get(this)[this.axes[0]];var e=this.getOffset(t.scale);this.observer.hold(this,t),this.observer.change(this,t,L(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,L(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,L(this.axes,[e])),this.observer.release(this,t,L(this.axes,[0]),0),this._base=null,this._prev=null},e.getOffset=function(t,e){return void 0===e&&(e=1),this._base*(t-e)*this.options.scale},e.attachEvent=function(t){this.observer=t,this.hammer.on("pinchstart",this.onPinchStart).on("pinchmove",this.onPinchMove).on("pinchend",this.onPinchEnd)},e.dettachEvent=function(){this.hammer.off("pinchstart",this.onPinchStart).off("pinchmove",this.onPinchMove).off("pinchend",this.onPinchEnd),this.observer=null,this._prev=null},e.enable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pinch").options.enable)},t}(),K=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=h(t),this.options=p({scale:1,useNormalized:!0},e),this.onWheel=this.onWheel.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onWheel=function(t){var e=this;if(this._isEnabled&&(t.preventDefault(),0!==t.deltaY)){this._isHolded||(this.observer.hold(this,t),this._isHolded=!0);var n=(0<t.deltaY?-1:1)*this.options.scale*(this.options.useNormalized?1:Math.abs(t.deltaY));this.observer.change(this,t,L(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,L(e.axes,[0])))},50)}},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("wheel",this.onWheel),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("wheel",this.onWheel),this._isEnabled=!1,this.observer=null,this._timer&&(clearTimeout(this._timer),this._timer=null)},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),Y=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=h(t),this.options=p({scale:[1,1]},e),this.onKeydown=this.onKeydown.bind(this),this.onKeyup=this.onKeyup.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),"0"!==this.element.getAttribute("tabindex")&&this.element.setAttribute("tabindex","0"),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onKeydown=function(t){if(this._isEnabled){var e=!0,n=1,i=-1;switch(t.keyCode){case 37:case 65:n=-1;break;case 39:case 68:break;case 40:case 83:n=-1,i=1;break;case 38:case 87:i=1;break;default:e=!1}if((-1===i&&!this.axes[0]||1===i&&!this.axes[1])&&(e=!1),e){var s=-1===i?[+this.options.scale[0]*n,0]:[0,+this.options.scale[1]*n];this._isHolded||(this.observer.hold(this,event),this._isHolded=!0),clearTimeout(this._timer),this.observer.change(this,event,L(this.axes,s))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,L(e.axes,[0,0])),e._isHolded=!1},80))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("keydown",this.onKeydown,!1),this.element.addEventListener("keypress",this.onKeydown,!1),this.element.addEventListener("keyup",this.onKeyup,!1),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("keydown",this.onKeydown,!1),this.element.removeEventListener("keypress",this.onKeydown,!1),this.element.removeEventListener("keyup",this.onKeyup,!1),this._isEnabled=!1,this.observer=null},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}();return A.PanInput=S,A.RotatePanInput=k,A.PinchInput=F,A.WheelInput=K,A.MoveKeyInput=Y,A}); | ||
//# sourceMappingURL=axes.min.js.map |
@@ -8,3 +8,3 @@ /* | ||
@version 2.5.13 | ||
@version 2.5.14 | ||
@@ -14,3 +14,3 @@ All-in-one packaged file for ease use of '@egjs/axes' with below dependencies. | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t.eg=t.eg||{},t.eg.Axes=e())}(this,function(){"use strict";var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var m=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t};function a(t){return void 0===t}var r,t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],s=0;e.stop=function(){i=!0},e.currentTarget=this;for(var o=arguments.length,a=new Array(2<o?o-2:0),h=2;h<o;h++)a[h-2]=arguments[h];for(1<=a.length&&(r=r.concat(a)),s=0;n[s];s++)n[s].apply(this,r);return!i},e.once=function(r,s){if("object"==typeof r&&a(s)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof s){var o=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];s.apply(o,n),o.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,s,o=this._eventHandler[t];if(o)for(r=0;void 0!==(s=o[r]);r++)if(s===e){o=o.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function o(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}r="undefined"==typeof window?{}:window;var u,c="function"!=typeof Object.assign?function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign,l=["","webkit","Moz","MS","ms","o"],e="undefined"==typeof document?{style:{}}:document.createElement("div"),f="function",p=Math.round,E=Math.abs,_=Date.now;function d(t,e){for(var n,i,r=e[0].toUpperCase()+e.slice(1),s=0;s<l.length;){if((i=(n=l[s])?n+r:e)in t)return i;s++}}u="undefined"==typeof window?{}:window;var v=d(e.style,"touchAction"),g=void 0!==v;var y="compute",b="auto",x="manipulation",T="none",P="pan-x",w="pan-y",O=function(){if(!g)return!1;var e={},n=u.CSS&&u.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return e[t]=!n||u.CSS.supports("touch-action",t)}),e}(),A="ontouchstart"in u,I=void 0!==d(u,"PointerEvent"),D=A&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),M="touch",C="mouse",R=25,z=1,S=4,H=8,Y=1,F=2,X=4,k=8,j=16,W=F|X,N=k|j,q=W|N,L=["x","y"],K=["clientX","clientY"];function U(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(void 0!==t.length)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function Q(t,e){return typeof t===f?t.apply(e&&e[0]||void 0,e):t}function V(t,e){return-1<t.indexOf(e)}var B=function(){function t(t,e){this.manager=t,this.set(e)}var e=t.prototype;return e.set=function(t){t===y&&(t=this.compute()),g&&this.manager.element.style&&O[t]&&(this.manager.element.style[v]=t),this.actions=t.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var e=[];return U(this.manager.recognizers,function(t){Q(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),function(t){if(V(t,T))return T;var e=V(t,P),n=V(t,w);return e&&n?T:e||n?e?P:w:V(t,x)?x:b}(e.join(" "))},e.preventDefaults=function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,r=V(i,T)&&!O[T],s=V(i,w)&&!O[w],o=V(i,P)&&!O[P];if(r){var a=1===t.pointers.length,h=t.distance<2,u=t.deltaTime<250;if(a&&h&&u)return}if(!o||!s)return r||s&&n&W||o&&n&N?this.preventSrc(e):void 0}},e.preventSrc=function(t){this.manager.session.prevented=!0,t.preventDefault()},t}();function G(t,e){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function Z(t){var e=t.length;if(1===e)return{x:p(t[0].clientX),y:p(t[0].clientY)};for(var n=0,i=0,r=0;r<e;)n+=t[r].clientX,i+=t[r].clientY,r++;return{x:p(n/e),y:p(i/e)}}function J(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:p(t.pointers[n].clientX),clientY:p(t.pointers[n].clientY)},n++;return{timeStamp:_(),pointers:e,center:Z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function $(t,e,n){n||(n=L);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return Math.sqrt(i*i+r*r)}function tt(t,e,n){n||(n=L);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return 180*Math.atan2(r,i)/Math.PI}function et(t,e){return t===e?Y:E(t)>=E(e)?t<0?F:X:e<0?k:j}function nt(t,e,n){return{x:e/t||0,y:n/t||0}}function it(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=J(e)),1<r&&!n.firstMultiple?n.firstMultiple=J(e):1===r&&(n.firstMultiple=!1);var s,o,a,h,u,c,l=n.firstInput,f=n.firstMultiple,p=f?f.center:l.center,m=e.center=Z(i);e.timeStamp=_(),e.deltaTime=e.timeStamp-l.timeStamp,e.angle=tt(p,m),e.distance=$(p,m),s=n,a=(o=e).center,h=s.offsetDelta||{},u=s.prevDelta||{},c=s.prevInput||{},o.eventType!==z&&c.eventType!==S||(u=s.prevDelta={x:c.deltaX||0,y:c.deltaY||0},h=s.offsetDelta={x:a.x,y:a.y}),o.deltaX=u.x+(a.x-h.x),o.deltaY=u.y+(a.y-h.y),e.offsetDirection=et(e.deltaX,e.deltaY);var d,v,g,y,b=nt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=b.x,e.overallVelocityY=b.y,e.overallVelocity=E(b.x)>E(b.y)?b.x:b.y,e.scale=f?(d=f.pointers,$((v=i)[0],v[1],K)/$(d[0],d[1],K)):1,e.rotation=f?(g=f.pointers,tt((y=i)[1],y[0],K)+tt(g[1],g[0],K)):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,r,s,o=t.lastInterval||e,a=e.timeStamp-o.timeStamp;if(e.eventType!==H&&(R<a||void 0===o.velocity)){var h=e.deltaX-o.deltaX,u=e.deltaY-o.deltaY,c=nt(a,h,u);i=c.x,r=c.y,n=E(c.x)>E(c.y)?c.x:c.y,s=et(h,u),t.lastInterval=e}else n=o.velocity,i=o.velocityX,r=o.velocityY,s=o.direction;e.velocity=n,e.velocityX=i,e.velocityY=r,e.direction=s}(n,e);var x=t.element;G(e.srcEvent.target,x)&&(x=e.srcEvent.target),e.target=x}function rt(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=e&z&&i-r==0,o=e&(S|H)&&i-r==0;n.isFirst=!!s,n.isFinal=!!o,s&&(t.session={}),n.eventType=e,it(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function st(t){return t.trim().split(/\s+/g)}function ot(e,t,n){U(st(t),function(t){e.addEventListener(t,n,!1)})}function at(e,t,n){U(st(t),function(t){e.removeEventListener(t,n,!1)})}function ht(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow||window}var ut=function(){function t(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){Q(e.options.enable,[e])&&n.handler(t)},this.init()}var e=t.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ot(this.element,this.evEl,this.domHandler),this.evTarget&&ot(this.target,this.evTarget,this.domHandler),this.evWin&&ot(ht(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&at(this.element,this.evEl,this.domHandler),this.evTarget&&at(this.target,this.evTarget,this.domHandler),this.evWin&&at(ht(this.element),this.evWin,this.domHandler)},t}();function ct(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}var lt={pointerdown:z,pointermove:2,pointerup:S,pointercancel:H,pointerout:H},ft={2:M,3:"pen",4:C,5:"kinect"},pt="pointerdown",mt="pointermove pointerup pointercancel";u.MSPointerEvent&&!u.PointerEvent&&(pt="MSPointerDown",mt="MSPointerMove MSPointerUp MSPointerCancel");var dt=function(n){function i(){var t,e=i.prototype;return e.evEl=pt,e.evWin=mt,(t=n.apply(this,arguments)||this).store=t.manager.session.pointerEvents=[],t}return o(i,n),i.prototype.handler=function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),r=lt[i],s=ft[t.pointerType]||t.pointerType,o=s===M,a=ct(e,t.pointerId,"pointerId");r&z&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):r&(S|H)&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:s,srcEvent:t}),n&&e.splice(a,1))},i}(ut);function vt(t){return Array.prototype.slice.call(t,0)}function gt(t,n,e){for(var i=[],r=[],s=0;s<t.length;){var o=n?t[s][n]:t[s];ct(r,o)<0&&i.push(t[s]),r[s]=o,s++}return e&&(i=n?i.sort(function(t,e){return t[n]>e[n]}):i.sort()),i}var yt={touchstart:z,touchmove:2,touchend:S,touchcancel:H},bt=function(e){function n(){var t;return n.prototype.evTarget="touchstart touchmove touchend touchcancel",(t=e.apply(this,arguments)||this).targetIds={},t}return o(n,e),n.prototype.handler=function(t){var e=yt[t.type],n=function(t,e){var n,i,r=vt(t.touches),s=this.targetIds;if(e&(2|z)&&1===r.length)return s[r[0].identifier]=!0,[r,r];var o=vt(t.changedTouches),a=[],h=this.target;if(i=r.filter(function(t){return G(t.target,h)}),e===z)for(n=0;n<i.length;)s[i[n].identifier]=!0,n++;n=0;for(;n<o.length;)s[o[n].identifier]&&a.push(o[n]),e&(S|H)&&delete s[o[n].identifier],n++;return a.length?[gt(i.concat(a),"identifier",!0),a]:void 0}.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:t})},n}(ut);var xt={mousedown:z,mousemove:2,mouseup:S},Et=function(n){function i(){var t,e=i.prototype;return e.evEl="mousedown",e.evWin="mousemove mouseup",(t=n.apply(this,arguments)||this).pressed=!1,t}return o(i,n),i.prototype.handler=function(t){var e=xt[t.type];e&z&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=S),this.pressed&&(e&S&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:C,srcEvent:t}))},i}(ut),_t=2500,Tt=25;function Pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={x:e.clientX,y:e.clientY},i=this.lastTouches;this.lastTouches.push(n);setTimeout(function(){var t=i.indexOf(n);-1<t&&i.splice(t,1)},_t)}}var wt=function(){return function(n){function t(t,e){var s;return(s=n.call(this,t,e)||this).handler=function(t,e,n){var i=n.pointerType===M,r=n.pointerType===C;if(!(r&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)(function(t,e){t&z?(this.primaryTouch=e.changedPointers[0].identifier,Pt.call(this,e)):t&(S|H)&&Pt.call(this,e)}).call(h(h(s)),e,n);else if(r&&function(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var r=this.lastTouches[i],s=Math.abs(e-r.x),o=Math.abs(n-r.y);if(s<=Tt&&o<=Tt)return!0}return!1}.call(h(h(s)),n))return;s.callback(t,e,n)}},s.touch=new bt(s.manager,s.handler),s.mouse=new Et(s.manager,s.handler),s.primaryTouch=null,s.lastTouches=[],s}return o(t,n),t.prototype.destroy=function(){this.touch.destroy(),this.mouse.destroy()},t}(ut)}();function Ot(t,e,n){return!!Array.isArray(t)&&(U(t,n[e],n),!0)}var At=1;function It(t,e){var n=e.manager;return n?n.get(t):t}function Dt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}var Mt=function(){function t(t){void 0===t&&(t={}),this.options=s({enable:!0},t),this.id=At++,this.manager=null,this.state=1,this.simultaneous={},this.requireFail=[]}var e=t.prototype;return e.set=function(t){return c(this.options,t),this.manager&&this.manager.touchAction.update(),this},e.recognizeWith=function(t){if(Ot(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=It(t,this)).id]||(e[t.id]=t).recognizeWith(this),this},e.dropRecognizeWith=function(t){return Ot(t,"dropRecognizeWith",this)||(t=It(t,this),delete this.simultaneous[t.id]),this},e.requireFailure=function(t){if(Ot(t,"requireFailure",this))return this;var e=this.requireFail;return-1===ct(e,t=It(t,this))&&(e.push(t),t.requireFailure(this)),this},e.dropRequireFailure=function(t){if(Ot(t,"dropRequireFailure",this))return this;t=It(t,this);var e=ct(this.requireFail,t);return-1<e&&this.requireFail.splice(e,1),this},e.hasRequireFailures=function(){return 0<this.requireFail.length},e.canRecognizeWith=function(t){return!!this.simultaneous[t.id]},e.emit=function(e){var n=this,t=this.state;function i(t){n.manager.emit(t,e)}t<8&&i(n.options.event+Dt(t)),i(n.options.event),e.additionalEvent&&i(e.additionalEvent),8<=t&&i(n.options.event+Dt(t))},e.tryEmit=function(t){if(this.canEmit())return this.emit(t);this.state=32},e.canEmit=function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},e.recognize=function(t){var e=c({},t);if(!Q(this.options.enable,[this,e]))return this.reset(),void(this.state=32);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},e.process=function(t){},e.getTouchAction=function(){},e.reset=function(){},t}(),Ct={domEvents:!1,touchAction:y,enable:!0,inputTarget:null,inputClass:null,preset:[],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Rt(n,i){var r,s=n.element;s.style&&(U(n.options.cssProps,function(t,e){r=d(s.style,e),s.style[r]=i?(n.oldCssProps[r]=s.style[r],t):n.oldCssProps[r]||""}),i||(n.oldCssProps={}))}var zt=function(){function t(t,e){var n,i=this;this.options=c({},Ct,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(I?dt:D?bt:A?wt:Et))(n,rt),this.touchAction=new B(this,this.options.touchAction),Rt(this,!0),U(this.options.recognizers,function(t){var e=i.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])},this)}var e=t.prototype;return e.set=function(t){return c(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},e.stop=function(t){this.session.stopped=t?2:1},e.recognize=function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,r=e.curRecognizer;(!r||r&&8&r.state)&&(r=e.curRecognizer=null);for(var s=0;s<i.length;)n=i[s],2===e.stopped||r&&n!==r&&!n.canRecognizeWith(r)?n.reset():n.recognize(t),!r&&14&n.state&&(r=e.curRecognizer=n),s++}},e.get=function(t){if(t instanceof Mt)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event===t)return e[n];return null},e.add=function(t){if(Ot(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),(t.manager=this).touchAction.update(),t},e.remove=function(t){if(Ot(t,"remove",this))return this;var e=this.get(t);if(t){var n=this.recognizers,i=ct(n,e);-1!==i&&(n.splice(i,1),this.touchAction.update())}return this},e.on=function(t,e){if(void 0===t||void 0===e)return this;var n=this.handlers;return U(st(t),function(t){n[t]=n[t]||[],n[t].push(e)}),this},e.off=function(t,e){if(void 0===t)return this;var n=this.handlers;return U(st(t),function(t){e?n[t]&&n[t].splice(ct(n[t],e),1):delete n[t]}),this},e.emit=function(t,e){var n,i,r;this.options.domEvents&&(n=t,i=e,(r=document.createEvent("Event")).initEvent(n,!0,!0),(r.gesture=i).target.dispatchEvent(r));var s=this.handlers[t]&&this.handlers[t].slice();if(s&&s.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var o=0;o<s.length;)s[o](e),o++}},e.destroy=function(){this.element&&Rt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null},t}();var St=function(e){function t(t){return void 0===t&&(t={}),e.call(this,s({pointers:1},t))||this}o(t,e);var n=t.prototype;return n.attrTest=function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},n.process=function(t){var e=this.state,n=t.eventType,i=6&e,r=this.attrTest(t);return i&&(n&H||!r)?16|e:i||r?n&S?8|e:2&e?4|e:2:32},t}(Mt);function Ht(t){return t===j?"down":t===k?"up":t===F?"left":t===X?"right":""}var Yt=function(n){function t(t){var e;return void 0===t&&(t={}),(e=n.call(this,s({event:"pan",threshold:10,pointers:1,direction:q},t))||this).pX=null,e.pY=null,e}o(t,n);var e=t.prototype;return e.getTouchAction=function(){var t=this.options.direction,e=[];return t&W&&e.push(w),t&N&&e.push(P),e},e.directionTest=function(t){var e=this.options,n=!0,i=t.distance,r=t.direction,s=t.deltaX,o=t.deltaY;return r&e.direction||(i=e.direction&W?(r=0===s?Y:s<0?F:X,n=s!==this.pX,Math.abs(t.deltaX)):(r=0===o?Y:o<0?k:j,n=o!==this.pY,Math.abs(t.deltaY))),t.direction=r,n&&i>e.threshold&&r&e.direction},e.attrTest=function(t){return St.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},e.emit=function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Ht(t.direction);e&&(t.additionalEvent=this.options.event+e),n.prototype.emit.call(this,t)},t}(St),Ft=function(n){function t(t){return void 0===t&&(t={}),n.call(this,s({event:"pinch",threshold:0,pointers:2},t))||this}o(t,n);var e=t.prototype;return e.getTouchAction=function(){return[T]},e.attrTest=function(t){return n.prototype.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},e.emit=function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}n.prototype.emit.call(this,t)},t}(St),Xt=1e5,kt=function(){if("undefined"==typeof document)return"";for(var t=(document.head||document.getElementsByTagName("head")[0]).style,e=["transform","webkitTransform","msTransform","mozTransform"],n=0,i=e.length;n<i;n++)if(e[n]in t)return e[n];return""}();function jt(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function Wt(t,e){var n;if(void 0===e&&(e=!1),"string"==typeof t){if(t.match(/^<([a-z]+)\s*([^>]*)>/)){var i=document.createElement("div");i.innerHTML=t,n=jt(i.childNodes)}else n=jt(document.querySelectorAll(t));e||(n=1<=n.length?n[0]:void 0)}else t===r?n=t:!t.nodeName||1!==t.nodeType&&9!==t.nodeType?"jQuery"in r&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return Wt(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var Nt=r.requestAnimationFrame||r.webkitRequestAnimationFrame,qt=r.cancelAnimationFrame||r.webkitCancelAnimationFrame;if(Nt&&!qt){var Lt={},Kt=Nt;Nt=function(e){var n=Kt(function(t){Lt[n]&&e(t)});return Lt[n]=!0,n},qt=function(t){delete Lt[t]}}else Nt&&qt||(Nt=function(t){return r.setTimeout(function(){t(r.performance&&r.performance.now&&r.performance.now()||(new Date).getTime())},16)},qt=r.clearTimeout);function Ut(t){return Qt(t,function(t){return Zt(t)})}function Qt(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function Vt(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function Bt(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function Gt(t,n){return Bt(t,function(t,e){return t===n[e]})}function Zt(t){return Math.round(t*Xt)/Xt}function Jt(t,e,n,i){var r=t,s=[n[0]?e[0]:i?e[0]-i[0]:e[0],n[1]?e[1]:i?e[1]+i[1]:e[1]];return r=Math.max(s[0],r),+Zt(r=Math.min(s[1],r))}function $t(t,e){return t<e[0]||t>e[1]}function te(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function ee(t,e,n,i){var r=t,s=e[0],o=e[1],a=o-s;return n[1]&&o<t&&(r=(r-o)%a+s),n[0]&&t<s&&(r=(r-s)%a+o),i?r:+Zt(r)}function ne(t,e,n){return Math.max(Math.min(t,n),e)}var ie=function(){function t(t){var e=t.options,n=t.itm,i=t.em,r=t.axm;this.options=e,this.itm=n,this.em=i,this.axm=r,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(s,t,e){var n,o=this;if(void 0!==e)n=e;else{var i=Qt(t,function(t,e){return n=Math.abs(t-s[e]),i=o.options.deceleration,(r=Math.sqrt(n/i*2))<100?0:r;var n,i,r});n=Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)}return ne(n,this.options.minimumDuration,this.options.maximumDuration)},e.createAnimationParam=function(t,e,n){var i=this.axm.get(),r=t,s=n&&n.event||null;return{depaPos:i,destPos:r,duration:ne(e,this.options.minimumDuration,this.options.maximumDuration),delta:this.axm.getDelta(i,r),inputEvent:s,input:n&&n.input||null,isTrusted:!!s,done:this.animationEnd}},e.grab=function(t,e){if(this._animateParam&&t.length){var n=this.axm.get(t),i=this.axm.map(n,function(t,e){return ee(t,e.range,e.circular,!1)});Bt(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(r=this._raf,qt(r)),this._raf=null,this.em.triggerAnimationEnd(!(!e||!e.event))}var r},e.getEventInfo=function(){return this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent?{input:this._animateParam.input,event:this._animateParam.inputEvent}:null},e.restore=function(t){var e=this.axm.get(),n=this.axm.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axm.filter(this.axm.get(),function(t,e){return te(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return ee(t,e.range,e.circular,!1)})),this.itm.setInterrupt(!1),this.em.triggerAnimationEnd(!!t),this.axm.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.itm.setInterrupt(!1),this.em.triggerFinish(t)},e.animateLoop=function(o,a){if(o.duration){this._animateParam=m({},o);var h=this._animateParam,u=this,c=h.depaPos,l=0,f=Qt(c,function(t,e){return t<=h.destPos[e]?1:-1}),p=(new Date).getTime();h.startTime=p,function t(){u._raf=null;var e=(new Date).getTime(),n=u.easing((e-h.startTime)/o.duration),i=Qt(c,function(t,e){return t+h.delta[e]*(n-l)});i=u.axm.map(i,function(t,e,n){var i=ee(t,e.range,e.circular,!0);return t!==i&&(o.destPos[n]+=-f[n]*(e.range[1]-e.range[0]),c[n]+=-f[n]*(e.range[1]-e.range[0])),i});var r=!u.em.triggerChange(i,!1,Ut(c));if(c=i,p=e,1<=(l=n)){var s=o.destPos;return Gt(s,u.axm.get(Object.keys(s)))||u.em.triggerChange(s,!0,Ut(c)),void a()}r?u.finish(!1):u._raf=Nt(t)}()}else this.em.triggerChange(o.destPos,!0),a()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=ne(e.duration,this.options.minimumDuration,this.options.maximumDuration),e},e.animateTo=function(t,e,n){var i=this,r=this.createAnimationParam(t,e,n),s=m({},r.depaPos),o=this.em.triggerAnimationStart(r),a=this.getUserControll(r);if(!o&&this.axm.every(a.destPos,function(t,e){return te(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!Gt(a.destPos,s)){var h=n&&n.event||null;this.animateLoop({depaPos:s,destPos:a.destPos,duration:a.duration,delta:this.axm.getDelta(s,a.destPos),isTrusted:!!h,inputEvent:h,input:n&&n.input||null},function(){return i.animationEnd()})}},e.easing=function(t){return 1<t?1:this.options.easing(t)},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t);this.grab(n);var i=this.axm.get(n);if(Gt(t,i))return this;this.itm.setInterrupt(!0);var r=Vt(t,function(t,e){return i[e]!==t});return Object.keys(r).length&&(Gt(r=this.axm.map(r,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:Jt(t,n,i)}),i)||(0<e?this.animateTo(r,e):(this.em.triggerChange(r),this.finish(!1)))),this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(Qt(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),re=function(){function t(t){this.axes=t}var e=t.prototype;return e.triggerHold=function(t,e){this.axes.trigger("hold",{pos:t,input:e.input||null,inputEvent:e.event||null,isTrusted:!0})},e.triggerRelease=function(t){t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("release",t)},e.triggerChange=function(t,e,n,i,r){void 0===r&&(r=!1);var s=this.am,o=s.axm,a=s.getEventInfo(),h=o.moveTo(t,e,n),u=i&&i.event||a&&a.event||null,c={pos:h.pos,delta:h.delta,holding:r,inputEvent:u,isTrusted:!!u,input:i&&i.input||a&&a.input||null,set:u?this.createUserControll(h.pos):function(){}},l=this.axes.trigger("change",c);return u&&o.set(c.set().destPos),l},e.triggerAnimationStart=function(t){return t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("animationStart",t)},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this.axes.trigger("animationEnd",{isTrusted:t})},e.triggerFinish=function(t){void 0===t&&(t=!1),this.axes.trigger("finish",{isTrusted:t})},e.createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:m({},t),duration:e};return function(t,e){return t&&(n.destPos=m({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},t}(),se=function(){function t(t){this.options=t,this._prevented=!1}var e=t.prototype;return e.isInterrupting=function(){return this.options.interruptable||this._prevented},e.isInterrupted=function(){return!this.options.interruptable&&this._prevented},e.setInterrupt=function(t){!this.options.interruptable&&(this._prevented=t)},t}(),oe=function(){function t(t,e){var n=this;this.axis=t,this.options=e,this._complementOptions(),this._pos=Object.keys(this.axis).reduce(function(t,e){return t[e]=n.axis[e].range[0],t},{})}var e=t.prototype;return e._complementOptions=function(){var r=this;Object.keys(this.axis).forEach(function(i){r.axis[i]=m({range:[0,100],bounce:[0,0],circular:[!1,!1]},r.axis[i]),["bounce","circular"].forEach(function(t){var e=r.axis,n=e[i][t];/string|number|boolean/.test(typeof n)&&(e[i][t]=[n,n])})})},e.getDelta=function(t,e){var n=this.get(t);return Qt(this.get(e),function(t,e){return t-n[e]})},e.get=function(t){var n=this;return t&&Array.isArray(t)?t.reduce(function(t,e){return e&&e in n._pos&&(t[e]=n._pos[e]),t},{}):m({},this._pos,t||{})},e.moveTo=function(n,i,r){void 0===r&&(r=this._pos);var t=Qt(this._pos,function(t,e){return e in n&&e in r?n[e]-r[e]:0});return this.set(this.map(n,function(t,e){return e?ee(t,e.range,e.circular,i):0})),{pos:m({},this._pos),delta:t}},e.set=function(t){for(var e in t)e&&e in this._pos&&(this._pos[e]=t[e])},e.every=function(t,n){var i=this.axis;return Bt(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return Vt(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return Qt(t,function(t,e){return n(t,i[e],e)})},e.isOutside=function(t){return!this.every(t?this.get(t):this._pos,function(t,e){return!$t(t,e.range)})},t}(),ae=function(){function t(t){var e=t.options,n=t.itm,i=t.em,r=t.axm,s=t.am;this.isOutside=!1,this.moveDistance=null,this.isStopped=!1,this.options=e,this.itm=n,this.em=i,this.axm=r,this.am=s}var e=t.prototype;return e.atOutside=function(t){var o=this;if(this.isOutside)return this.axm.map(t,function(t,e){var n=e.range[0]-e.bounce[0],i=e.range[1]+e.bounce[1];return i<t?i:t<n?n:t});var a=this.am.easing(1e-5)/1e-5;return this.axm.map(t,function(t,e){var n=e.range[0],i=e.range[1],r=e.bounce,s=e.circular;return s&&(s[0]||s[1])?t:t<n?n-o.am.easing((n-t)/(r[0]*a))*r[0]:i<t?i+o.am.easing((t-i)/(r[1]*a))*r[1]:t})},e.get=function(t){return this.axm.get(t.axes)},e.hold=function(t,e){if(!this.itm.isInterrupted()&&t.axes.length){var n={input:t,event:e};this.isStopped=!1,this.itm.setInterrupt(!0),this.am.grab(t.axes,n),!this.moveDistance&&this.em.triggerHold(this.axm.get(),n),this.isOutside=this.axm.isOutside(t.axes),this.moveDistance=this.axm.get(t.axes)}},e.change=function(t,e,n){if(!this.isStopped&&this.itm.isInterrupting()&&!this.axm.every(n,function(t){return 0===t})){var i,r=this.moveDistance||this.axm.get(t.axes);i=Qt(r,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(r,function(t,e){return!$t(t,e.range)})&&(this.isOutside=!1),r=this.atOutside(r),i=this.atOutside(i),!this.em.triggerChange(i,!1,r,{input:t,event:e},!0)&&(this.isStopped=!0,this.moveDistance=null,this.am.finish(!1))}},e.release=function(t,e,n,i){if(!this.isStopped&&this.itm.isInterrupting()&&this.moveDistance){var r=this.axm.get(t.axes),s=this.axm.get(),o=this.axm.get(this.axm.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?r[n]+t:Jt(r[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,r,i);0===a&&(o=m({},s));var h={depaPos:s,destPos:o,duration:a,delta:this.axm.getDelta(s,o),inputEvent:e,input:t,isTrusted:!0};this.em.triggerRelease(h),this.moveDistance=null;var u=this.am.getUserControll(h),c=Gt(u.destPos,s),l={input:t,event:e};c||0===u.duration?(!c&&this.em.triggerChange(u.destPos,!1,s,l,!0),this.itm.setInterrupt(!1),this.axm.isOutside()?this.am.restore(l):this.em.triggerFinish(!0)):this.am.animateTo(u.destPos,u.duration,l)}},t}(),he=function(r){function t(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i=r.call(this)||this;return i.axis=t,i._inputs=[],i.options=m({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4},e),i.itm=new se(i.options),i.axm=new oe(i.axis,i.options),i.em=new re(i),i.am=new ie(i),i.io=new ae(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}n(t,r);var e=t.prototype;return e.connect=function(t,e){var n;if(n="string"==typeof t?t.split(" "):t.concat(),~this._inputs.indexOf(e)&&this.disconnect(e),"hammer"in e){var i=this._inputs.filter(function(t){return t.hammer&&t.element===e.element});i.length&&(e.hammer=i[0].hammer)}return e.mapAxes(n),e.connect(this.io),this._inputs.push(e),this},e.disconnect=function(t){if(t){var e=this._inputs.indexOf(t);0<=e&&(this._inputs[e].disconnect(),this._inputs.splice(e,1))}else this._inputs.forEach(function(t){return t.disconnect()}),this._inputs=[];return this},e.get=function(t){return this.axm.get(t)},e.setTo=function(t,e){return void 0===e&&(e=0),this.am.setTo(t,e),this},e.setBy=function(t,e){return void 0===e&&(e=0),this.am.setBy(t,e),this},e.isBounceArea=function(t){return this.axm.isOutside(t)},e.destroy=function(){this.disconnect(),this.em.destroy()},t.VERSION="2.5.13",t.TRANSFORM=kt,t.DIRECTION_NONE=Y,t.DIRECTION_LEFT=F,t.DIRECTION_RIGHT=X,t.DIRECTION_UP=k,t.DIRECTION_DOWN=j,t.DIRECTION_HORIZONTAL=W,t.DIRECTION_VERTICAL=N,t.DIRECTION_ALL=q,t}(t),ue="PointerEvent"in r||"MSPointerEvent"in r,ce="ontouchstart"in r,le="_EGJS_AXES_INPUTTYPE_";function fe(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function pe(t,e){try{return new zt(t,m({},e))}catch(t){return null}}function me(t){void 0===t&&(t=[]);var e=!1,n=!1,i=!1;return t.forEach(function(t){switch(t){case"mouse":n=!0;break;case"touch":e=ce;break;case"pointer":i=ue}}),i?dt:e&&n?wt:e?bt:n?Et:null}function de(t,e,n){return n?!!(e===q||e&t&&n&t):!!(e&t)}var ve=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,void 0===zt)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=Wt(t),this.options=m({inputType:["touch","mouse","pointer"],scale:[1,1],thresholdAngle:45,threshold:0,hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onHammerInput=this.onHammerInput.bind(this),this.onPanmove=this.onPanmove.bind(this),this.onPanend=this.onPanend.bind(this)}var e=t.prototype;return e.mapAxes=function(t){var e=!!t[0],n=!!t[1];this._direction=e&&n?q:e?W:n?N:Y,this.axes=t},e.connect=function(t){var e={direction:this._direction,threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[le];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=me(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pe(this.element,m({inputClass:i},this.options.hammerManagerOptions)),this.element[le]=n}return this.panRecognizer=new Yt(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=Y,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[le],this.element=null,this.hammer=null},e.enable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pan").options.enable)},e.removeRecognizer=function(){this.hammer&&this.panRecognizer&&(this.hammer.remove(this.panRecognizer),this.panRecognizer=null)},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?this.observer.hold(this,t):t.isFinal&&this.onPanend(t))},e.onPanmove=function(t){var e=function(t,e){if(e<0||90<e)return Y;var n=Math.abs(t);return e<n&&n<180-e?N:W}(t.angle,this.options.thresholdAngle),n=this.hammer.session.prevInput;t.offsetY=n?(t.offsetX=t.deltaX-n.deltaX,t.deltaY-n.deltaY):t.offsetX=0;var i=this.getOffset([t.offsetX,t.offsetY],[de(W,this._direction,e),de(N,this._direction,e)]),r=i.some(function(t){return 0!==t});r&&(t.srcEvent.preventDefault(),t.srcEvent.stopPropagation()),(t.preventSystemEvent=r)&&this.observer.change(this,t,fe(this.axes,i))},e.onPanend=function(t){var e,n,i,r,s=this.getOffset([Math.abs(t.velocityX)*(t.deltaX<0?-1:1),Math.abs(t.velocityY)*(t.deltaY<0?-1:1)],[de(W,this._direction),de(N,this._direction)]);e=s,n=this.observer.options.deceleration,i=Math.sqrt(e[0]*e[0]+e[1]*e[1]),r=Math.abs(i/-n),s=[e[0]/2*r,e[1]/2*r],this.observer.release(this,t,fe(this.axes,s))},e.attachEvent=function(t){this.observer=t,this.hammer.on("hammer.input",this.onHammerInput).on("panstart panmove",this.onPanmove)},e.dettachEvent=function(){this.hammer.off("hammer.input",this.onHammerInput).off("panstart panmove",this.onPanmove),this.observer=null},e.getOffset=function(t,e){var n=[0,0],i=this.options.scale;return e[0]&&(n[0]=t[0]*i[0]),e[1]&&(n[1]=t[1]*i[1]),n},t}(),ge=function(i){function t(t,e){var n=i.call(this,t,e)||this;return n.prevQuadrant=null,n.lastDiff=0,n}n(t,i);var e=t.prototype;return e.mapAxes=function(t){this._direction=he.DIRECTION_ALL,this.axes=t},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?(this.observer.hold(this,t),this.onPanstart(t)):t.isFinal&&this.onPanend(t))},e.onPanstart=function(t){var e=this.element.getBoundingClientRect();this.coefficientForDistanceToAngle=360/(e.width*Math.PI),this.rotateOrigin=[e.left+(e.width-1)/2,e.top+(e.height-1)/2],this.prevAngle=null,this.triggerChange(t)},e.onPanmove=function(t){this.triggerChange(t)},e.onPanend=function(t){this.triggerChange(t),this.triggerAnimation(t)},e.triggerChange=function(t){var e=this.getAngle(t.center.x,t.center.y),n=this.getQuadrant(t.center.x,t.center.y),i=this.getDifference(this.prevAngle,e,this.prevQuadrant,n);this.prevAngle=e,this.prevQuadrant=n,0!==i&&(this.lastDiff=i,this.observer.change(this,t,fe(this.axes,[-i])))},e.triggerAnimation=function(t){var e=t.velocityX,n=t.velocityY,i=Math.sqrt(e*e+n*n)*(0<this.lastDiff?-1:1),r=i/2*Math.abs(i/-this.observer.options.deceleration);this.observer.release(this,t,fe(this.axes,[r*this.coefficientForDistanceToAngle]))},e.getDifference=function(t,e,n,i){return null===t?0:1===n&&4===i?-t-(360-e):4===n&&1===i?360-t+e:e-t},e.getPosFromOrigin=function(t,e){return{x:t-this.rotateOrigin[0],y:this.rotateOrigin[1]-e}},e.getAngle=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,r=n.y,s=180*Math.atan2(r,i)/Math.PI;return s<0?360+s:s},e.getQuadrant=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,r=n.y,s=0;return 0<=i&&0<=r?s=1:i<0&&0<=r?s=2:i<0&&r<0?s=3:0<=i&&r<0&&(s=4),s},t}(ve),ye=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this._base=null,this._prev=null,this.pinchRecognizer=null,void 0===zt)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=Wt(t),this.options=m({scale:1,threshold:0,inputType:["touch","pointer"],hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onPinchStart=this.onPinchStart.bind(this),this.onPinchMove=this.onPinchMove.bind(this),this.onPinchEnd=this.onPinchEnd.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){var e={threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[le];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=me(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pe(this.element,m({inputClass:i},this.options.hammerManagerOptions)),this.element[le]=n}return this.pinchRecognizer=new Ft(e),this.hammer.add(this.pinchRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null,this.dettachEvent()),this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[le],this.element=null,this.hammer=null},e.removeRecognizer=function(){this.hammer&&this.pinchRecognizer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null)},e.onPinchStart=function(t){this._base=this.observer.get(this)[this.axes[0]];var e=this.getOffset(t.scale);this.observer.hold(this,t),this.observer.change(this,t,fe(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,fe(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,fe(this.axes,[e])),this.observer.release(this,t,fe(this.axes,[0]),0),this._base=null,this._prev=null},e.getOffset=function(t,e){return void 0===e&&(e=1),this._base*(t-e)*this.options.scale},e.attachEvent=function(t){this.observer=t,this.hammer.on("pinchstart",this.onPinchStart).on("pinchmove",this.onPinchMove).on("pinchend",this.onPinchEnd)},e.dettachEvent=function(){this.hammer.off("pinchstart",this.onPinchStart).off("pinchmove",this.onPinchMove).off("pinchend",this.onPinchEnd),this.observer=null,this._prev=null},e.enable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pinch").options.enable)},t}(),be=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Wt(t),this.options=m({scale:1,useNormalized:!0},e),this.onWheel=this.onWheel.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onWheel=function(t){var e=this;if(this._isEnabled&&(t.preventDefault(),0!==t.deltaY)){this._isHolded||(this.observer.hold(this,t),this._isHolded=!0);var n=(0<t.deltaY?-1:1)*this.options.scale*(this.options.useNormalized?1:Math.abs(t.deltaY));this.observer.change(this,t,fe(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,fe(e.axes,[0])))},50)}},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("wheel",this.onWheel),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("wheel",this.onWheel),this._isEnabled=!1,this.observer=null,this._timer&&(clearTimeout(this._timer),this._timer=null)},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),xe=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Wt(t),this.options=m({scale:[1,1]},e),this.onKeydown=this.onKeydown.bind(this),this.onKeyup=this.onKeyup.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),"0"!==this.element.getAttribute("tabindex")&&this.element.setAttribute("tabindex","0"),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onKeydown=function(t){if(this._isEnabled){var e=!0,n=1,i=-1;switch(t.keyCode){case 37:case 65:n=-1;break;case 39:case 68:break;case 40:case 83:n=-1,i=1;break;case 38:case 87:i=1;break;default:e=!1}if((-1===i&&!this.axes[0]||1===i&&!this.axes[1])&&(e=!1),e){var r=-1===i?[+this.options.scale[0]*n,0]:[0,+this.options.scale[1]*n];this._isHolded||(this.observer.hold(this,event),this._isHolded=!0),clearTimeout(this._timer),this.observer.change(this,event,fe(this.axes,r))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,fe(e.axes,[0,0])),e._isHolded=!1},80))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("keydown",this.onKeydown,!1),this.element.addEventListener("keypress",this.onKeydown,!1),this.element.addEventListener("keyup",this.onKeyup,!1),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("keydown",this.onKeydown,!1),this.element.removeEventListener("keypress",this.onKeydown,!1),this.element.removeEventListener("keyup",this.onKeyup,!1),this._isEnabled=!1,this.observer=null},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}();return he.PanInput=ve,he.RotatePanInput=ge,he.PinchInput=ye,he.WheelInput=be,he.MoveKeyInput=xe,he}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t.eg=t.eg||{},t.eg.Axes=e())}(this,function(){"use strict";var i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};function n(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var d=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t};function a(t){return void 0===t}var r,t=function(){var t=function(){function t(){this._eventHandler={},this.options={}}var e=t.prototype;return e.trigger=function(t,e){void 0===e&&(e={});var n=this._eventHandler[t]||[];if(!(0<n.length))return!0;n=n.concat(),e.eventType=t;var i=!1,r=[e],s=0;e.stop=function(){i=!0},e.currentTarget=this;for(var o=arguments.length,a=new Array(2<o?o-2:0),h=2;h<o;h++)a[h-2]=arguments[h];for(1<=a.length&&(r=r.concat(a)),s=0;n[s];s++)n[s].apply(this,r);return!i},e.once=function(r,s){if("object"==typeof r&&a(s)){var t,e=r;for(t in e)this.once(t,e[t]);return this}if("string"==typeof r&&"function"==typeof s){var o=this;this.on(r,function t(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];s.apply(o,n),o.off(r,t)})}return this},e.hasOn=function(t){return!!this._eventHandler[t]},e.on=function(t,e){if("object"==typeof t&&a(e)){var n,i=t;for(n in i)this.on(n,i[n]);return this}if("string"==typeof t&&"function"==typeof e){var r=this._eventHandler[t];a(r)&&(this._eventHandler[t]=[],r=this._eventHandler[t]),r.push(e)}return this},e.off=function(t,e){if(a(t))return this._eventHandler={},this;if(a(e)){if("string"==typeof t)return this._eventHandler[t]=void 0,this;var n,i=t;for(n in i)this.off(n,i[n]);return this}var r,s,o=this._eventHandler[t];if(o)for(r=0;void 0!==(s=o[r]);r++)if(s===e){o=o.splice(r,1);break}return this},t}();return t.VERSION="2.1.2",t}();function s(){return(s=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}function o(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}r="undefined"==typeof window?{}:window;var u,c="function"!=typeof Object.assign?function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var e=Object(t),n=1;n<arguments.length;n++){var i=arguments[n];if(null!=i)for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}return e}:Object.assign,l=["","webkit","Moz","MS","ms","o"],e="undefined"==typeof document?{style:{}}:document.createElement("div"),f="function",p=Math.round,E=Math.abs,_=Date.now;function m(t,e){for(var n,i,r=e[0].toUpperCase()+e.slice(1),s=0;s<l.length;){if((i=(n=l[s])?n+r:e)in t)return i;s++}}u="undefined"==typeof window?{}:window;var v=m(e.style,"touchAction"),g=void 0!==v;var y="compute",b="auto",x="manipulation",T="none",P="pan-x",w="pan-y",O=function(){if(!g)return!1;var e={},n=u.CSS&&u.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(t){return e[t]=!n||u.CSS.supports("touch-action",t)}),e}(),A="ontouchstart"in u,I=void 0!==m(u,"PointerEvent"),D=A&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),M="touch",C="mouse",R=25,z=1,S=4,H=8,Y=1,F=2,X=4,k=8,j=16,W=F|X,N=k|j,q=W|N,L=["x","y"],K=["clientX","clientY"];function U(t,e,n){var i;if(t)if(t.forEach)t.forEach(e,n);else if(void 0!==t.length)for(i=0;i<t.length;)e.call(n,t[i],i,t),i++;else for(i in t)t.hasOwnProperty(i)&&e.call(n,t[i],i,t)}function Q(t,e){return typeof t===f?t.apply(e&&e[0]||void 0,e):t}function V(t,e){return-1<t.indexOf(e)}var B=function(){function t(t,e){this.manager=t,this.set(e)}var e=t.prototype;return e.set=function(t){t===y&&(t=this.compute()),g&&this.manager.element.style&&O[t]&&(this.manager.element.style[v]=t),this.actions=t.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var e=[];return U(this.manager.recognizers,function(t){Q(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),function(t){if(V(t,T))return T;var e=V(t,P),n=V(t,w);return e&&n?T:e||n?e?P:w:V(t,x)?x:b}(e.join(" "))},e.preventDefaults=function(t){var e=t.srcEvent,n=t.offsetDirection;if(this.manager.session.prevented)e.preventDefault();else{var i=this.actions,r=V(i,T)&&!O[T],s=V(i,w)&&!O[w],o=V(i,P)&&!O[P];if(r){var a=1===t.pointers.length,h=t.distance<2,u=t.deltaTime<250;if(a&&h&&u)return}if(!o||!s)return r||s&&n&W||o&&n&N?this.preventSrc(e):void 0}},e.preventSrc=function(t){this.manager.session.prevented=!0,t.preventDefault()},t}();function G(t,e){for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function Z(t){var e=t.length;if(1===e)return{x:p(t[0].clientX),y:p(t[0].clientY)};for(var n=0,i=0,r=0;r<e;)n+=t[r].clientX,i+=t[r].clientY,r++;return{x:p(n/e),y:p(i/e)}}function J(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:p(t.pointers[n].clientX),clientY:p(t.pointers[n].clientY)},n++;return{timeStamp:_(),pointers:e,center:Z(e),deltaX:t.deltaX,deltaY:t.deltaY}}function $(t,e,n){n||(n=L);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return Math.sqrt(i*i+r*r)}function tt(t,e,n){n||(n=L);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return 180*Math.atan2(r,i)/Math.PI}function et(t,e){return t===e?Y:E(t)>=E(e)?t<0?F:X:e<0?k:j}function nt(t,e,n){return{x:e/t||0,y:n/t||0}}function it(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=J(e)),1<r&&!n.firstMultiple?n.firstMultiple=J(e):1===r&&(n.firstMultiple=!1);var s,o,a,h,u,c,l=n.firstInput,f=n.firstMultiple,p=f?f.center:l.center,m=e.center=Z(i);e.timeStamp=_(),e.deltaTime=e.timeStamp-l.timeStamp,e.angle=tt(p,m),e.distance=$(p,m),s=n,a=(o=e).center,h=s.offsetDelta||{},u=s.prevDelta||{},c=s.prevInput||{},o.eventType!==z&&c.eventType!==S||(u=s.prevDelta={x:c.deltaX||0,y:c.deltaY||0},h=s.offsetDelta={x:a.x,y:a.y}),o.deltaX=u.x+(a.x-h.x),o.deltaY=u.y+(a.y-h.y),e.offsetDirection=et(e.deltaX,e.deltaY);var d,v,g,y,b=nt(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=b.x,e.overallVelocityY=b.y,e.overallVelocity=E(b.x)>E(b.y)?b.x:b.y,e.scale=f?(d=f.pointers,$((v=i)[0],v[1],K)/$(d[0],d[1],K)):1,e.rotation=f?(g=f.pointers,tt((y=i)[1],y[0],K)+tt(g[1],g[0],K)):0,e.maxPointers=n.prevInput?e.pointers.length>n.prevInput.maxPointers?e.pointers.length:n.prevInput.maxPointers:e.pointers.length,function(t,e){var n,i,r,s,o=t.lastInterval||e,a=e.timeStamp-o.timeStamp;if(e.eventType!==H&&(R<a||void 0===o.velocity)){var h=e.deltaX-o.deltaX,u=e.deltaY-o.deltaY,c=nt(a,h,u);i=c.x,r=c.y,n=E(c.x)>E(c.y)?c.x:c.y,s=et(h,u),t.lastInterval=e}else n=o.velocity,i=o.velocityX,r=o.velocityY,s=o.direction;e.velocity=n,e.velocityX=i,e.velocityY=r,e.direction=s}(n,e);var x=t.element;G(e.srcEvent.target,x)&&(x=e.srcEvent.target),e.target=x}function rt(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=e&z&&i-r==0,o=e&(S|H)&&i-r==0;n.isFirst=!!s,n.isFinal=!!o,s&&(t.session={}),n.eventType=e,it(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function st(t){return t.trim().split(/\s+/g)}function ot(e,t,n){U(st(t),function(t){e.addEventListener(t,n,!1)})}function at(e,t,n){U(st(t),function(t){e.removeEventListener(t,n,!1)})}function ht(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow||window}var ut=function(){function t(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){Q(e.options.enable,[e])&&n.handler(t)},this.init()}var e=t.prototype;return e.handler=function(){},e.init=function(){this.evEl&&ot(this.element,this.evEl,this.domHandler),this.evTarget&&ot(this.target,this.evTarget,this.domHandler),this.evWin&&ot(ht(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&at(this.element,this.evEl,this.domHandler),this.evTarget&&at(this.target,this.evTarget,this.domHandler),this.evWin&&at(ht(this.element),this.evWin,this.domHandler)},t}();function ct(t,e,n){if(t.indexOf&&!n)return t.indexOf(e);for(var i=0;i<t.length;){if(n&&t[i][n]==e||!n&&t[i]===e)return i;i++}return-1}var lt={pointerdown:z,pointermove:2,pointerup:S,pointercancel:H,pointerout:H},ft={2:M,3:"pen",4:C,5:"kinect"},pt="pointerdown",mt="pointermove pointerup pointercancel";u.MSPointerEvent&&!u.PointerEvent&&(pt="MSPointerDown",mt="MSPointerMove MSPointerUp MSPointerCancel");var dt=function(n){function i(){var t,e=i.prototype;return e.evEl=pt,e.evWin=mt,(t=n.apply(this,arguments)||this).store=t.manager.session.pointerEvents=[],t}return o(i,n),i.prototype.handler=function(t){var e=this.store,n=!1,i=t.type.toLowerCase().replace("ms",""),r=lt[i],s=ft[t.pointerType]||t.pointerType,o=s===M,a=ct(e,t.pointerId,"pointerId");r&z&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):r&(S|H)&&(n=!0),a<0||(e[a]=t,this.callback(this.manager,r,{pointers:e,changedPointers:[t],pointerType:s,srcEvent:t}),n&&e.splice(a,1))},i}(ut);function vt(t){return Array.prototype.slice.call(t,0)}function gt(t,n,e){for(var i=[],r=[],s=0;s<t.length;){var o=n?t[s][n]:t[s];ct(r,o)<0&&i.push(t[s]),r[s]=o,s++}return e&&(i=n?i.sort(function(t,e){return t[n]>e[n]}):i.sort()),i}var yt={touchstart:z,touchmove:2,touchend:S,touchcancel:H},bt=function(e){function n(){var t;return n.prototype.evTarget="touchstart touchmove touchend touchcancel",(t=e.apply(this,arguments)||this).targetIds={},t}return o(n,e),n.prototype.handler=function(t){var e=yt[t.type],n=function(t,e){var n,i,r=vt(t.touches),s=this.targetIds;if(e&(2|z)&&1===r.length)return s[r[0].identifier]=!0,[r,r];var o=vt(t.changedTouches),a=[],h=this.target;if(i=r.filter(function(t){return G(t.target,h)}),e===z)for(n=0;n<i.length;)s[i[n].identifier]=!0,n++;n=0;for(;n<o.length;)s[o[n].identifier]&&a.push(o[n]),e&(S|H)&&delete s[o[n].identifier],n++;return a.length?[gt(i.concat(a),"identifier",!0),a]:void 0}.call(this,t,e);n&&this.callback(this.manager,e,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:t})},n}(ut);var xt={mousedown:z,mousemove:2,mouseup:S},Et=function(n){function i(){var t,e=i.prototype;return e.evEl="mousedown",e.evWin="mousemove mouseup",(t=n.apply(this,arguments)||this).pressed=!1,t}return o(i,n),i.prototype.handler=function(t){var e=xt[t.type];e&z&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=S),this.pressed&&(e&S&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:C,srcEvent:t}))},i}(ut),_t=2500,Tt=25;function Pt(t){var e=t.changedPointers[0];if(e.identifier===this.primaryTouch){var n={x:e.clientX,y:e.clientY},i=this.lastTouches;this.lastTouches.push(n);setTimeout(function(){var t=i.indexOf(n);-1<t&&i.splice(t,1)},_t)}}var wt=function(){return function(n){function t(t,e){var s;return(s=n.call(this,t,e)||this).handler=function(t,e,n){var i=n.pointerType===M,r=n.pointerType===C;if(!(r&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)(function(t,e){t&z?(this.primaryTouch=e.changedPointers[0].identifier,Pt.call(this,e)):t&(S|H)&&Pt.call(this,e)}).call(h(h(s)),e,n);else if(r&&function(t){for(var e=t.srcEvent.clientX,n=t.srcEvent.clientY,i=0;i<this.lastTouches.length;i++){var r=this.lastTouches[i],s=Math.abs(e-r.x),o=Math.abs(n-r.y);if(s<=Tt&&o<=Tt)return!0}return!1}.call(h(h(s)),n))return;s.callback(t,e,n)}},s.touch=new bt(s.manager,s.handler),s.mouse=new Et(s.manager,s.handler),s.primaryTouch=null,s.lastTouches=[],s}return o(t,n),t.prototype.destroy=function(){this.touch.destroy(),this.mouse.destroy()},t}(ut)}();function Ot(t,e,n){return!!Array.isArray(t)&&(U(t,n[e],n),!0)}var At=1;function It(t,e){var n=e.manager;return n?n.get(t):t}function Dt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}var Mt=function(){function t(t){void 0===t&&(t={}),this.options=s({enable:!0},t),this.id=At++,this.manager=null,this.state=1,this.simultaneous={},this.requireFail=[]}var e=t.prototype;return e.set=function(t){return c(this.options,t),this.manager&&this.manager.touchAction.update(),this},e.recognizeWith=function(t){if(Ot(t,"recognizeWith",this))return this;var e=this.simultaneous;return e[(t=It(t,this)).id]||(e[t.id]=t).recognizeWith(this),this},e.dropRecognizeWith=function(t){return Ot(t,"dropRecognizeWith",this)||(t=It(t,this),delete this.simultaneous[t.id]),this},e.requireFailure=function(t){if(Ot(t,"requireFailure",this))return this;var e=this.requireFail;return-1===ct(e,t=It(t,this))&&(e.push(t),t.requireFailure(this)),this},e.dropRequireFailure=function(t){if(Ot(t,"dropRequireFailure",this))return this;t=It(t,this);var e=ct(this.requireFail,t);return-1<e&&this.requireFail.splice(e,1),this},e.hasRequireFailures=function(){return 0<this.requireFail.length},e.canRecognizeWith=function(t){return!!this.simultaneous[t.id]},e.emit=function(e){var n=this,t=this.state;function i(t){n.manager.emit(t,e)}t<8&&i(n.options.event+Dt(t)),i(n.options.event),e.additionalEvent&&i(e.additionalEvent),8<=t&&i(n.options.event+Dt(t))},e.tryEmit=function(t){if(this.canEmit())return this.emit(t);this.state=32},e.canEmit=function(){for(var t=0;t<this.requireFail.length;){if(!(33&this.requireFail[t].state))return!1;t++}return!0},e.recognize=function(t){var e=c({},t);if(!Q(this.options.enable,[this,e]))return this.reset(),void(this.state=32);56&this.state&&(this.state=1),this.state=this.process(e),30&this.state&&this.tryEmit(e)},e.process=function(t){},e.getTouchAction=function(){},e.reset=function(){},t}(),Ct={domEvents:!1,touchAction:y,enable:!0,inputTarget:null,inputClass:null,preset:[],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};function Rt(n,i){var r,s=n.element;s.style&&(U(n.options.cssProps,function(t,e){r=m(s.style,e),s.style[r]=i?(n.oldCssProps[r]=s.style[r],t):n.oldCssProps[r]||""}),i||(n.oldCssProps={}))}var zt=function(){function t(t,e){var n,i=this;this.options=c({},Ct,e||{}),this.options.inputTarget=this.options.inputTarget||t,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=t,this.input=new((n=this).options.inputClass||(I?dt:D?bt:A?wt:Et))(n,rt),this.touchAction=new B(this,this.options.touchAction),Rt(this,!0),U(this.options.recognizers,function(t){var e=i.add(new t[0](t[1]));t[2]&&e.recognizeWith(t[2]),t[3]&&e.requireFailure(t[3])},this)}var e=t.prototype;return e.set=function(t){return c(this.options,t),t.touchAction&&this.touchAction.update(),t.inputTarget&&(this.input.destroy(),this.input.target=t.inputTarget,this.input.init()),this},e.stop=function(t){this.session.stopped=t?2:1},e.recognize=function(t){var e=this.session;if(!e.stopped){var n;this.touchAction.preventDefaults(t);var i=this.recognizers,r=e.curRecognizer;(!r||r&&8&r.state)&&(r=e.curRecognizer=null);for(var s=0;s<i.length;)n=i[s],2===e.stopped||r&&n!==r&&!n.canRecognizeWith(r)?n.reset():n.recognize(t),!r&&14&n.state&&(r=e.curRecognizer=n),s++}},e.get=function(t){if(t instanceof Mt)return t;for(var e=this.recognizers,n=0;n<e.length;n++)if(e[n].options.event===t)return e[n];return null},e.add=function(t){if(Ot(t,"add",this))return this;var e=this.get(t.options.event);return e&&this.remove(e),this.recognizers.push(t),(t.manager=this).touchAction.update(),t},e.remove=function(t){if(Ot(t,"remove",this))return this;var e=this.get(t);if(t){var n=this.recognizers,i=ct(n,e);-1!==i&&(n.splice(i,1),this.touchAction.update())}return this},e.on=function(t,e){if(void 0===t||void 0===e)return this;var n=this.handlers;return U(st(t),function(t){n[t]=n[t]||[],n[t].push(e)}),this},e.off=function(t,e){if(void 0===t)return this;var n=this.handlers;return U(st(t),function(t){e?n[t]&&n[t].splice(ct(n[t],e),1):delete n[t]}),this},e.emit=function(t,e){var n,i,r;this.options.domEvents&&(n=t,i=e,(r=document.createEvent("Event")).initEvent(n,!0,!0),(r.gesture=i).target.dispatchEvent(r));var s=this.handlers[t]&&this.handlers[t].slice();if(s&&s.length){e.type=t,e.preventDefault=function(){e.srcEvent.preventDefault()};for(var o=0;o<s.length;)s[o](e),o++}},e.destroy=function(){this.element&&Rt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null},t}();var St=function(e){function t(t){return void 0===t&&(t={}),e.call(this,s({pointers:1},t))||this}o(t,e);var n=t.prototype;return n.attrTest=function(t){var e=this.options.pointers;return 0===e||t.pointers.length===e},n.process=function(t){var e=this.state,n=t.eventType,i=6&e,r=this.attrTest(t);return i&&(n&H||!r)?16|e:i||r?n&S?8|e:2&e?4|e:2:32},t}(Mt);function Ht(t){return t===j?"down":t===k?"up":t===F?"left":t===X?"right":""}var Yt=function(n){function t(t){var e;return void 0===t&&(t={}),(e=n.call(this,s({event:"pan",threshold:10,pointers:1,direction:q},t))||this).pX=null,e.pY=null,e}o(t,n);var e=t.prototype;return e.getTouchAction=function(){var t=this.options.direction,e=[];return t&W&&e.push(w),t&N&&e.push(P),e},e.directionTest=function(t){var e=this.options,n=!0,i=t.distance,r=t.direction,s=t.deltaX,o=t.deltaY;return r&e.direction||(i=e.direction&W?(r=0===s?Y:s<0?F:X,n=s!==this.pX,Math.abs(t.deltaX)):(r=0===o?Y:o<0?k:j,n=o!==this.pY,Math.abs(t.deltaY))),t.direction=r,n&&i>e.threshold&&r&e.direction},e.attrTest=function(t){return St.prototype.attrTest.call(this,t)&&(2&this.state||!(2&this.state)&&this.directionTest(t))},e.emit=function(t){this.pX=t.deltaX,this.pY=t.deltaY;var e=Ht(t.direction);e&&(t.additionalEvent=this.options.event+e),n.prototype.emit.call(this,t)},t}(St),Ft=function(n){function t(t){return void 0===t&&(t={}),n.call(this,s({event:"pinch",threshold:0,pointers:2},t))||this}o(t,n);var e=t.prototype;return e.getTouchAction=function(){return[T]},e.attrTest=function(t){return n.prototype.attrTest.call(this,t)&&(Math.abs(t.scale-1)>this.options.threshold||2&this.state)},e.emit=function(t){if(1!==t.scale){var e=t.scale<1?"in":"out";t.additionalEvent=this.options.event+e}n.prototype.emit.call(this,t)},t}(St),Xt=1e5,kt=function(){if("undefined"==typeof document)return"";for(var t=(document.head||document.getElementsByTagName("head")[0]).style,e=["transform","webkitTransform","msTransform","mozTransform"],n=0,i=e.length;n<i;n++)if(e[n]in t)return e[n];return""}();function jt(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function Wt(t,e){var n;if(void 0===e&&(e=!1),"string"==typeof t){if(t.match(/^<([a-z]+)\s*([^>]*)>/)){var i=document.createElement("div");i.innerHTML=t,n=jt(i.childNodes)}else n=jt(document.querySelectorAll(t));e||(n=1<=n.length?n[0]:void 0)}else t===r?n=t:!t.nodeName||1!==t.nodeType&&9!==t.nodeType?"jQuery"in r&&t instanceof jQuery||t.constructor.prototype.jquery?n=e?t.toArray():t.get(0):Array.isArray(t)&&(n=t.map(function(t){return Wt(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var Nt=r.requestAnimationFrame||r.webkitRequestAnimationFrame,qt=r.cancelAnimationFrame||r.webkitCancelAnimationFrame;if(Nt&&!qt){var Lt={},Kt=Nt;Nt=function(e){var n=Kt(function(t){Lt[n]&&e(t)});return Lt[n]=!0,n},qt=function(t){delete Lt[t]}}else Nt&&qt||(Nt=function(t){return r.setTimeout(function(){t(r.performance&&r.performance.now&&r.performance.now()||(new Date).getTime())},16)},qt=r.clearTimeout);function Ut(t){return Qt(t,function(t){return Zt(t)})}function Qt(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function Vt(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function Bt(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function Gt(t,n){return Bt(t,function(t,e){return t===n[e]})}function Zt(t){return Math.round(t*Xt)/Xt}function Jt(t,e,n,i){var r=t,s=[n[0]?e[0]:i?e[0]-i[0]:e[0],n[1]?e[1]:i?e[1]+i[1]:e[1]];return r=Math.max(s[0],r),+Zt(r=Math.min(s[1],r))}function $t(t,e){return t<e[0]||t>e[1]}function te(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function ee(t,e,n,i){var r=t,s=e[0],o=e[1],a=o-s;return n[1]&&o<t&&(r=(r-o)%a+s),n[0]&&t<s&&(r=(r-s)%a+o),i?r:+Zt(r)}function ne(t,e,n){return Math.max(Math.min(t,n),e)}var ie=function(){function t(t){var e=t.options,n=t.itm,i=t.em,r=t.axm;this.options=e,this.itm=n,this.em=i,this.axm=r,this.animationEnd=this.animationEnd.bind(this)}var e=t.prototype;return e.getDuration=function(s,t,e){var n,o=this;if(void 0!==e)n=e;else{var i=Qt(t,function(t,e){return n=Math.abs(t-s[e]),i=o.options.deceleration,(r=Math.sqrt(n/i*2))<100?0:r;var n,i,r});n=Object.keys(i).reduce(function(t,e){return Math.max(t,i[e])},-1/0)}return ne(n,this.options.minimumDuration,this.options.maximumDuration)},e.createAnimationParam=function(t,e,n){var i=this.axm.get(),r=t,s=n&&n.event||null;return{depaPos:i,destPos:r,duration:ne(e,this.options.minimumDuration,this.options.maximumDuration),delta:this.axm.getDelta(i,r),inputEvent:s,input:n&&n.input||null,isTrusted:!!s,done:this.animationEnd}},e.grab=function(t,e){if(this._animateParam&&t.length){var n=this.axm.get(t),i=this.axm.map(n,function(t,e){return ee(t,e.range,e.circular,!1)});Bt(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(r=this._raf,qt(r)),this._raf=null,this.em.triggerAnimationEnd(!(!e||!e.event))}var r},e.getEventInfo=function(){return this._animateParam&&this._animateParam.input&&this._animateParam.inputEvent?{input:this._animateParam.input,event:this._animateParam.inputEvent}:null},e.restore=function(t){var e=this.axm.get(),n=this.axm.map(e,function(t,e){return Math.min(e.range[1],Math.max(e.range[0],t))});this.animateTo(n,this.getDuration(e,n),t)},e.animationEnd=function(){var t=this.getEventInfo();this._animateParam=null;var e=this.axm.filter(this.axm.get(),function(t,e){return te(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return ee(t,e.range,e.circular,!1)})),this.itm.setInterrupt(!1),this.em.triggerAnimationEnd(!!t),this.axm.isOutside()?this.restore(t):this.finish(!!t)},e.finish=function(t){this._animateParam=null,this.itm.setInterrupt(!1),this.em.triggerFinish(t)},e.animateLoop=function(r,s){if(r.duration){this._animateParam=d({},r);var h=this._animateParam,u=this,c=h.destPos,l=h.depaPos,f=0,p=Qt(l,function(t,e){return t<=c[e]?1:-1}),m=(new Date).getTime();h.startTime=m,function t(){u._raf=null;var e=(new Date).getTime(),o=(e-h.startTime)/r.duration,a=u.easing(o),n=u.axm.map(l,function(t,e,n){var i=1<=o?c[n]:t+h.delta[n]*(a-f),r=ee(i,e.range,e.circular,!0);if(i!==r){var s=p[n]*(e.range[1]-e.range[0]);c[n]-=s,l[n]-=s}return r}),i=!u.em.triggerChange(n,!1,Ut(l));if(l=n,m=e,1<=(f=a))return Gt(c,u.axm.get(Object.keys(c)))||u.em.triggerChange(c,!0,Ut(l)),void s();i?u.finish(!1):u._raf=Nt(t)}()}else this.em.triggerChange(r.destPos,!0),s()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=ne(e.duration,this.options.minimumDuration,this.options.maximumDuration),e},e.animateTo=function(t,e,n){var i=this,r=this.createAnimationParam(t,e,n),s=d({},r.depaPos),o=this.em.triggerAnimationStart(r),a=this.getUserControll(r);if(!o&&this.axm.every(a.destPos,function(t,e){return te(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!Gt(a.destPos,s)){var h=n&&n.event||null;this.animateLoop({depaPos:s,destPos:a.destPos,duration:a.duration,delta:this.axm.getDelta(s,a.destPos),isTrusted:!!h,inputEvent:h,input:n&&n.input||null},function(){return i.animationEnd()})}},e.easing=function(t){return 1<t?1:this.options.easing(t)},e.setTo=function(t,e){void 0===e&&(e=0);var n=Object.keys(t);this.grab(n);var i=this.axm.get(n);if(Gt(t,i))return this;this.itm.setInterrupt(!0);var r=Vt(t,function(t,e){return i[e]!==t});return Object.keys(r).length&&(Gt(r=this.axm.map(r,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:Jt(t,n,i)}),i)||(0<e?this.animateTo(r,e):(this.em.triggerChange(r),this.finish(!1)))),this},e.setBy=function(n,t){return void 0===t&&(t=0),this.setTo(Qt(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),re=function(){function t(t){this.axes=t}var e=t.prototype;return e.triggerHold=function(t,e){this.axes.trigger("hold",{pos:t,input:e.input||null,inputEvent:e.event||null,isTrusted:!0})},e.triggerRelease=function(t){t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("release",t)},e.triggerChange=function(t,e,n,i,r){void 0===r&&(r=!1);var s=this.am,o=s.axm,a=s.getEventInfo(),h=o.moveTo(t,e,n),u=i&&i.event||a&&a.event||null,c={pos:h.pos,delta:h.delta,holding:r,inputEvent:u,isTrusted:!!u,input:i&&i.input||a&&a.input||null,set:u?this.createUserControll(h.pos):function(){}},l=this.axes.trigger("change",c);return u&&o.set(c.set().destPos),l},e.triggerAnimationStart=function(t){return t.setTo=this.createUserControll(t.destPos,t.duration),this.axes.trigger("animationStart",t)},e.triggerAnimationEnd=function(t){void 0===t&&(t=!1),this.axes.trigger("animationEnd",{isTrusted:t})},e.triggerFinish=function(t){void 0===t&&(t=!1),this.axes.trigger("finish",{isTrusted:t})},e.createUserControll=function(t,e){void 0===e&&(e=0);var n={destPos:d({},t),duration:e};return function(t,e){return t&&(n.destPos=d({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},t}(),se=function(){function t(t){this.options=t,this._prevented=!1}var e=t.prototype;return e.isInterrupting=function(){return this.options.interruptable||this._prevented},e.isInterrupted=function(){return!this.options.interruptable&&this._prevented},e.setInterrupt=function(t){!this.options.interruptable&&(this._prevented=t)},t}(),oe=function(){function t(t,e){var n=this;this.axis=t,this.options=e,this._complementOptions(),this._pos=Object.keys(this.axis).reduce(function(t,e){return t[e]=n.axis[e].range[0],t},{})}var e=t.prototype;return e._complementOptions=function(){var r=this;Object.keys(this.axis).forEach(function(i){r.axis[i]=d({range:[0,100],bounce:[0,0],circular:[!1,!1]},r.axis[i]),["bounce","circular"].forEach(function(t){var e=r.axis,n=e[i][t];/string|number|boolean/.test(typeof n)&&(e[i][t]=[n,n])})})},e.getDelta=function(t,e){var n=this.get(t);return Qt(this.get(e),function(t,e){return t-n[e]})},e.get=function(t){var n=this;return t&&Array.isArray(t)?t.reduce(function(t,e){return e&&e in n._pos&&(t[e]=n._pos[e]),t},{}):d({},this._pos,t||{})},e.moveTo=function(n,i,r){void 0===r&&(r=this._pos);var t=Qt(this._pos,function(t,e){return e in n&&e in r?n[e]-r[e]:0});return this.set(this.map(n,function(t,e){return e?ee(t,e.range,e.circular,i):0})),{pos:d({},this._pos),delta:t}},e.set=function(t){for(var e in t)e&&e in this._pos&&(this._pos[e]=t[e])},e.every=function(t,n){var i=this.axis;return Bt(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return Vt(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return Qt(t,function(t,e){return n(t,i[e],e)})},e.isOutside=function(t){return!this.every(t?this.get(t):this._pos,function(t,e){return!$t(t,e.range)})},t}(),ae=function(){function t(t){var e=t.options,n=t.itm,i=t.em,r=t.axm,s=t.am;this.isOutside=!1,this.moveDistance=null,this.isStopped=!1,this.options=e,this.itm=n,this.em=i,this.axm=r,this.am=s}var e=t.prototype;return e.atOutside=function(t){var o=this;if(this.isOutside)return this.axm.map(t,function(t,e){var n=e.range[0]-e.bounce[0],i=e.range[1]+e.bounce[1];return i<t?i:t<n?n:t});var a=this.am.easing(1e-5)/1e-5;return this.axm.map(t,function(t,e){var n=e.range[0],i=e.range[1],r=e.bounce,s=e.circular;return s&&(s[0]||s[1])?t:t<n?n-o.am.easing((n-t)/(r[0]*a))*r[0]:i<t?i+o.am.easing((t-i)/(r[1]*a))*r[1]:t})},e.get=function(t){return this.axm.get(t.axes)},e.hold=function(t,e){if(!this.itm.isInterrupted()&&t.axes.length){var n={input:t,event:e};this.isStopped=!1,this.itm.setInterrupt(!0),this.am.grab(t.axes,n),!this.moveDistance&&this.em.triggerHold(this.axm.get(),n),this.isOutside=this.axm.isOutside(t.axes),this.moveDistance=this.axm.get(t.axes)}},e.change=function(t,e,n){if(!this.isStopped&&this.itm.isInterrupting()&&!this.axm.every(n,function(t){return 0===t})){var i,r=this.moveDistance||this.axm.get(t.axes);i=Qt(r,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(r,function(t,e){return!$t(t,e.range)})&&(this.isOutside=!1),r=this.atOutside(r),i=this.atOutside(i),!this.em.triggerChange(i,!1,r,{input:t,event:e},!0)&&(this.isStopped=!0,this.moveDistance=null,this.am.finish(!1))}},e.release=function(t,e,n,i){if(!this.isStopped&&this.itm.isInterrupting()&&this.moveDistance){var r=this.axm.get(t.axes),s=this.axm.get(),o=this.axm.get(this.axm.map(n,function(t,e,n){return e.circular&&(e.circular[0]||e.circular[1])?r[n]+t:Jt(r[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,r,i);0===a&&(o=d({},s));var h={depaPos:s,destPos:o,duration:a,delta:this.axm.getDelta(s,o),inputEvent:e,input:t,isTrusted:!0};this.em.triggerRelease(h),this.moveDistance=null;var u=this.am.getUserControll(h),c=Gt(u.destPos,s),l={input:t,event:e};c||0===u.duration?(!c&&this.em.triggerChange(u.destPos,!1,s,l,!0),this.itm.setInterrupt(!1),this.axm.isOutside()?this.am.restore(l):this.em.triggerFinish(!0)):this.am.animateTo(u.destPos,u.duration,l)}},t}(),he=function(r){function t(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i=r.call(this)||this;return i.axis=t,i._inputs=[],i.options=d({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4},e),i.itm=new se(i.options),i.axm=new oe(i.axis,i.options),i.em=new re(i),i.am=new ie(i),i.io=new ae(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}n(t,r);var e=t.prototype;return e.connect=function(t,e){var n;if(n="string"==typeof t?t.split(" "):t.concat(),~this._inputs.indexOf(e)&&this.disconnect(e),"hammer"in e){var i=this._inputs.filter(function(t){return t.hammer&&t.element===e.element});i.length&&(e.hammer=i[0].hammer)}return e.mapAxes(n),e.connect(this.io),this._inputs.push(e),this},e.disconnect=function(t){if(t){var e=this._inputs.indexOf(t);0<=e&&(this._inputs[e].disconnect(),this._inputs.splice(e,1))}else this._inputs.forEach(function(t){return t.disconnect()}),this._inputs=[];return this},e.get=function(t){return this.axm.get(t)},e.setTo=function(t,e){return void 0===e&&(e=0),this.am.setTo(t,e),this},e.setBy=function(t,e){return void 0===e&&(e=0),this.am.setBy(t,e),this},e.isBounceArea=function(t){return this.axm.isOutside(t)},e.destroy=function(){this.disconnect(),this.em.destroy()},t.VERSION="2.5.14",t.TRANSFORM=kt,t.DIRECTION_NONE=Y,t.DIRECTION_LEFT=F,t.DIRECTION_RIGHT=X,t.DIRECTION_UP=k,t.DIRECTION_DOWN=j,t.DIRECTION_HORIZONTAL=W,t.DIRECTION_VERTICAL=N,t.DIRECTION_ALL=q,t}(t),ue="PointerEvent"in r||"MSPointerEvent"in r,ce="ontouchstart"in r,le="_EGJS_AXES_INPUTTYPE_";function fe(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function pe(t,e){try{return new zt(t,d({},e))}catch(t){return null}}function me(t){void 0===t&&(t=[]);var e=!1,n=!1,i=!1;return t.forEach(function(t){switch(t){case"mouse":n=!0;break;case"touch":e=ce;break;case"pointer":i=ue}}),i?dt:e&&n?wt:e?bt:n?Et:null}function de(t,e,n){return n?!!(e===q||e&t&&n&t):!!(e&t)}var ve=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,void 0===zt)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=Wt(t),this.options=d({inputType:["touch","mouse","pointer"],scale:[1,1],thresholdAngle:45,threshold:0,hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onHammerInput=this.onHammerInput.bind(this),this.onPanmove=this.onPanmove.bind(this),this.onPanend=this.onPanend.bind(this)}var e=t.prototype;return e.mapAxes=function(t){var e=!!t[0],n=!!t[1];this._direction=e&&n?q:e?W:n?N:Y,this.axes=t},e.connect=function(t){var e={direction:this._direction,threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[le];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=me(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pe(this.element,d({inputClass:i},this.options.hammerManagerOptions)),this.element[le]=n}return this.panRecognizer=new Yt(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=Y,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[le],this.element=null,this.hammer=null},e.enable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pan").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pan").options.enable)},e.removeRecognizer=function(){this.hammer&&this.panRecognizer&&(this.hammer.remove(this.panRecognizer),this.panRecognizer=null)},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?this.observer.hold(this,t):t.isFinal&&this.onPanend(t))},e.onPanmove=function(t){var e=function(t,e){if(e<0||90<e)return Y;var n=Math.abs(t);return e<n&&n<180-e?N:W}(t.angle,this.options.thresholdAngle),n=this.hammer.session.prevInput;t.offsetY=n?(t.offsetX=t.deltaX-n.deltaX,t.deltaY-n.deltaY):t.offsetX=0;var i=this.getOffset([t.offsetX,t.offsetY],[de(W,this._direction,e),de(N,this._direction,e)]),r=i.some(function(t){return 0!==t});r&&(t.srcEvent.preventDefault(),t.srcEvent.stopPropagation()),(t.preventSystemEvent=r)&&this.observer.change(this,t,fe(this.axes,i))},e.onPanend=function(t){var e,n,i,r,s=this.getOffset([Math.abs(t.velocityX)*(t.deltaX<0?-1:1),Math.abs(t.velocityY)*(t.deltaY<0?-1:1)],[de(W,this._direction),de(N,this._direction)]);e=s,n=this.observer.options.deceleration,i=Math.sqrt(e[0]*e[0]+e[1]*e[1]),r=Math.abs(i/-n),s=[e[0]/2*r,e[1]/2*r],this.observer.release(this,t,fe(this.axes,s))},e.attachEvent=function(t){this.observer=t,this.hammer.on("hammer.input",this.onHammerInput).on("panstart panmove",this.onPanmove)},e.dettachEvent=function(){this.hammer.off("hammer.input",this.onHammerInput).off("panstart panmove",this.onPanmove),this.observer=null},e.getOffset=function(t,e){var n=[0,0],i=this.options.scale;return e[0]&&(n[0]=t[0]*i[0]),e[1]&&(n[1]=t[1]*i[1]),n},t}(),ge=function(i){function t(t,e){var n=i.call(this,t,e)||this;return n.prevQuadrant=null,n.lastDiff=0,n}n(t,i);var e=t.prototype;return e.mapAxes=function(t){this._direction=he.DIRECTION_ALL,this.axes=t},e.onHammerInput=function(t){this.isEnable()&&(t.isFirst?(this.observer.hold(this,t),this.onPanstart(t)):t.isFinal&&this.onPanend(t))},e.onPanstart=function(t){var e=this.element.getBoundingClientRect();this.coefficientForDistanceToAngle=360/(e.width*Math.PI),this.rotateOrigin=[e.left+(e.width-1)/2,e.top+(e.height-1)/2],this.prevAngle=null,this.triggerChange(t)},e.onPanmove=function(t){this.triggerChange(t)},e.onPanend=function(t){this.triggerChange(t),this.triggerAnimation(t)},e.triggerChange=function(t){var e=this.getAngle(t.center.x,t.center.y),n=this.getQuadrant(t.center.x,t.center.y),i=this.getDifference(this.prevAngle,e,this.prevQuadrant,n);this.prevAngle=e,this.prevQuadrant=n,0!==i&&(this.lastDiff=i,this.observer.change(this,t,fe(this.axes,[-i])))},e.triggerAnimation=function(t){var e=t.velocityX,n=t.velocityY,i=Math.sqrt(e*e+n*n)*(0<this.lastDiff?-1:1),r=i/2*Math.abs(i/-this.observer.options.deceleration);this.observer.release(this,t,fe(this.axes,[r*this.coefficientForDistanceToAngle]))},e.getDifference=function(t,e,n,i){return null===t?0:1===n&&4===i?-t-(360-e):4===n&&1===i?360-t+e:e-t},e.getPosFromOrigin=function(t,e){return{x:t-this.rotateOrigin[0],y:this.rotateOrigin[1]-e}},e.getAngle=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,r=n.y,s=180*Math.atan2(r,i)/Math.PI;return s<0?360+s:s},e.getQuadrant=function(t,e){var n=this.getPosFromOrigin(t,e),i=n.x,r=n.y,s=0;return 0<=i&&0<=r?s=1:i<0&&0<=r?s=2:i<0&&r<0?s=3:0<=i&&r<0&&(s=4),s},t}(ve),ye=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this._base=null,this._prev=null,this.pinchRecognizer=null,void 0===zt)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=Wt(t),this.options=d({scale:1,threshold:0,inputType:["touch","pointer"],hammerManagerOptions:{cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",userDrag:"none"}}},e),this.onPinchStart=this.onPinchStart.bind(this),this.onPinchMove=this.onPinchMove.bind(this),this.onPinchEnd=this.onPinchEnd.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){var e={threshold:this.options.threshold};if(this.hammer)this.removeRecognizer(),this.dettachEvent();else{var n=this.element[le];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=me(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=pe(this.element,d({inputClass:i},this.options.hammerManagerOptions)),this.element[le]=n}return this.pinchRecognizer=new Ft(e),this.hammer.add(this.pinchRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null,this.dettachEvent()),this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[le],this.element=null,this.hammer=null},e.removeRecognizer=function(){this.hammer&&this.pinchRecognizer&&(this.hammer.remove(this.pinchRecognizer),this.pinchRecognizer=null)},e.onPinchStart=function(t){this._base=this.observer.get(this)[this.axes[0]];var e=this.getOffset(t.scale);this.observer.hold(this,t),this.observer.change(this,t,fe(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,fe(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,fe(this.axes,[e])),this.observer.release(this,t,fe(this.axes,[0]),0),this._base=null,this._prev=null},e.getOffset=function(t,e){return void 0===e&&(e=1),this._base*(t-e)*this.options.scale},e.attachEvent=function(t){this.observer=t,this.hammer.on("pinchstart",this.onPinchStart).on("pinchmove",this.onPinchMove).on("pinchend",this.onPinchEnd)},e.dettachEvent=function(){this.hammer.off("pinchstart",this.onPinchStart).off("pinchmove",this.onPinchMove).off("pinchend",this.onPinchEnd),this.observer=null,this._prev=null},e.enable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!0),this},e.disable=function(){return this.hammer&&(this.hammer.get("pinch").options.enable=!1),this},e.isEnable=function(){return!(!this.hammer||!this.hammer.get("pinch").options.enable)},t}(),be=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Wt(t),this.options=d({scale:1,useNormalized:!0},e),this.onWheel=this.onWheel.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onWheel=function(t){var e=this;if(this._isEnabled&&(t.preventDefault(),0!==t.deltaY)){this._isHolded||(this.observer.hold(this,t),this._isHolded=!0);var n=(0<t.deltaY?-1:1)*this.options.scale*(this.options.useNormalized?1:Math.abs(t.deltaY));this.observer.change(this,t,fe(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,fe(e.axes,[0])))},50)}},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("wheel",this.onWheel),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("wheel",this.onWheel),this._isEnabled=!1,this.observer=null,this._timer&&(clearTimeout(this._timer),this._timer=null)},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}(),xe=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Wt(t),this.options=d({scale:[1,1]},e),this.onKeydown=this.onKeydown.bind(this),this.onKeyup=this.onKeyup.bind(this)}var e=t.prototype;return e.mapAxes=function(t){this.axes=t},e.connect=function(t){return this.dettachEvent(),"0"!==this.element.getAttribute("tabindex")&&this.element.setAttribute("tabindex","0"),this.attachEvent(t),this},e.disconnect=function(){return this.dettachEvent(),this},e.destroy=function(){this.disconnect(),this.element=null},e.onKeydown=function(t){if(this._isEnabled){var e=!0,n=1,i=-1;switch(t.keyCode){case 37:case 65:n=-1;break;case 39:case 68:break;case 40:case 83:n=-1,i=1;break;case 38:case 87:i=1;break;default:e=!1}if((-1===i&&!this.axes[0]||1===i&&!this.axes[1])&&(e=!1),e){var r=-1===i?[+this.options.scale[0]*n,0]:[0,+this.options.scale[1]*n];this._isHolded||(this.observer.hold(this,event),this._isHolded=!0),clearTimeout(this._timer),this.observer.change(this,event,fe(this.axes,r))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,fe(e.axes,[0,0])),e._isHolded=!1},80))},e.attachEvent=function(t){this.observer=t,this.element.addEventListener("keydown",this.onKeydown,!1),this.element.addEventListener("keypress",this.onKeydown,!1),this.element.addEventListener("keyup",this.onKeyup,!1),this._isEnabled=!0},e.dettachEvent=function(){this.element.removeEventListener("keydown",this.onKeydown,!1),this.element.removeEventListener("keypress",this.onKeydown,!1),this.element.removeEventListener("keyup",this.onKeyup,!1),this._isEnabled=!1,this.observer=null},e.enable=function(){return this._isEnabled=!0,this},e.disable=function(){return this._isEnabled=!1,this},e.isEnable=function(){return this._isEnabled},t}();return he.PanInput=ve,he.RotatePanInput=ge,he.PinchInput=ye,he.WheelInput=be,he.MoveKeyInput=xe,he}); | ||
//# sourceMappingURL=axes.pkgd.min.js.map |
@@ -104,6 +104,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
var self_1 = this; | ||
var destPos_1 = info_1.destPos; | ||
var prevPos_1 = info_1.depaPos; | ||
var prevEasingPer_1 = 0; | ||
var directions_1 = map(prevPos_1, function (value, key) { | ||
return value <= info_1.destPos[key] ? 1 : -1; | ||
return value <= destPos_1[key] ? 1 : -1; | ||
}); | ||
@@ -115,14 +116,19 @@ var prevTime_1 = new Date().getTime(); | ||
var currentTime = new Date().getTime(); | ||
var easingPer = self_1.easing((currentTime - info_1.startTime) / param.duration); | ||
var toPos = map(prevPos_1, function (pos, key) { return pos + info_1.delta[key] * (easingPer - prevEasingPer_1); }); | ||
toPos = self_1.axm.map(toPos, function (pos, options, key) { | ||
// fix absolute position to relative position | ||
// fix the bouncing phenomenon by changing the range. | ||
var nextPos = getCirculatedPos(pos, options.range, options.circular, true); | ||
if (pos !== nextPos) { | ||
var ratio = (currentTime - info_1.startTime) / param.duration; | ||
var easingPer = self_1.easing(ratio); | ||
var toPos = self_1.axm.map(prevPos_1, function (pos, options, key) { | ||
var nextPos = ratio >= 1 | ||
? destPos_1[key] | ||
: pos + info_1.delta[key] * (easingPer - prevEasingPer_1); | ||
// Subtract distance from distance already moved. | ||
// Recalculate the remaining distance. | ||
// Fix the bouncing phenomenon by changing the range. | ||
var circulatedPos = getCirculatedPos(nextPos, options.range, options.circular, true); | ||
if (nextPos !== circulatedPos) { | ||
// circular | ||
param.destPos[key] += -directions_1[key] * (options.range[1] - options.range[0]); | ||
prevPos_1[key] += -directions_1[key] * (options.range[1] - options.range[0]); | ||
var rangeOffset = directions_1[key] * (options.range[1] - options.range[0]); | ||
destPos_1[key] -= rangeOffset; | ||
prevPos_1[key] -= rangeOffset; | ||
} | ||
return nextPos; | ||
return circulatedPos; | ||
}); | ||
@@ -134,5 +140,4 @@ var isCanceled = !self_1.em.triggerChange(toPos, false, mapToFixed(prevPos_1)); | ||
if (easingPer >= 1) { | ||
var destPos = param.destPos; | ||
if (!equal(destPos, self_1.axm.get(Object.keys(destPos)))) { | ||
self_1.em.triggerChange(destPos, true, mapToFixed(prevPos_1)); | ||
if (!equal(destPos_1, self_1.axm.get(Object.keys(destPos_1)))) { | ||
self_1.em.triggerChange(destPos_1, true, mapToFixed(prevPos_1)); | ||
} | ||
@@ -139,0 +144,0 @@ complete(); |
{ | ||
"name": "@egjs/axes", | ||
"version": "2.5.13", | ||
"version": "2.5.14-rc", | ||
"description": "A module used to change the information of user action entered by various input devices such as touch screen or mouse into the logical virtual coordinates. You can easily create a UI that responds to user actions.", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
@@ -143,6 +143,8 @@ import { IInputType } from "./inputType/InputType"; | ||
const self = this; | ||
const destPos = info.destPos; | ||
let prevPos = info.depaPos; | ||
let prevEasingPer = 0; | ||
const directions = map(prevPos, (value, key) => { | ||
return value <= info.destPos[key] ? 1 : -1; | ||
return value <= destPos[key] ? 1 : -1; | ||
}); | ||
@@ -155,15 +157,21 @@ let prevTime = new Date().getTime(); | ||
const currentTime = new Date().getTime(); | ||
const easingPer = self.easing((currentTime - info.startTime) / param.duration); | ||
let toPos: Axis = map(prevPos, (pos, key) => pos + info.delta[key] * (easingPer - prevEasingPer)); | ||
const ratio = (currentTime - info.startTime) / param.duration; | ||
const easingPer = self.easing(ratio); | ||
const toPos: Axis = self.axm.map(prevPos, (pos, options, key) => { | ||
const nextPos = ratio >= 1 | ||
? destPos[key] | ||
: pos + info.delta[key] * (easingPer - prevEasingPer); | ||
toPos = self.axm.map(toPos, (pos, options, key) => { | ||
// fix absolute position to relative position | ||
// fix the bouncing phenomenon by changing the range. | ||
const nextPos = getCirculatedPos(pos, options.range, options.circular as boolean[], true); | ||
if (pos !== nextPos) { | ||
// Subtract distance from distance already moved. | ||
// Recalculate the remaining distance. | ||
// Fix the bouncing phenomenon by changing the range. | ||
const circulatedPos = getCirculatedPos(nextPos, options.range, options.circular as boolean[], true); | ||
if (nextPos !== circulatedPos) { | ||
// circular | ||
param.destPos[key] += -directions[key] * (options.range[1] - options.range[0]); | ||
prevPos[key] += -directions[key] * (options.range[1] - options.range[0]); | ||
const rangeOffset = directions[key] * (options.range[1] - options.range[0]); | ||
destPos[key] -= rangeOffset; | ||
prevPos[key] -= rangeOffset; | ||
} | ||
return nextPos; | ||
return circulatedPos; | ||
}); | ||
@@ -176,4 +184,2 @@ const isCanceled = !self.em.triggerChange(toPos, false, mapToFixed(prevPos)); | ||
if (easingPer >= 1) { | ||
const destPos = param.destPos; | ||
if (!equal(destPos, self.axm.get(Object.keys(destPos)))) { | ||
@@ -180,0 +186,0 @@ self.em.triggerChange(destPos, true, mapToFixed(prevPos)); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1681309
15300
2