@egjs/axes
Advanced tools
Comparing version 2.5.12 to 2.5.13
@@ -24,2 +24,3 @@ import Component from "@egjs/component"; | ||
static MoveKeyInput: any; | ||
static RotatePanInput: any; | ||
static TRANSFORM: string; | ||
@@ -41,5 +42,5 @@ static DIRECTION_NONE: number; | ||
private _inputs; | ||
constructor(axis: { | ||
constructor(axis?: { | ||
[key: string]: AxisOption; | ||
}, options: AxesOption, startPos?: Axis); | ||
}, options?: AxesOption, startPos?: Axis); | ||
connect(axes: string[] | string, inputType: IInputType): this; | ||
@@ -46,0 +47,0 @@ disconnect(inputType?: IInputType): this; |
@@ -24,4 +24,4 @@ import { ObjectInterface } from "./const"; | ||
filter(pos: Axis, callback: (value: number, options: AxisOption, key: string) => boolean): Axis; | ||
map(pos: Axis, callback: (value: number, options: AxisOption, key: string) => number): Axis; | ||
map<U>(pos: Axis, callback: (value: number, options: AxisOption, key: string) => U): ObjectInterface<U>; | ||
isOutside(axes?: string[]): boolean; | ||
} |
import Axes from "./Axes"; | ||
export { PanInput } from "./inputType/PanInput"; | ||
export { RotatePanInput } from "./inputType/RotatePanInput"; | ||
export { PinchInput } from "./inputType/PinchInput"; | ||
@@ -4,0 +5,0 @@ export { WheelInput } from "./inputType/WheelInput"; |
@@ -18,4 +18,4 @@ import { IInputType, IInputTypeObserver } from "./InputType"; | ||
element: HTMLElement; | ||
private observer; | ||
private _direction; | ||
protected observer: IInputTypeObserver; | ||
protected _direction: any; | ||
private panRecognizer; | ||
@@ -31,5 +31,5 @@ constructor(el: string | HTMLElement, options?: PanInputOption); | ||
private removeRecognizer; | ||
private onHammerInput; | ||
private onPanmove; | ||
private onPanend; | ||
protected onHammerInput(event: any): void; | ||
protected onPanmove(event: any): void; | ||
protected onPanend(event: any): void; | ||
private attachEvent; | ||
@@ -36,0 +36,0 @@ private dettachEvent; |
@@ -6,2 +6,3 @@ import { ObjectInterface } from "./const"; | ||
export declare function cancelAnimationFrame(key: any): void; | ||
export declare function mapToFixed(obj: ObjectInterface<number>): ObjectInterface<number>; | ||
export declare function map<T, U>(obj: ObjectInterface<T>, callback: (value: T, key: string) => U): ObjectInterface<U>; | ||
@@ -8,0 +9,0 @@ export declare function filter<T>(obj: ObjectInterface<T>, callback: (value: T, key: string) => boolean): ObjectInterface<T>; |
@@ -8,5 +8,5 @@ /* | ||
@version 2.5.12 | ||
@version 2.5.13 | ||
*/ | ||
!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])};var s,l=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,n=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 r(t){for(var e=[],n=0,i=t.length;n<i;n++)e.push(t[n]);return e}function a(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=r(i.childNodes)}else n=r(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 a(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var c=s.requestAnimationFrame||s.webkitRequestAnimationFrame,h=s.cancelAnimationFrame||s.webkitCancelAnimationFrame;if(c&&!h){var u={},m=c;c=function(e){var n=m(function(t){u[n]&&e(t)});return u[n]=!0,n},h=function(t){delete u[t]}}else c&&h||(c=function(t){return s.setTimeout(function(){t(s.performance&&s.performance.now&&s.performance.now()||(new Date).getTime())},16)},h=s.clearTimeout);function f(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function d(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function p(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function v(t,n){return p(t,function(t,e){return t===n[e]})}function g(t){return Math.round(t*e)/e}function _(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),+g(s=Math.min(r[1],s))}function E(t,e){return t<e[0]||t>e[1]}function b(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function x(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:+g(s)}function I(t,e,n){return Math.max(Math.min(t,n),e)}var T=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=f(t,function(t,e){return n=Math.abs(Math.abs(t)-Math.abs(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 I(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:I(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 x(t,e.range,e.circular,!1)});p(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(s=this._raf,h(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 b(t,e.range,e.circular)});0<Object.keys(e).length&&this.setTo(this.axm.map(e,function(t,e){return x(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,o){if(r.duration){this._animateParam=l({},r);var a=this._animateParam,h=this,u=a.depaPos;a.startTime=(new Date).getTime(),function t(){h._raf=null;var n=h.easing(((new Date).getTime()-a.startTime)/r.duration),e=f(a.depaPos,function(t,e){return t+a.delta[e]*n}),i=!h.em.triggerChange(e,!1,u);if(u=f(e,function(t){return g(t)}),1<=n){var s=r.destPos;return v(s,h.axm.get(Object.keys(s)))||h.em.triggerChange(s,!0,u),void o()}i?h.finish(!1):h._raf=c(t)}()}else this.em.triggerChange(r.destPos,!0),o()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=I(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=l({},s.depaPos),o=this.em.triggerAnimationStart(s),a=this.getUserControll(s);if(!o&&this.axm.every(a.destPos,function(t,e){return b(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!v(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(v(t,i))return this;this.itm.setInterrupt(!0);var s=d(t,function(t,e){return i[e]!==t});return Object.keys(s).length&&(v(s=this.axm.map(s,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:_(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(f(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),y=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:l({},t),duration:e};return function(t,e){return t&&(n.destPos=l({},t)),void 0!==e&&(n.duration=e),n}},e.setAnimationManager=function(t){this.am=t},e.destroy=function(){this.axes.off()},t}(),O=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}(),P=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]=l({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 f(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},{}):l({},this._pos,t||{})},e.moveTo=function(n,i,s){void 0===s&&(s=this._pos);var t=f(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?x(t,e.range,e.circular,i):0})),{pos:l({},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 p(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return d(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return f(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!E(t,e.range)})},t}(),R=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=f(s,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(s,function(t,e){return!E(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:_(s[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,s,i);0===a&&(o=l({},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=v(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}(),D=function(s){function t(t,e,n){void 0===t&&(t={});var i=s.call(this)||this;return i.axis=t,i._inputs=[],i.options=l({easing:function(t){return 1-Math.pow(1-t,3)},interruptable:!0,maximumDuration:1/0,minimumDuration:0,deceleration:6e-4},e),i.itm=new O(i.options),i.axm=new P(i.axis,i.options),i.em=new y(i),i.am=new T(i),i.io=new R(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}!function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new 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.12",t.TRANSFORM=n,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),C="PointerEvent"in s||"MSPointerEvent"in s,N="ontouchstart"in s,A="_EGJS_AXES_INPUTTYPE_";function w(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function M(t,e){try{return new o.Manager(t,l({},e))}catch(t){return null}}function L(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=N;break;case"pointer":i=C}}),i?o.PointerEventInput:e&&n?o.TouchMouseInput:e?o.TouchInput:n?o.MouseInput:null}function H(t,e,n){return n?!!(e===o.DIRECTION_ALL||e&t&&n&t):!!(e&t)}var j=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=a(t),this.options=l({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[A];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=L(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=M(this.element,l({inputClass:i},this.options.hammerManagerOptions)),this.element[A]=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[A],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],[H(o.DIRECTION_HORIZONTAL,this._direction,e),H(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,w(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)],[H(o.DIRECTION_HORIZONTAL,this._direction),H(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,w(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}(),z=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=a(t),this.options=l({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[A];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=L(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=M(this.element,l({inputClass:i},this.options.hammerManagerOptions)),this.element[A]=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[A],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,w(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,w(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,w(this.axes,[e])),this.observer.release(this,t,w(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}(),S=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=a(t),this.options=l({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,w(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,w(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}(),k=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=a(t),this.options=l({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,w(this.axes,s))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,w(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 D.PanInput=j,D.PinchInput=z,D.WheelInput=S,D.MoveKeyInput=k,D}); | ||
!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}); | ||
//# sourceMappingURL=axes.min.js.map |
@@ -8,3 +8,3 @@ /* | ||
@version 2.5.12 | ||
@version 2.5.13 | ||
@@ -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])};var p=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"),n="function",f=Math.round,x=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 d=m(e.style,"touchAction"),v=void 0!==d;var g="compute",y="auto",b="manipulation",E="none",T="pan-x",P="pan-y",w=function(){if(!v)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}(),O="ontouchstart"in u,I=void 0!==m(u,"PointerEvent"),M=O&&/mobile|tablet|ip(ad|hone|od)|android/i.test(navigator.userAgent),A="touch",D="mouse",z=25,C=1,R=4,S=8,H=1,Y=2,k=4,X=8,j=16,F=Y|k,W=X|j,N=F|W,q=["x","y"],L=["clientX","clientY"];function K(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 U(t,e){return typeof t===n?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===g&&(t=this.compute()),v&&this.manager.element.style&&w[t]&&(this.manager.element.style[d]=t),this.actions=t.toLowerCase().trim()},e.update=function(){this.set(this.manager.options.touchAction)},e.compute=function(){var e=[];return K(this.manager.recognizers,function(t){U(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),function(t){if(V(t,E))return E;var e=V(t,T),n=V(t,P);return e&&n?E:e||n?e?T:P:V(t,b)?b:y}(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,E)&&!w[E],s=V(i,P)&&!w[P],o=V(i,T)&&!w[T];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&F||o&&n&W?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 Q(t){var e=t.length;if(1===e)return{x:f(t[0].clientX),y:f(t[0].clientY)};for(var n=0,i=0,r=0;r<e;)n+=t[r].clientX,i+=t[r].clientY,r++;return{x:f(n/e),y:f(i/e)}}function Z(t){for(var e=[],n=0;n<t.pointers.length;)e[n]={clientX:f(t.pointers[n].clientX),clientY:f(t.pointers[n].clientY)},n++;return{timeStamp:_(),pointers:e,center:Q(e),deltaX:t.deltaX,deltaY:t.deltaY}}function J(t,e,n){n||(n=q);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return Math.sqrt(i*i+r*r)}function $(t,e,n){n||(n=q);var i=e[n[0]]-t[n[0]],r=e[n[1]]-t[n[1]];return 180*Math.atan2(r,i)/Math.PI}function tt(t,e){return t===e?H:x(t)>=x(e)?t<0?Y:k:e<0?X:j}function et(t,e,n){return{x:e/t||0,y:n/t||0}}function nt(t,e){var n=t.session,i=e.pointers,r=i.length;n.firstInput||(n.firstInput=Z(e)),1<r&&!n.firstMultiple?n.firstMultiple=Z(e):1===r&&(n.firstMultiple=!1);var s,o,a,h,u,c,l=n.firstInput,p=n.firstMultiple,f=p?p.center:l.center,m=e.center=Q(i);e.timeStamp=_(),e.deltaTime=e.timeStamp-l.timeStamp,e.angle=$(f,m),e.distance=J(f,m),s=n,a=(o=e).center,h=s.offsetDelta||{},u=s.prevDelta||{},c=s.prevInput||{},o.eventType!==C&&c.eventType!==R||(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=tt(e.deltaX,e.deltaY);var d,v,g,y,b=et(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=b.x,e.overallVelocityY=b.y,e.overallVelocity=x(b.x)>x(b.y)?b.x:b.y,e.scale=p?(d=p.pointers,J((v=i)[0],v[1],L)/J(d[0],d[1],L)):1,e.rotation=p?(g=p.pointers,$((y=i)[1],y[0],L)+$(g[1],g[0],L)):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!==S&&(z<a||void 0===o.velocity)){var h=e.deltaX-o.deltaX,u=e.deltaY-o.deltaY,c=et(a,h,u);i=c.x,r=c.y,n=x(c.x)>x(c.y)?c.x:c.y,s=tt(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 E=t.element;G(e.srcEvent.target,E)&&(E=e.srcEvent.target),e.target=E}function it(t,e,n){var i=n.pointers.length,r=n.changedPointers.length,s=e&C&&i-r==0,o=e&(R|S)&&i-r==0;n.isFirst=!!s,n.isFinal=!!o,s&&(t.session={}),n.eventType=e,nt(t,n),t.emit("hammer.input",n),t.recognize(n),t.session.prevInput=n}function rt(t){return t.trim().split(/\s+/g)}function st(e,t,n){K(rt(t),function(t){e.addEventListener(t,n,!1)})}function ot(e,t,n){K(rt(t),function(t){e.removeEventListener(t,n,!1)})}function at(t){var e=t.ownerDocument||t;return e.defaultView||e.parentWindow||window}var ht=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){U(e.options.enable,[e])&&n.handler(t)},this.init()}var e=t.prototype;return e.handler=function(){},e.init=function(){this.evEl&&st(this.element,this.evEl,this.domHandler),this.evTarget&&st(this.target,this.evTarget,this.domHandler),this.evWin&&st(at(this.element),this.evWin,this.domHandler)},e.destroy=function(){this.evEl&&ot(this.element,this.evEl,this.domHandler),this.evTarget&&ot(this.target,this.evTarget,this.domHandler),this.evWin&&ot(at(this.element),this.evWin,this.domHandler)},t}();function ut(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 ct={pointerdown:C,pointermove:2,pointerup:R,pointercancel:S,pointerout:S},lt={2:A,3:"pen",4:D,5:"kinect"},pt="pointerdown",ft="pointermove pointerup pointercancel";u.MSPointerEvent&&!u.PointerEvent&&(pt="MSPointerDown",ft="MSPointerMove MSPointerUp MSPointerCancel");var mt=function(n){function i(){var t,e=i.prototype;return e.evEl=pt,e.evWin=ft,(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=ct[i],s=lt[t.pointerType]||t.pointerType,o=s===A,a=ut(e,t.pointerId,"pointerId");r&C&&(0===t.button||o)?a<0&&(e.push(t),a=e.length-1):r&(R|S)&&(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}(ht);function dt(t){return Array.prototype.slice.call(t,0)}function vt(t,n,e){for(var i=[],r=[],s=0;s<t.length;){var o=n?t[s][n]:t[s];ut(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 gt={touchstart:C,touchmove:2,touchend:R,touchcancel:S},yt=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=gt[t.type],n=function(t,e){var n,i,r=dt(t.touches),s=this.targetIds;if(e&(2|C)&&1===r.length)return s[r[0].identifier]=!0,[r,r];var o=dt(t.changedTouches),a=[],h=this.target;if(i=r.filter(function(t){return G(t.target,h)}),e===C)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&(R|S)&&delete s[o[n].identifier],n++;return a.length?[vt(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:A,srcEvent:t})},n}(ht);var bt={mousedown:C,mousemove:2,mouseup:R},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=bt[t.type];e&C&&0===t.button&&(this.pressed=!0),2&e&&1!==t.which&&(e=R),this.pressed&&(e&R&&(this.pressed=!1),this.callback(this.manager,e,{pointers:[t],changedPointers:[t],pointerType:D,srcEvent:t}))},i}(ht),xt=2500,_t=25;function Tt(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)},xt)}}var Pt=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===A,r=n.pointerType===D;if(!(r&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(i)(function(t,e){t&C?(this.primaryTouch=e.changedPointers[0].identifier,Tt.call(this,e)):t&(R|S)&&Tt.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<=_t&&o<=_t)return!0}return!1}.call(h(h(s)),n))return;s.callback(t,e,n)}},s.touch=new yt(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}(ht)}();function wt(t,e,n){return!!Array.isArray(t)&&(K(t,n[e],n),!0)}var Ot=1;function It(t,e){var n=e.manager;return n?n.get(t):t}function Mt(t){return 16&t?"cancel":8&t?"end":4&t?"move":2&t?"start":""}var At=function(){function t(t){void 0===t&&(t={}),this.options=s({enable:!0},t),this.id=Ot++,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(wt(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 wt(t,"dropRecognizeWith",this)||(t=It(t,this),delete this.simultaneous[t.id]),this},e.requireFailure=function(t){if(wt(t,"requireFailure",this))return this;var e=this.requireFail;return-1===ut(e,t=It(t,this))&&(e.push(t),t.requireFailure(this)),this},e.dropRequireFailure=function(t){if(wt(t,"dropRequireFailure",this))return this;t=It(t,this);var e=ut(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+Mt(t)),i(n.options.event),e.additionalEvent&&i(e.additionalEvent),8<=t&&i(n.options.event+Mt(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(!U(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}(),Dt={domEvents:!1,touchAction:g,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 zt(n,i){var r,s=n.element;s.style&&(K(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 Ct=function(){function t(t,e){var n,i=this;this.options=c({},Dt,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?mt:M?yt:O?Pt:Et))(n,it),this.touchAction=new B(this,this.options.touchAction),zt(this,!0),K(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 At)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(wt(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(wt(t,"remove",this))return this;var e=this.get(t);if(t){var n=this.recognizers,i=ut(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 K(rt(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 K(rt(t),function(t){e?n[t]&&n[t].splice(ut(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&&zt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null},t}();var Rt=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&S||!r)?16|e:i||r?n&R?8|e:2&e?4|e:2:32},t}(At);function St(t){return t===j?"down":t===X?"up":t===Y?"left":t===k?"right":""}var Ht=function(n){function t(t){var e;return void 0===t&&(t={}),(e=n.call(this,s({event:"pan",threshold:10,pointers:1,direction:N},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&F&&e.push(P),t&W&&e.push(T),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&F?(r=0===s?H:s<0?Y:k,n=s!==this.pX,Math.abs(t.deltaX)):(r=0===o?H:o<0?X:j,n=o!==this.pY,Math.abs(t.deltaY))),t.direction=r,n&&i>e.threshold&&r&e.direction},e.attrTest=function(t){return Rt.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=St(t.direction);e&&(t.additionalEvent=this.options.event+e),n.prototype.emit.call(this,t)},t}(Rt),Yt=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[E]},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}(Rt),kt=1e5,Xt=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 Ft(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 Ft(t)}),e||(n=1<=n.length?n[0]:void 0)):n=t;return n}var Wt=r.requestAnimationFrame||r.webkitRequestAnimationFrame,Nt=r.cancelAnimationFrame||r.webkitCancelAnimationFrame;if(Wt&&!Nt){var qt={},Lt=Wt;Wt=function(e){var n=Lt(function(t){qt[n]&&e(t)});return qt[n]=!0,n},Nt=function(t){delete qt[t]}}else Wt&&Nt||(Wt=function(t){return r.setTimeout(function(){t(r.performance&&r.performance.now&&r.performance.now()||(new Date).getTime())},16)},Nt=r.clearTimeout);function Kt(t,e){var n={};for(var i in t)i&&(n[i]=e(t[i],i));return n}function Ut(t,e){var n={};for(var i in t)i&&e(t[i],i)&&(n[i]=t[i]);return n}function Vt(t,e){for(var n in t)if(n&&!e(t[n],n))return!1;return!0}function Bt(t,n){return Vt(t,function(t,e){return t===n[e]})}function Gt(t){return Math.round(t*kt)/kt}function Qt(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),+Gt(r=Math.min(s[1],r))}function Zt(t,e){return t<e[0]||t>e[1]}function Jt(t,e,n){return n[1]&&t>e[1]||n[0]&&t<e[0]}function $t(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:+Gt(r)}function te(t,e,n){return Math.max(Math.min(t,n),e)}var ee=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=Kt(t,function(t,e){return n=Math.abs(Math.abs(t)-Math.abs(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 te(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:te(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 $t(t,e.range,e.circular,!1)});Vt(i,function(t,e){return n[e]===t})||this.em.triggerChange(i,!1,n,e,!!e),this._animateParam=null,this._raf&&(r=this._raf,Nt(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 Jt(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,o){if(s.duration){this._animateParam=p({},s);var a=this._animateParam,h=this,u=a.depaPos;a.startTime=(new Date).getTime(),function t(){h._raf=null;var n=h.easing(((new Date).getTime()-a.startTime)/s.duration),e=Kt(a.depaPos,function(t,e){return t+a.delta[e]*n}),i=!h.em.triggerChange(e,!1,u);if(u=Kt(e,function(t){return Gt(t)}),1<=n){var r=s.destPos;return Bt(r,h.axm.get(Object.keys(r)))||h.em.triggerChange(r,!0,u),void o()}i?h.finish(!1):h._raf=Wt(t)}()}else this.em.triggerChange(s.destPos,!0),o()},e.getUserControll=function(t){var e=t.setTo();return e.destPos=this.axm.get(e.destPos),e.duration=te(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=p({},r.depaPos),o=this.em.triggerAnimationStart(r),a=this.getUserControll(r);if(!o&&this.axm.every(a.destPos,function(t,e){return Jt(t,e.range,e.circular)})&&console.warn("You can't stop the 'animation' event when 'circular' is true."),o&&!Bt(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(Bt(t,i))return this;this.itm.setInterrupt(!0);var r=Ut(t,function(t,e){return i[e]!==t});return Object.keys(r).length&&(Bt(r=this.axm.map(r,function(t,e){var n=e.range,i=e.circular;return i&&(i[0]||i[1])?t:Qt(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(Kt(this.axm.get(Object.keys(n)),function(t,e){return t+n[e]}),t)},t}(),ne=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: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}(),ie=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}(),re=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]=p({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 Kt(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,r){void 0===r&&(r=this._pos);var t=Kt(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?$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 Vt(t,function(t,e){return n(t,i[e],e)})},e.filter=function(t,n){var i=this.axis;return Ut(t,function(t,e){return n(t,i[e],e)})},e.map=function(t,n){var i=this.axis;return Kt(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!Zt(t,e.range)})},t}(),se=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=Kt(r,function(t,e){return t+(n[e]||0)}),this.moveDistance&&(this.moveDistance=i),this.isOutside&&this.axm.every(r,function(t,e){return!Zt(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:Qt(r[n]+t,e.range,e.circular,e.bounce)})),a=this.am.getDuration(o,r,i);0===a&&(o=p({},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=Bt(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}(),oe=function(r){function t(t,e,n){void 0===t&&(t={});var i=r.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 ie(i.options),i.axm=new re(i.axis,i.options),i.em=new ne(i),i.am=new ee(i),i.io=new se(i),i.em.setAnimationManager(i.am),n&&i.em.triggerChange(n),i}!function(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new 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.12",t.TRANSFORM=Xt,t.DIRECTION_NONE=H,t.DIRECTION_LEFT=Y,t.DIRECTION_RIGHT=k,t.DIRECTION_UP=X,t.DIRECTION_DOWN=j,t.DIRECTION_HORIZONTAL=F,t.DIRECTION_VERTICAL=W,t.DIRECTION_ALL=N,t}(t),ae="PointerEvent"in r||"MSPointerEvent"in r,he="ontouchstart"in r,ue="_EGJS_AXES_INPUTTYPE_";function ce(i,t){return t.reduce(function(t,e,n){return i[n]&&(t[i[n]]=e),t},{})}function le(t,e){try{return new Ct(t,p({},e))}catch(t){return null}}function pe(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=he;break;case"pointer":i=ae}}),i?mt:e&&n?Pt:e?yt:n?Et:null}function fe(t,e,n){return n?!!(e===N||e&t&&n&t):!!(e&t)}var me=function(){function t(t,e){if(this.axes=[],this.hammer=null,this.element=null,this.panRecognizer=null,void 0===Ct)throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/");this.element=Ft(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?N:e?F:n?W:H,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[ue];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=pe(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=le(this.element,p({inputClass:i},this.options.hammerManagerOptions)),this.element[ue]=n}return this.panRecognizer=new Ht(e),this.hammer.add(this.panRecognizer),this.attachEvent(t),this},e.disconnect=function(){return this.removeRecognizer(),this.hammer&&this.dettachEvent(),this._direction=H,this},e.destroy=function(){this.disconnect(),this.hammer&&0===this.hammer.recognizers.length&&this.hammer.destroy(),delete this.element[ue],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 H;var n=Math.abs(t);return e<n&&n<180-e?W:F}(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],[fe(F,this._direction,e),fe(W,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,ce(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)],[fe(F,this._direction),fe(W,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,ce(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}(),de=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===Ct)throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/");this.element=Ft(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[ue];n||(n=String(Math.round(Math.random()*(new Date).getTime())));var i=pe(this.options.inputType);if(!i)throw new Error("Wrong inputType parameter!");this.hammer=le(this.element,p({inputClass:i},this.options.hammerManagerOptions)),this.element[ue]=n}return this.pinchRecognizer=new Yt(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[ue],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,ce(this.axes,[e])),this._prev=t.scale},e.onPinchMove=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,ce(this.axes,[e])),this._prev=t.scale},e.onPinchEnd=function(t){var e=this.getOffset(t.scale,this._prev);this.observer.change(this,t,ce(this.axes,[e])),this.observer.release(this,t,ce(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}(),ve=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Ft(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,ce(this.axes,[n])),clearTimeout(this._timer),this._timer=setTimeout(function(){e._isHolded&&(e._isHolded=!1,e.observer.release(e,t,ce(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}(),ge=function(){function t(t,e){this.axes=[],this.element=null,this._isEnabled=!1,this._isHolded=!1,this._timer=null,this.element=Ft(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 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,ce(this.axes,r))}}},e.onKeyup=function(t){var e=this;this._isHolded&&(clearTimeout(this._timer),this._timer=setTimeout(function(){e.observer.release(e,t,ce(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 oe.PanInput=me,oe.PinchInput=de,oe.WheelInput=ve,oe.MoveKeyInput=ge,oe}); | ||
!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}); | ||
//# sourceMappingURL=axes.pkgd.min.js.map |
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { getInsidePosition, isCircularable, getCirculatedPos, getDuration } from "./Coordinate"; | ||
import { requestAnimationFrame, cancelAnimationFrame, map, every, filter, equal, toFixed } from "./utils"; | ||
import { requestAnimationFrame, cancelAnimationFrame, map, every, filter, equal, mapToFixed } from "./utils"; | ||
function minMax(value, min, max) { | ||
return Math.max(Math.min(value, max), min); | ||
} | ||
var AnimationManager = (function () { | ||
var AnimationManager = /** @class */ (function () { | ||
function AnimationManager(_a) { | ||
@@ -31,3 +31,3 @@ var options = _a.options, itm = _a.itm, em = _a.em, axm = _a.axm; | ||
else { | ||
var durations_1 = map(destPos, function (v, k) { return getDuration(Math.abs(Math.abs(v) - Math.abs(depaPos[k])), _this.options.deceleration); }); | ||
var durations_1 = map(destPos, function (v, k) { return getDuration(Math.abs(v - depaPos[k]), _this.options.deceleration); }); | ||
duration = Object.keys(durations_1).reduce(function (max, v) { return Math.max(max, durations_1[v]); }, -Infinity); | ||
@@ -84,2 +84,3 @@ } | ||
this._animateParam = null; | ||
// for Circular | ||
var circularTargets = this.axm.filter(this.axm.get(), function (v, opt) { return isCircularable(v, opt.range, opt.circular); }); | ||
@@ -107,13 +108,32 @@ Object.keys(circularTargets).length > 0 && this.setTo(this.axm.map(circularTargets, function (v, opt) { return getCirculatedPos(v, opt.range, opt.circular, false); })); | ||
var prevPos_1 = info_1.depaPos; | ||
info_1.startTime = new Date().getTime(); | ||
var prevEasingPer_1 = 0; | ||
var directions_1 = map(prevPos_1, function (value, key) { | ||
return value <= info_1.destPos[key] ? 1 : -1; | ||
}); | ||
var prevTime_1 = new Date().getTime(); | ||
info_1.startTime = prevTime_1; | ||
(function loop() { | ||
self_1._raf = null; | ||
var easingPer = self_1.easing((new Date().getTime() - info_1.startTime) / param.duration); | ||
var toPos = map(info_1.depaPos, function (pos, key) { return pos + info_1.delta[key] * easingPer; }); | ||
var isCanceled = !self_1.em.triggerChange(toPos, false, prevPos_1); | ||
prevPos_1 = map(toPos, function (v) { return toFixed(v); }); | ||
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) { | ||
// 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]); | ||
} | ||
return nextPos; | ||
}); | ||
var isCanceled = !self_1.em.triggerChange(toPos, false, mapToFixed(prevPos_1)); | ||
prevPos_1 = toPos; | ||
prevTime_1 = currentTime; | ||
prevEasingPer_1 = easingPer; | ||
if (easingPer >= 1) { | ||
var destPos = param.destPos; | ||
if (!equal(destPos, self_1.axm.get(Object.keys(destPos)))) { | ||
self_1.em.triggerChange(destPos, true, prevPos_1); | ||
self_1.em.triggerChange(destPos, true, mapToFixed(prevPos_1)); | ||
} | ||
@@ -127,2 +147,3 @@ complete(); | ||
else { | ||
// animationEnd | ||
self_1._raf = requestAnimationFrame(loop); | ||
@@ -148,3 +169,5 @@ } | ||
var retTrigger = this.em.triggerAnimationStart(param); | ||
// to control | ||
var userWish = this.getUserControll(param); | ||
// You can't stop the 'animationStart' event when 'circular' is true. | ||
if (!retTrigger && this.axm.every(userWish.destPos, function (v, opt) { return isCircularable(v, opt.range, opt.circular); })) { | ||
@@ -151,0 +174,0 @@ console.warn("You can't stop the 'animation' event when 'circular' is true."); |
@@ -26,6 +26,98 @@ var __extends = (this && this.__extends) || (function () { | ||
import { TRANSFORM, DIRECTION_NONE, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, DIRECTION_DOWN, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, DIRECTION_ALL } from "./const"; | ||
var Axes = (function (_super) { | ||
/** | ||
* @typedef {Object} AxisOption The Axis information. The key of the axis specifies the name to use as the logical virtual coordinate system. | ||
* @ko 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다. | ||
* @property {Number[]} [range] The coordinate of range <ko>좌표 범위</ko> | ||
* @property {Number} [range.0=0] The coordinate of the minimum <ko>최소 좌표</ko> | ||
* @property {Number} [range.1=0] The coordinate of the maximum <ko>최대 좌표</ko> | ||
* @property {Number[]} [bounce] The size of bouncing area. The coordinates can exceed the coordinate area as much as the bouncing area based on user action. If the coordinates does not exceed the bouncing area when an element is dragged, the coordinates where bouncing effects are applied are retuned back into the coordinate area<ko>바운스 영역의 크기. 사용자의 동작에 따라 좌표가 좌표 영역을 넘어 바운스 영역의 크기만큼 더 이동할 수 있다. 사용자가 끌어다 놓는 동작을 했을 때 좌표가 바운스 영역에 있으면, 바운스 효과가 적용된 좌표가 다시 좌표 영역 안으로 들어온다</ko> | ||
* @property {Number} [bounce.0=0] The size of coordinate of the minimum area <ko>최소 좌표 바운스 영역의 크기</ko> | ||
* @property {Number} [bounce.1=0] The size of coordinate of the maximum area <ko>최대 좌표 바운스 영역의 크기</ko> | ||
* @property {Boolean[]} [circular] Indicates whether a circular element is available. If it is set to "true" and an element is dragged outside the coordinate area, the element will appear on the other side.<ko>순환 여부. 'true'로 설정한 방향의 좌표 영역 밖으로 엘리먼트가 이동하면 반대 방향에서 엘리먼트가 나타난다</ko> | ||
* @property {Boolean} [circular.0=false] Indicates whether to circulate to the coordinate of the minimum <ko>최소 좌표 방향의 순환 여부</ko> | ||
* @property {Boolean} [circular.1=false] Indicates whether to circulate to the coordinate of the maximum <ko>최대 좌표 방향의 순환 여부</ko> | ||
**/ | ||
/** | ||
* @typedef {Object} AxesOption The option object of the eg.Axes module | ||
* @ko eg.Axes 모듈의 옵션 객체 | ||
* @property {Function} [easing=easing.easeOutCubic] The easing function to apply to an animation <ko>애니메이션에 적용할 easing 함수</ko> | ||
* @property {Number} [maximumDuration=Infinity] Maximum duration of the animation <ko>가속도에 의해 애니메이션이 동작할 때의 최대 좌표 이동 시간</ko> | ||
* @property {Number} [minimumDuration=0] Minimum duration of the animation <ko>가속도에 의해 애니메이션이 동작할 때의 최소 좌표 이동 시간</ko> | ||
* @property {Number} [deceleration=0.0006] Deceleration of the animation where acceleration is manually enabled by user. A higher value indicates shorter running time. <ko>사용자의 동작으로 가속도가 적용된 애니메이션의 감속도. 값이 높을수록 애니메이션 실행 시간이 짧아진다</ko> | ||
* @property {Boolean} [interruptable=true] Indicates whether an animation is interruptible.<br>- true: It can be paused or stopped by user action or the API.<br>- false: It cannot be paused or stopped by user action or the API while it is running.<ko>진행 중인 애니메이션 중지 가능 여부.<br>- true: 사용자의 동작이나 API로 애니메이션을 중지할 수 있다.<br>- false: 애니메이션이 진행 중일 때는 사용자의 동작이나 API가 적용되지 않는다</ko> | ||
**/ | ||
/** | ||
* @class eg.Axes | ||
* @classdesc 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. | ||
* @ko 터치 입력 장치나 마우스와 같은 다양한 입력 장치를 통해 전달 받은 사용자의 동작을 논리적인 가상 좌표로 변경하는 모듈이다. 사용자 동작에 반응하는 UI를 손쉽게 만들수 있다. | ||
* @extends eg.Component | ||
* | ||
* @param {Object.<string, AxisOption>} axis Axis information managed by eg.Axes. The key of the axis specifies the name to use as the logical virtual coordinate system. <ko>eg.Axes가 관리하는 축 정보. 축의 키는 논리적인 가상 좌표계로 사용할 이름을 지정한다.</ko> | ||
* @param {AxesOption} [options] The option object of the eg.Axes module<ko>eg.Axes 모듈의 옵션 객체</ko> | ||
* @param {Object.<string, number>} [startPos] The coordinates to be moved when creating an instance. not triggering change event.<ko>인스턴스 생성시 이동할 좌표, change 이벤트는 발생하지 않음.</ko> | ||
* | ||
* @support {"ie": "10+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.3+ (except 3.x)"} | ||
* @example | ||
* | ||
* // 1. Initialize eg.Axes | ||
* const axes = new eg.Axes({ | ||
* something1: { | ||
* range: [0, 150], | ||
* bounce: 50 | ||
* }, | ||
* something2: { | ||
* range: [0, 200], | ||
* bounce: 100 | ||
* }, | ||
* somethingN: { | ||
* range: [1, 10], | ||
* } | ||
* }, { | ||
* deceleration : 0.0024 | ||
* }); | ||
* | ||
* // 2. attach event handler | ||
* axes.on({ | ||
* "hold" : function(evt) { | ||
* }, | ||
* "release" : function(evt) { | ||
* }, | ||
* "animationStart" : function(evt) { | ||
* }, | ||
* "animationEnd" : function(evt) { | ||
* }, | ||
* "change" : function(evt) { | ||
* } | ||
* }); | ||
* | ||
* // 3. Initialize inputTypes | ||
* const panInputArea = new eg.Axes.PanInput("#area", { | ||
* scale: [0.5, 1] | ||
* }); | ||
* const panInputHmove = new eg.Axes.PanInput("#hmove"); | ||
* const panInputVmove = new eg.Axes.PanInput("#vmove"); | ||
* const pinchInputArea = new eg.Axes.PinchInput("#area", { | ||
* scale: 1.5 | ||
* }); | ||
* | ||
* // 4. Connect eg.Axes and InputTypes | ||
* // [PanInput] When the mouse or touchscreen is down and moved. | ||
* // Connect the 'something2' axis to the mouse or touchscreen x position and | ||
* // connect the 'somethingN' axis to the mouse or touchscreen y position. | ||
* axes.connect(["something2", "somethingN"], panInputArea); // or axes.connect("something2 somethingN", panInputArea); | ||
* | ||
* // Connect only one 'something1' axis to the mouse or touchscreen x position. | ||
* axes.connect(["something1"], panInputHmove); // or axes.connect("something1", panInputHmove); | ||
* | ||
* // Connect only one 'something2' axis to the mouse or touchscreen y position. | ||
* axes.connect(["", "something2"], panInputVmove); // or axes.connect(" something2", panInputVmove); | ||
* | ||
* // [PinchInput] Connect 'something2' axis when two pointers are moving toward (zoom-in) or away from each other (zoom-out). | ||
* axes.connect("something2", pinchInputArea); | ||
*/ | ||
var Axes = /** @class */ (function (_super) { | ||
__extends(Axes, _super); | ||
function Axes(axis, options, startPos) { | ||
if (axis === void 0) { axis = {}; } | ||
if (options === void 0) { options = {}; } | ||
var _this = _super.call(this) || this; | ||
@@ -52,2 +144,26 @@ _this.axis = axis; | ||
} | ||
/** | ||
* Connect the axis of eg.Axes to the inputType. | ||
* @ko eg.Axes의 축과 inputType을 연결한다 | ||
* @method eg.Axes#connect | ||
* @param {(String[]|String)} axes The name of the axis to associate with inputType <ko>inputType과 연결할 축의 이름</ko> | ||
* @param {Object} inputType The inputType instance to associate with the axis of eg.Axes <ko>eg.Axes의 축과 연결할 inputType 인스턴스<ko> | ||
* @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* } | ||
* }); | ||
* | ||
* axes.connect("x", new eg.Axes.PanInput("#area1")) | ||
* .connect("x xOther", new eg.Axes.PanInput("#area2")) | ||
* .connect(" xOther", new eg.Axes.PanInput("#area3")) | ||
* .connect(["x"], new eg.Axes.PanInput("#area4")) | ||
* .connect(["xOther", "x"], new eg.Axes.PanInput("#area5")) | ||
* .connect(["", "xOther"], new eg.Axes.PanInput("#area6")); | ||
*/ | ||
Axes.prototype.connect = function (axes, inputType) { | ||
@@ -61,5 +177,7 @@ var mapped; | ||
} | ||
// check same instance | ||
if (~this._inputs.indexOf(inputType)) { | ||
this.disconnect(inputType); | ||
} | ||
// check same element in hammer type for share | ||
if ("hammer" in inputType) { | ||
@@ -76,2 +194,29 @@ var targets = this._inputs.filter(function (v) { return v.hammer && v.element === inputType.element; }); | ||
}; | ||
/** | ||
* Disconnect the axis of eg.Axes from the inputType. | ||
* @ko eg.Axes의 축과 inputType의 연결을 끊는다. | ||
* @method eg.Axes#disconnect | ||
* @param {Object} [inputType] An inputType instance associated with the axis of eg.Axes <ko>eg.Axes의 축과 연결한 inputType 인스턴스<ko> | ||
* @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* } | ||
* }); | ||
* | ||
* const input1 = new eg.Axes.PanInput("#area1"); | ||
* const input2 = new eg.Axes.PanInput("#area2"); | ||
* const input3 = new eg.Axes.PanInput("#area3"); | ||
* | ||
* axes.connect("x", input1); | ||
* .connect("x xOther", input2) | ||
* .connect(["xOther", "x"], input3); | ||
* | ||
* axes.disconnect(input1); // disconnects input1 | ||
* axes.disconnect(); // disconnects all of them | ||
*/ | ||
Axes.prototype.disconnect = function (inputType) { | ||
@@ -91,5 +236,55 @@ if (inputType) { | ||
}; | ||
/** | ||
* Returns the current position of the coordinates. | ||
* @ko 좌표의 현재 위치를 반환한다 | ||
* @method eg.Axes#get | ||
* @param {Object} [axes] The names of the axis <ko>축 이름들</ko> | ||
* @return {Object.<string, number>} Axis coordinate information <ko>축 좌표 정보</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }); | ||
* | ||
* axes.get(); // {"x": 0, "xOther": -100, "zoom": 50} | ||
* axes.get(["x", "zoom"]); // {"x": 0, "zoom": 50} | ||
*/ | ||
Axes.prototype.get = function (axes) { | ||
return this.axm.get(axes); | ||
}; | ||
/** | ||
* Moves an axis to specific coordinates. | ||
* @ko 좌표를 이동한다. | ||
* @method eg.Axes#setTo | ||
* @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko> | ||
* @param {Number} [duration=0] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko> | ||
* @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }); | ||
* | ||
* axes.setTo({"x": 30, "zoom": 60}); | ||
* axes.get(); // {"x": 30, "xOther": -100, "zoom": 60} | ||
* | ||
* axes.setTo({"x": 100, "xOther": 60}, 1000); // animatation | ||
* | ||
* // after 1000 ms | ||
* axes.get(); // {"x": 100, "xOther": 60, "zoom": 60} | ||
*/ | ||
Axes.prototype.setTo = function (pos, duration) { | ||
@@ -100,2 +295,30 @@ if (duration === void 0) { duration = 0; } | ||
}; | ||
/** | ||
* Moves an axis from the current coordinates to specific coordinates. | ||
* @ko 현재 좌표를 기준으로 좌표를 이동한다. | ||
* @method eg.Axes#setBy | ||
* @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko> | ||
* @param {Number} [duration=0] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko> | ||
* @return {eg.Axes} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }); | ||
* | ||
* axes.setBy({"x": 30, "zoom": 10}); | ||
* axes.get(); // {"x": 30, "xOther": -100, "zoom": 60} | ||
* | ||
* axes.setBy({"x": 70, "xOther": 60}, 1000); // animatation | ||
* | ||
* // after 1000 ms | ||
* axes.get(); // {"x": 100, "xOther": -40, "zoom": 60} | ||
*/ | ||
Axes.prototype.setBy = function (pos, duration) { | ||
@@ -106,5 +329,33 @@ if (duration === void 0) { duration = 0; } | ||
}; | ||
/** | ||
* Returns whether there is a coordinate in the bounce area of the target axis. | ||
* @ko 대상 축 중 bounce영역에 좌표가 존재하는지를 반환한다 | ||
* @method eg.Axes#isBounceArea | ||
* @param {Object} [axes] The names of the axis <ko>축 이름들</ko> | ||
* @return {Boolen} Whether the bounce area exists. <ko>bounce 영역 존재 여부</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "xOther": { | ||
* range: [-100, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }); | ||
* | ||
* axes.isBounceArea(["x"]); | ||
* axes.isBounceArea(["x", "zoom"]); | ||
* axes.isBounceArea(); | ||
*/ | ||
Axes.prototype.isBounceArea = function (axes) { | ||
return this.axm.isOutside(axes); | ||
}; | ||
/** | ||
* Destroys properties, and events used in a module and disconnect all connections to inputTypes. | ||
* @ko 모듈에 사용한 속성, 이벤트를 해제한다. 모든 inputType과의 연결을 끊는다. | ||
* @method eg.Axes#destroy | ||
*/ | ||
Axes.prototype.destroy = function () { | ||
@@ -114,11 +365,71 @@ this.disconnect(); | ||
}; | ||
/** | ||
* Version info string | ||
* @ko 버전정보 문자열 | ||
* @name VERSION | ||
* @static | ||
* @type {String} | ||
* @example | ||
* eg.Axes.VERSION; // ex) 3.3.3 | ||
* @memberof eg.Axes | ||
*/ | ||
Axes.VERSION = "#__VERSION__#"; | ||
/** | ||
* @name eg.Axes.TRANSFORM | ||
* @desc Returns the transform attribute with CSS vendor prefixes. | ||
* @ko CSS vendor prefixes를 붙인 transform 속성을 반환한다. | ||
* | ||
* @constant | ||
* @type {String} | ||
* @example | ||
* eg.Axes.TRANSFORM; // "transform" or "webkitTransform" | ||
*/ | ||
Axes.TRANSFORM = TRANSFORM; | ||
/** | ||
* @name eg.Axes.DIRECTION_NONE | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_NONE = DIRECTION_NONE; | ||
/** | ||
* @name eg.Axes.DIRECTION_LEFT | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_LEFT = DIRECTION_LEFT; | ||
/** | ||
* @name eg.Axes.DIRECTION_RIGHT | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_RIGHT = DIRECTION_RIGHT; | ||
/** | ||
* @name eg.Axes.DIRECTION_UP | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_UP = DIRECTION_UP; | ||
/** | ||
* @name eg.Axes.DIRECTION_DOWN | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_DOWN = DIRECTION_DOWN; | ||
/** | ||
* @name eg.Axes.DIRECTION_HORIZONTAL | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_HORIZONTAL = DIRECTION_HORIZONTAL; | ||
/** | ||
* @name eg.Axes.DIRECTION_VERTICAL | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_VERTICAL = DIRECTION_VERTICAL; | ||
/** | ||
* @name eg.Axes.DIRECTION_ALL | ||
* @constant | ||
* @type {Number} | ||
*/ | ||
Axes.DIRECTION_ALL = DIRECTION_ALL; | ||
@@ -125,0 +436,0 @@ return Axes; |
@@ -11,3 +11,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { map, filter, every } from "./utils"; | ||
var AxisManager = (function () { | ||
var AxisManager = /** @class */ (function () { | ||
function AxisManager(axis, options) { | ||
@@ -23,2 +23,6 @@ var _this = this; | ||
} | ||
/** | ||
* set up 'css' expression | ||
* @private | ||
*/ | ||
AxisManager.prototype._complementOptions = function () { | ||
@@ -25,0 +29,0 @@ var _this = this; |
@@ -0,3 +1,5 @@ | ||
/* eslint-disable no-new-func, no-nested-ternary */ | ||
var win; | ||
if (typeof window === "undefined") { | ||
// window is undefined in node.js | ||
win = {}; | ||
@@ -8,3 +10,4 @@ } | ||
} | ||
/* eslint-enable no-new-func, no-nested-ternary */ | ||
export { win as window }; | ||
//# sourceMappingURL=browser.js.map |
@@ -0,1 +1,9 @@ | ||
// export const DIRECTION_NONE = 1; | ||
// export const DIRECTION_LEFT = 2; | ||
// export const DIRECTION_RIGHT = 4; | ||
// export const DIRECTION_HORIZONTAL = 2 | 4; | ||
// export const DIRECTION_UP = 8; | ||
// export const DIRECTION_DOWN = 16; | ||
// export const DIRECTION_VERTICAL = 8 | 16; | ||
// export const DIRECTION_ALL = 2 | 4 | 8 | 16; | ||
export { DIRECTION_NONE, DIRECTION_LEFT, DIRECTION_RIGHT, DIRECTION_UP, DIRECTION_DOWN, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL, DIRECTION_ALL, } from "@egjs/hammerjs"; | ||
@@ -2,0 +10,0 @@ export var FIXED_DIGIT = 100000; |
@@ -12,2 +12,3 @@ import { toFixed } from "./utils"; | ||
} | ||
// determine outside | ||
export function isOutside(pos, range) { | ||
@@ -18,2 +19,3 @@ return pos < range[0] || pos > range[1]; | ||
var duration = Math.sqrt(distance / deceleration * 2); | ||
// when duration is under 100, then value is zero | ||
return duration < 100 ? 0 : duration; | ||
@@ -30,6 +32,6 @@ } | ||
var length = max - min; | ||
if (circular[1] && pos > max) { | ||
if (circular[1] && pos > max) { // right | ||
toPos = (toPos - max) % length + min; | ||
} | ||
if (circular[0] && pos < min) { | ||
if (circular[0] && pos < min) { // left | ||
toPos = (toPos - min) % length + max; | ||
@@ -36,0 +38,0 @@ } |
@@ -9,6 +9,32 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
}; | ||
var EventManager = (function () { | ||
var EventManager = /** @class */ (function () { | ||
function EventManager(axes) { | ||
this.axes = axes; | ||
} | ||
/** | ||
* This event is fired when a user holds an element on the screen of the device. | ||
* @ko 사용자가 기기의 화면에 손을 대고 있을 때 발생하는 이벤트 | ||
* @name eg.Axes#hold | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired<ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Object.<string, number>} pos coordinate <ko>좌표 정보</ko> | ||
* @property {Object} input The instance of inputType where the event occurred<ko>이벤트가 발생한 inputType 인스턴스</ko> | ||
* @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("hold", function(event) { | ||
* // event.pos | ||
* // event.input | ||
* // event.inputEvent | ||
* // isTrusted | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerHold = function (pos, option) { | ||
@@ -22,2 +48,73 @@ this.axes.trigger("hold", { | ||
}; | ||
/** | ||
* Specifies the coordinates to move after the 'change' event. It works when the holding value of the change event is true. | ||
* @ko 'change' 이벤트 이후 이동할 좌표를 지정한다. change이벤트의 holding 값이 true일 경우에 동작한다 | ||
* @name set | ||
* @function | ||
* @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("change", function(event) { | ||
* event.holding && event.set({x: 10}); | ||
* }); | ||
*/ | ||
/** Specifies the animation coordinates to move after the 'release' or 'animationStart' events. | ||
* @ko 'release' 또는 'animationStart' 이벤트 이후 이동할 좌표를 지정한다. | ||
* @name setTo | ||
* @function | ||
* @param {Object.<string, number>} pos The coordinate to move to <ko>이동할 좌표</ko> | ||
* @param {Number} [duration] Duration of the animation (unit: ms) <ko>애니메이션 진행 시간(단위: ms)</ko> | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("animationStart", function(event) { | ||
* event.setTo({x: 10}, 2000); | ||
* }); | ||
*/ | ||
/** | ||
* This event is fired when a user release an element on the screen of the device. | ||
* @ko 사용자가 기기의 화면에서 손을 뗐을 때 발생하는 이벤트 | ||
* @name eg.Axes#release | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired<ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Object.<string, number>} depaPos The coordinates when releasing an element<ko>손을 뗐을 때의 좌표 </ko> | ||
* @property {Object.<string, number>} destPos The coordinates to move to after releasing an element<ko>손을 뗀 뒤에 이동할 좌표</ko> | ||
* @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko> | ||
* @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko> | ||
* @property {Object} input The instance of inputType where the event occurred<ko>이벤트가 발생한 inputType 인스턴스</ko> | ||
* @property {setTo} setTo Specifies the animation coordinates to move after the event <ko>이벤트 이후 이동할 애니메이션 좌표를 지정한다</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("release", function(event) { | ||
* // event.depaPos | ||
* // event.destPos | ||
* // event.delta | ||
* // event.input | ||
* // event.inputEvent | ||
* // event.setTo | ||
* // event.isTrusted | ||
* | ||
* // if you want to change the animation coordinates to move after the 'release' event. | ||
* event.setTo({x: 10}, 2000); | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerRelease = function (param) { | ||
@@ -27,2 +124,38 @@ param.setTo = this.createUserControll(param.destPos, param.duration); | ||
}; | ||
/** | ||
* This event is fired when coordinate changes. | ||
* @ko 좌표가 변경됐을 때 발생하는 이벤트 | ||
* @name eg.Axes#change | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired <ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Object.<string, number>} pos The coordinate <ko>좌표</ko> | ||
* @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko> | ||
* @property {Boolean} holding Indicates whether a user holds an element on the screen of the device.<ko>사용자가 기기의 화면을 누르고 있는지 여부</ko> | ||
* @property {Object} input The instance of inputType where the event occurred. If the value is changed by animation, it returns 'null'.<ko>이벤트가 발생한 inputType 인스턴스. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko> | ||
* @property {Object} inputEvent The event object received from inputType. If the value is changed by animation, it returns 'null'.<ko>inputType으로 부터 받은 이벤트 객체. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko> | ||
* @property {set} set Specifies the coordinates to move after the event. It works when the holding value is true <ko>이벤트 이후 이동할 좌표를 지정한다. holding 값이 true일 경우에 동작한다.</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("change", function(event) { | ||
* // event.pos | ||
* // event.delta | ||
* // event.input | ||
* // event.inputEvent | ||
* // event.holding | ||
* // event.set | ||
* // event.isTrusted | ||
* | ||
* // if you want to change the coordinates to move after the 'change' event. | ||
* // it works when the holding value of the change event is true. | ||
* event.holding && event.set({x: 10}); | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerChange = function (pos, isAccurate, depaPos, option, holding) { | ||
@@ -48,2 +181,38 @@ if (holding === void 0) { holding = false; } | ||
}; | ||
/** | ||
* This event is fired when animation starts. | ||
* @ko 에니메이션이 시작할 때 발생한다. | ||
* @name eg.Axes#animationStart | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired<ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Object.<string, number>} depaPos The coordinates when animation starts<ko>애니메이션이 시작 되었을 때의 좌표 </ko> | ||
* @property {Object.<string, number>} destPos The coordinates to move to. If you change this value, you can run the animation<ko>이동할 좌표. 이값을 변경하여 애니메이션을 동작시킬수 있다</ko> | ||
* @property {Object.<string, number>} delta The movement variation of coordinate <ko>좌표의 변화량</ko> | ||
* @property {Number} duration Duration of the animation (unit: ms). If you change this value, you can control the animation duration time.<ko>애니메이션 진행 시간(단위: ms). 이값을 변경하여 애니메이션의 이동시간을 조절할 수 있다.</ko> | ||
* @property {Object} input The instance of inputType where the event occurred. If the value is changed by animation, it returns 'null'.<ko>이벤트가 발생한 inputType 인스턴스. 애니메이션에 의해 값이 변경될 경우에는 'null'을 반환한다.</ko> | ||
* @property {Object} inputEvent The event object received from inputType <ko>inputType으로 부터 받은 이벤트 객체</ko> | ||
* @property {setTo} setTo Specifies the animation coordinates to move after the event <ko>이벤트 이후 이동할 애니메이션 좌표를 지정한다</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("release", function(event) { | ||
* // event.depaPos | ||
* // event.destPos | ||
* // event.delta | ||
* // event.input | ||
* // event.inputEvent | ||
* // event.setTo | ||
* // event.isTrusted | ||
* | ||
* // if you want to change the animation coordinates to move after the 'animationStart' event. | ||
* event.setTo({x: 10}, 2000); | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerAnimationStart = function (param) { | ||
@@ -53,2 +222,22 @@ param.setTo = this.createUserControll(param.destPos, param.duration); | ||
}; | ||
/** | ||
* This event is fired when animation ends. | ||
* @ko 에니메이션이 끝났을 때 발생한다. | ||
* @name eg.Axes#animationEnd | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired<ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("animationEnd", function(event) { | ||
* // event.isTrusted | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerAnimationEnd = function (isTrusted) { | ||
@@ -60,2 +249,22 @@ if (isTrusted === void 0) { isTrusted = false; } | ||
}; | ||
/** | ||
* This event is fired when all actions have been completed. | ||
* @ko 에니메이션이 끝났을 때 발생한다. | ||
* @name eg.Axes#finish | ||
* @event | ||
* @type {object} The object of data to be sent when the event is fired<ko>이벤트가 발생할 때 전달되는 데이터 객체</ko> | ||
* @property {Boolean} isTrusted Returns true if an event was generated by the user action, or false if it was caused by a script or API call <ko>사용자의 액션에 의해 이벤트가 발생하였으면 true, 스크립트나 API호출에 의해 발생하였을 경우에는 false를 반환한다.</ko> | ||
* | ||
* @example | ||
* const axes = new eg.Axes({ | ||
* "x": { | ||
* range: [0, 100] | ||
* }, | ||
* "zoom": { | ||
* range: [50, 30] | ||
* } | ||
* }).on("finish", function(event) { | ||
* // event.isTrusted | ||
* }); | ||
*/ | ||
EventManager.prototype.triggerFinish = function (isTrusted) { | ||
@@ -69,2 +278,3 @@ if (isTrusted === void 0) { isTrusted = false; } | ||
if (duration === void 0) { duration = 0; } | ||
// to controll | ||
var userControl = { | ||
@@ -71,0 +281,0 @@ destPos: __assign({}, pos), |
import Axes from "./Axes"; | ||
export { PanInput } from "./inputType/PanInput"; | ||
export { RotatePanInput } from "./inputType/RotatePanInput"; | ||
export { PinchInput } from "./inputType/PinchInput"; | ||
@@ -4,0 +5,0 @@ export { WheelInput } from "./inputType/WheelInput"; |
import Axes from "./Axes"; | ||
import { PanInput } from "./inputType/PanInput"; | ||
import { RotatePanInput } from "./inputType/RotatePanInput"; | ||
import { PinchInput } from "./inputType/PinchInput"; | ||
@@ -7,2 +8,3 @@ import { WheelInput } from "./inputType/WheelInput"; | ||
Axes.PanInput = PanInput; | ||
Axes.RotatePanInput = RotatePanInput; | ||
Axes.PinchInput = PinchInput; | ||
@@ -9,0 +11,0 @@ Axes.WheelInput = WheelInput; |
@@ -11,3 +11,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { map, equal } from "./utils"; | ||
var InputObserver = (function () { | ||
var InputObserver = /** @class */ (function () { | ||
function InputObserver(_a) { | ||
@@ -24,2 +24,3 @@ var options = _a.options, itm = _a.itm, em = _a.em, axm = _a.axm, am = _a.am; | ||
} | ||
// when move pointer is held in outside | ||
InputObserver.prototype.atOutside = function (pos) { | ||
@@ -35,2 +36,4 @@ var _this = this; | ||
else { | ||
// when start pointer is held in inside | ||
// get a initialization slope value to prevent smooth animation. | ||
var initSlope_1 = this.am.easing(0.00001) / 0.00001; | ||
@@ -45,6 +48,6 @@ return this.axm.map(pos, function (v, opt) { | ||
} | ||
else if (v < min) { | ||
else if (v < min) { // left | ||
return min - _this.am.easing((min - v) / (out[0] * initSlope_1)) * out[0]; | ||
} | ||
else if (v > max) { | ||
else if (v > max) { // right | ||
return max + _this.am.easing((v - max) / (out[1] * initSlope_1)) * out[1]; | ||
@@ -80,4 +83,6 @@ } | ||
var destPos; | ||
// for outside logic | ||
destPos = map(depaPos, function (v, k) { return v + (offset[k] || 0); }); | ||
this.moveDistance && (this.moveDistance = destPos); | ||
// from outside to inside | ||
if (this.isOutside && | ||
@@ -117,2 +122,3 @@ this.axm.every(depaPos, function (v, opt) { return !isOutside(v, opt.range); })) { | ||
} | ||
// prepare params | ||
var param = { | ||
@@ -129,2 +135,3 @@ depaPos: depaPos, | ||
this.moveDistance = null; | ||
// to contol | ||
var userWish = this.am.getUserControll(param); | ||
@@ -131,0 +138,0 @@ var isEqual = equal(userWish.destPos, depaPos); |
@@ -24,2 +24,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
try { | ||
// create Hammer | ||
return new Manager(element, __assign({}, options)); | ||
@@ -45,2 +46,3 @@ } | ||
case "pointer": hasPointer = SUPPORT_POINTER_EVENTS; | ||
// no default | ||
} | ||
@@ -47,0 +49,0 @@ }); |
@@ -24,3 +24,26 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
var DELAY = 80; | ||
var MoveKeyInput = (function () { | ||
/** | ||
* @typedef {Object} MoveKeyInputOption The option object of the eg.Axes.MoveKeyInput module | ||
* @ko eg.Axes.MoveKeyInput 모듈의 옵션 객체 | ||
* @property {Array<Number>} [scale] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko> | ||
* @property {Number} [scale[0]=1] Coordinate scale for the first axis<ko>첫번째 축의 배율</ko> | ||
* @property {Number} [scale[1]=1] Coordinate scale for the decond axis<ko>두번째 축의 배율</ko> | ||
**/ | ||
/** | ||
* @class eg.Axes.MoveKeyInput | ||
* @classdesc A module that passes the amount of change to eg.Axes when the move key stroke is occured. use two axis. | ||
* @ko 이동키 입력이 발생했을 때의 변화량을 eg.Axes에 전달하는 모듈. 두 개 의 축을 사용한다. | ||
* | ||
* @example | ||
* const moveKey = new eg.Axes.MoveKeyInput("#area", { | ||
* scale: [1, 1] | ||
* }); | ||
* | ||
* // Connect 'x', 'y' axes when the moveKey is pressed. | ||
* axes.connect(["x", "y"], moveKey); | ||
* | ||
* @param {HTMLElement|String|jQuery} element An element to use the eg.Axes.MoveKeyInput module <ko>eg.Axes.MoveKeyInput 모듈을 사용할 엘리먼트</ko> | ||
* @param {MoveKeyInputOption} [options] The option object of the eg.Axes.MoveKeyInput module<ko>eg.Axes.MoveKeyInput 모듈의 옵션 객체</ko> | ||
*/ | ||
var MoveKeyInput = /** @class */ (function () { | ||
function MoveKeyInput(el, options) { | ||
@@ -44,2 +67,3 @@ this.axes = []; | ||
this.dettachEvent(); | ||
// add tabindex="0" to the container for making it focusable | ||
if (this.element.getAttribute("tabindex") !== "0") { | ||
@@ -55,2 +79,7 @@ this.element.setAttribute("tabindex", "0"); | ||
}; | ||
/** | ||
* Destroys elements, properties, and events used in a module. | ||
* @ko 모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다. | ||
* @method eg.Axes.MoveKeyInput#destroy | ||
*/ | ||
MoveKeyInput.prototype.destroy = function () { | ||
@@ -127,2 +156,8 @@ this.disconnect(); | ||
}; | ||
/** | ||
* Enables input devices | ||
* @ko 입력 장치를 사용할 수 있게 한다 | ||
* @method eg.Axes.MoveKeyInput#enable | ||
* @return {eg.Axes.MoveKeyInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
MoveKeyInput.prototype.enable = function () { | ||
@@ -132,2 +167,8 @@ this._isEnabled = true; | ||
}; | ||
/** | ||
* Disables input devices | ||
* @ko 입력 장치를 사용할 수 없게 한다. | ||
* @method eg.Axes.MoveKeyInput#disable | ||
* @return {eg.Axes.MoveKeyInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
MoveKeyInput.prototype.disable = function () { | ||
@@ -137,2 +178,8 @@ this._isEnabled = false; | ||
}; | ||
/** | ||
* Returns whether to use an input device | ||
* @ko 입력 장치를 사용 여부를 반환한다. | ||
* @method eg.Axes.MoveKeyInput#isEnable | ||
* @return {Boolean} Whether to use an input device <ko>입력장치 사용여부</ko> | ||
*/ | ||
MoveKeyInput.prototype.isEnable = function () { | ||
@@ -139,0 +186,0 @@ return this._isEnabled; |
@@ -12,2 +12,3 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { convertInputType, createHammer, toAxis, UNIQUEKEY } from "./InputType"; | ||
// get user's direction | ||
export function getDirectionByAngle(angle, thresholdAngle) { | ||
@@ -38,3 +39,38 @@ if (thresholdAngle < 0 || thresholdAngle > 90) { | ||
} | ||
var PanInput = (function () { | ||
/** | ||
* @typedef {Object} PanInputOption The option object of the eg.Axes.PanInput module. | ||
* @ko eg.Axes.PanInput 모듈의 옵션 객체 | ||
* @property {String[]} [inputType=["touch","mouse", "pointer"]] Types of input devices.<br>- touch: Touch screen<br>- mouse: Mouse <ko>입력 장치 종류.<br>- touch: 터치 입력 장치<br>- mouse: 마우스</ko> | ||
* @property {Number[]} [scale] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko> | ||
* @property {Number} [scale.0=1] horizontal axis scale <ko>수평축 배율</ko> | ||
* @property {Number} [scale.1=1] vertical axis scale <ko>수직축 배율</ko> | ||
* @property {Number} [thresholdAngle=45] The threshold value that determines whether user action is horizontal or vertical (0~90) <ko>사용자의 동작이 가로 방향인지 세로 방향인지 판단하는 기준 각도(0~90)</ko> | ||
* @property {Number} [threshold=0] Minimal pan distance required before recognizing <ko>사용자의 Pan 동작을 인식하기 위해산 최소한의 거리</ko> | ||
* @property {Object} [hammerManagerOptions={cssProps: {userSelect: "none",touchSelect: "none",touchCallout: "none",userDrag: "none"}] Options of Hammer.Manager <ko>Hammer.Manager의 옵션</ko> | ||
**/ | ||
/** | ||
* @class eg.Axes.PanInput | ||
* @classdesc A module that passes the amount of change to eg.Axes when the mouse or touchscreen is down and moved. use less than two axes. | ||
* @ko 마우스나 터치 스크린을 누르고 움직일때의 변화량을 eg.Axes에 전달하는 모듈. 두개 이하의 축을 사용한다. | ||
* | ||
* @example | ||
* const pan = new eg.Axes.PanInput("#area", { | ||
* inputType: ["touch"], | ||
* scale: [1, 1.3], | ||
* }); | ||
* | ||
* // Connect the 'something2' axis to the mouse or touchscreen x position when the mouse or touchscreen is down and moved. | ||
* // Connect the 'somethingN' axis to the mouse or touchscreen y position when the mouse or touchscreen is down and moved. | ||
* axes.connect(["something2", "somethingN"], pan); // or axes.connect("something2 somethingN", pan); | ||
* | ||
* // Connect only one 'something1' axis to the mouse or touchscreen x position when the mouse or touchscreen is down and moved. | ||
* axes.connect(["something1"], pan); // or axes.connect("something1", pan); | ||
* | ||
* // Connect only one 'something2' axis to the mouse or touchscreen y position when the mouse or touchscreen is down and moved. | ||
* axes.connect(["", "something2"], pan); // or axes.connect(" something2", pan); | ||
* | ||
* @param {HTMLElement|String|jQuery} element An element to use the eg.Axes.PanInput module <ko>eg.Axes.PanInput 모듈을 사용할 엘리먼트</ko> | ||
* @param {PanInputOption} [options] The option object of the eg.Axes.PanInput module<ko>eg.Axes.PanInput 모듈의 옵션 객체</ko> | ||
*/ | ||
var PanInput = /** @class */ (function () { | ||
function PanInput(el, options) { | ||
@@ -45,2 +81,10 @@ this.axes = []; | ||
this.panRecognizer = null; | ||
/** | ||
* Hammer helps you add support for touch gestures to your page | ||
* | ||
* @external Hammer | ||
* @see {@link http://hammerjs.github.io|Hammer.JS} | ||
* @see {@link http://hammerjs.github.io/jsdoc/Hammer.html|Hammer.JS API documents} | ||
* @see Hammer.JS applies specific CSS properties by {@link http://hammerjs.github.io/jsdoc/Hammer.defaults.cssProps.html|default} when creating an instance. The eg.Axes module removes all default CSS properties provided by Hammer.JS | ||
*/ | ||
if (typeof Manager === "undefined") { | ||
@@ -56,2 +100,4 @@ throw new Error("The Hammerjs must be loaded before eg.Axes.PanInput.\nhttp://hammerjs.github.io/"); | ||
hammerManagerOptions: { | ||
// css properties were removed due to usablility issue | ||
// http://hammerjs.github.io/jsdoc/Hammer.defaults.cssProps.html | ||
cssProps: { | ||
@@ -91,3 +137,4 @@ userSelect: "none", | ||
}; | ||
if (this.hammer) { | ||
if (this.hammer) { // for sharing hammer instance. | ||
// hammer remove previous PanRecognizer. | ||
this.removeRecognizer(); | ||
@@ -123,2 +170,7 @@ this.dettachEvent(); | ||
}; | ||
/** | ||
* Destroys elements, properties, and events used in a module. | ||
* @ko 모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다. | ||
* @method eg.Axes.PanInput#destroy | ||
*/ | ||
PanInput.prototype.destroy = function () { | ||
@@ -133,2 +185,8 @@ this.disconnect(); | ||
}; | ||
/** | ||
* Enables input devices | ||
* @ko 입력 장치를 사용할 수 있게 한다 | ||
* @method eg.Axes.PanInput#enable | ||
* @return {eg.Axes.PanInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
PanInput.prototype.enable = function () { | ||
@@ -138,2 +196,8 @@ this.hammer && (this.hammer.get("pan").options.enable = true); | ||
}; | ||
/** | ||
* Disables input devices | ||
* @ko 입력 장치를 사용할 수 없게 한다. | ||
* @method eg.Axes.PanInput#disable | ||
* @return {eg.Axes.PanInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
PanInput.prototype.disable = function () { | ||
@@ -143,2 +207,8 @@ this.hammer && (this.hammer.get("pan").options.enable = false); | ||
}; | ||
/** | ||
* Returns whether to use an input device | ||
* @ko 입력 장치를 사용 여부를 반환한다. | ||
* @method eg.Axes.PanInput#isEnable | ||
* @return {Boolean} Whether to use an input device <ko>입력장치 사용여부</ko> | ||
*/ | ||
PanInput.prototype.isEnable = function () { | ||
@@ -165,3 +235,5 @@ return !!(this.hammer && this.hammer.get("pan").options.enable); | ||
var userDirection = getDirectionByAngle(event.angle, this.options.thresholdAngle); | ||
// not support offset properties in Hammerjs - start | ||
var prevInput = this.hammer.session.prevInput; | ||
/* eslint-disable no-param-reassign */ | ||
if (prevInput) { | ||
@@ -168,0 +240,0 @@ event.offsetX = event.deltaX - prevInput.deltaX; |
@@ -12,3 +12,25 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { UNIQUEKEY, toAxis, convertInputType, createHammer } from "./InputType"; | ||
var PinchInput = (function () { | ||
/** | ||
* @typedef {Object} PinchInputOption The option object of the eg.Axes.PinchInput module | ||
* @ko eg.Axes.PinchInput 모듈의 옵션 객체 | ||
* @property {Number} [scale=1] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko> | ||
* @property {Number} [threshold=0] Minimal scale before recognizing <ko>사용자의 Pinch 동작을 인식하기 위해산 최소한의 배율</ko> | ||
* @property {Object} [hammerManagerOptions={cssProps: {userSelect: "none",touchSelect: "none",touchCallout: "none",userDrag: "none"}] Options of Hammer.Manager <ko>Hammer.Manager의 옵션</ko> | ||
**/ | ||
/** | ||
* @class eg.Axes.PinchInput | ||
* @classdesc A module that passes the amount of change to eg.Axes when two pointers are moving toward (zoom-in) or away from each other (zoom-out). use one axis. | ||
* @ko 2개의 pointer를 이용하여 zoom-in하거나 zoom-out 하는 동작의 변화량을 eg.Axes에 전달하는 모듈. 한 개 의 축을 사용한다. | ||
* @example | ||
* const pinch = new eg.Axes.PinchInput("#area", { | ||
* scale: 1 | ||
* }); | ||
* | ||
* // Connect 'something' axis when two pointers are moving toward (zoom-in) or away from each other (zoom-out). | ||
* axes.connect("something", pinch); | ||
* | ||
* @param {HTMLElement|String|jQuery} element An element to use the eg.Axes.PinchInput module <ko>eg.Axes.PinchInput 모듈을 사용할 엘리먼트</ko> | ||
* @param {PinchInputOption} [options] The option object of the eg.Axes.PinchInput module<ko>eg.Axes.PinchInput 모듈의 옵션 객체</ko> | ||
*/ | ||
var PinchInput = /** @class */ (function () { | ||
function PinchInput(el, options) { | ||
@@ -21,2 +43,10 @@ this.axes = []; | ||
this.pinchRecognizer = null; | ||
/** | ||
* Hammer helps you add support for touch gestures to your page | ||
* | ||
* @external Hammer | ||
* @see {@link http://hammerjs.github.io|Hammer.JS} | ||
* @see {@link http://hammerjs.github.io/jsdoc/Hammer.html|Hammer.JS API documents} | ||
* @see Hammer.JS applies specific CSS properties by {@link http://hammerjs.github.io/jsdoc/Hammer.defaults.cssProps.html|default} when creating an instance. The eg.Axes module removes all default CSS properties provided by Hammer.JS | ||
*/ | ||
if (typeof Manager === "undefined") { | ||
@@ -31,2 +61,4 @@ throw new Error("The Hammerjs must be loaded before eg.Axes.PinchInput.\nhttp://hammerjs.github.io/"); | ||
hammerManagerOptions: { | ||
// css properties were removed due to usablility issue | ||
// http://hammerjs.github.io/jsdoc/Hammer.defaults.cssProps.html | ||
cssProps: { | ||
@@ -49,3 +81,4 @@ userSelect: "none", | ||
var hammerOption = { threshold: this.options.threshold }; | ||
if (this.hammer) { | ||
if (this.hammer) { // for sharing hammer instance. | ||
// hammer remove previous PinchRecognizer. | ||
this.removeRecognizer(); | ||
@@ -82,2 +115,7 @@ this.dettachEvent(); | ||
}; | ||
/** | ||
* Destroys elements, properties, and events used in a module. | ||
* @ko 모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다. | ||
* @method eg.Axes.PinchInput#destroy | ||
*/ | ||
PinchInput.prototype.destroy = function () { | ||
@@ -134,2 +172,8 @@ this.disconnect(); | ||
}; | ||
/** | ||
* Enables input devices | ||
* @ko 입력 장치를 사용할 수 있게 한다 | ||
* @method eg.Axes.PinchInput#enable | ||
* @return {eg.Axes.PinchInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
PinchInput.prototype.enable = function () { | ||
@@ -139,2 +183,8 @@ this.hammer && (this.hammer.get("pinch").options.enable = true); | ||
}; | ||
/** | ||
* Disables input devices | ||
* @ko 입력 장치를 사용할 수 없게 한다. | ||
* @method eg.Axes.PinchInput#disable | ||
* @return {eg.Axes.PinchInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
PinchInput.prototype.disable = function () { | ||
@@ -144,2 +194,8 @@ this.hammer && (this.hammer.get("pinch").options.enable = false); | ||
}; | ||
/** | ||
* Returns whether to use an input device | ||
* @ko 입력 장치를 사용 여부를 반환한다. | ||
* @method eg.Axes.PinchInput#isEnable | ||
* @return {Boolean} Whether to use an input device <ko>입력장치 사용여부</ko> | ||
*/ | ||
PinchInput.prototype.isEnable = function () { | ||
@@ -146,0 +202,0 @@ return !!(this.hammer && this.hammer.get("pinch").options.enable); |
@@ -11,3 +11,24 @@ var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
import { toAxis } from "./InputType"; | ||
var WheelInput = (function () { | ||
/** | ||
* @typedef {Object} WheelInputOption The option object of the eg.Axes.WheelInput module | ||
* @ko eg.Axes.WheelInput 모듈의 옵션 객체 | ||
* @property {Number} [scale=1] Coordinate scale that a user can move<ko>사용자의 동작으로 이동하는 좌표의 배율</ko> | ||
**/ | ||
/** | ||
* @class eg.Axes.WheelInput | ||
* @classdesc A module that passes the amount of change to eg.Axes when the mouse wheel is moved. use one axis. | ||
* @ko 마우스 휠이 움직일때의 변화량을 eg.Axes에 전달하는 모듈. 한 개 의 축을 사용한다. | ||
* | ||
* @example | ||
* const wheel = new eg.Axes.WheelInput("#area", { | ||
* scale: 1 | ||
* }); | ||
* | ||
* // Connect 'something' axis when the mousewheel is moved. | ||
* axes.connect("something", wheel); | ||
* | ||
* @param {HTMLElement|String|jQuery} element An element to use the eg.Axes.WheelInput module <ko>eg.Axes.WheelInput 모듈을 사용할 엘리먼트</ko> | ||
* @param {WheelInputOption} [options] The option object of the eg.Axes.WheelInput module<ko>eg.Axes.WheelInput 모듈의 옵션 객체</ko> | ||
*/ | ||
var WheelInput = /** @class */ (function () { | ||
function WheelInput(el, options) { | ||
@@ -38,2 +59,7 @@ this.axes = []; | ||
}; | ||
/** | ||
* Destroys elements, properties, and events used in a module. | ||
* @ko 모듈에 사용한 엘리먼트와 속성, 이벤트를 해제한다. | ||
* @method eg.Axes.WheelInput#destroy | ||
*/ | ||
WheelInput.prototype.destroy = function () { | ||
@@ -81,2 +107,8 @@ this.disconnect(); | ||
}; | ||
/** | ||
* Enables input devices | ||
* @ko 입력 장치를 사용할 수 있게 한다 | ||
* @method eg.Axes.WheelInput#enable | ||
* @return {eg.Axes.WheelInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
WheelInput.prototype.enable = function () { | ||
@@ -86,2 +118,8 @@ this._isEnabled = true; | ||
}; | ||
/** | ||
* Disables input devices | ||
* @ko 입력 장치를 사용할 수 없게 한다. | ||
* @method eg.Axes.WheelInput#disable | ||
* @return {eg.Axes.WheelInput} An instance of a module itself <ko>모듈 자신의 인스턴스</ko> | ||
*/ | ||
WheelInput.prototype.disable = function () { | ||
@@ -91,2 +129,8 @@ this._isEnabled = false; | ||
}; | ||
/** | ||
* Returns whether to use an input device | ||
* @ko 입력 장치를 사용 여부를 반환한다. | ||
* @method eg.Axes.WheelInput#isEnable | ||
* @return {Boolean} Whether to use an input device <ko>입력장치 사용여부</ko> | ||
*/ | ||
WheelInput.prototype.isEnable = function () { | ||
@@ -93,0 +137,0 @@ return this._isEnabled; |
@@ -1,7 +0,8 @@ | ||
var InterruptManager = (function () { | ||
var InterruptManager = /** @class */ (function () { | ||
function InterruptManager(options) { | ||
this.options = options; | ||
this._prevented = false; | ||
this._prevented = false; // check whether the animation event was prevented | ||
} | ||
InterruptManager.prototype.isInterrupting = function () { | ||
// when interruptable is 'true', return value is always 'true'. | ||
return this.options.interruptable || this._prevented; | ||
@@ -8,0 +9,0 @@ }; |
import { window } from "./browser"; | ||
import { FIXED_DIGIT } from "./const"; | ||
export function toArray(nodes) { | ||
// const el = Array.prototype.slice.call(nodes); | ||
// for IE8 | ||
var el = []; | ||
@@ -13,5 +15,7 @@ for (var i = 0, len = nodes.length; i < len; i++) { | ||
var el; | ||
if (typeof param === "string") { | ||
if (typeof param === "string") { // String (HTML, Selector) | ||
// check if string is HTML tag format | ||
var match = param.match(/^<([a-z]+)\s*([^>]*)>/); | ||
if (match) { | ||
// creating element | ||
if (match) { // HTML | ||
var dummy = document.createElement("div"); | ||
@@ -21,3 +25,3 @@ dummy.innerHTML = param; | ||
} | ||
else { | ||
else { // Selector | ||
el = toArray(document.querySelectorAll(param)); | ||
@@ -29,11 +33,11 @@ } | ||
} | ||
else if (param === window) { | ||
else if (param === window) { // window | ||
el = param; | ||
} | ||
else if (param.nodeName && | ||
(param.nodeType === 1 || param.nodeType === 9)) { | ||
(param.nodeType === 1 || param.nodeType === 9)) { // HTMLElement, Document | ||
el = param; | ||
} | ||
else if (("jQuery" in window && param instanceof jQuery) || | ||
param.constructor.prototype.jquery) { | ||
param.constructor.prototype.jquery) { // jQuery | ||
el = multi ? param.toArray() : param.get(0); | ||
@@ -76,8 +80,22 @@ } | ||
} | ||
/** | ||
* A polyfill for the window.requestAnimationFrame() method. | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame | ||
* @private | ||
*/ | ||
export function requestAnimationFrame(fp) { | ||
return raf(fp); | ||
} | ||
/** | ||
* A polyfill for the window.cancelAnimationFrame() method. It cancels an animation executed through a call to the requestAnimationFrame() method. | ||
* @param {Number} key − The ID value returned through a call to the requestAnimationFrame() method. <ko>requestAnimationFrame() 메서드가 반환한 아이디 값</ko> | ||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/cancelAnimationFrame | ||
* @private | ||
*/ | ||
export function cancelAnimationFrame(key) { | ||
caf(key); | ||
} | ||
export function mapToFixed(obj) { | ||
return map(obj, function (value) { return toFixed(value); }); | ||
} | ||
export function map(obj, callback) { | ||
@@ -84,0 +102,0 @@ var tranformed = {}; |
{ | ||
"name": "@egjs/axes", | ||
"version": "2.5.12", | ||
"version": "2.5.13", | ||
"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, |
@@ -6,3 +6,3 @@ import { IInputType } from "./inputType/InputType"; | ||
import { EventManager, ChangeEventOption } from "./EventManager"; | ||
import { requestAnimationFrame, cancelAnimationFrame, map, every, filter, equal, toFixed } from "./utils"; | ||
import { requestAnimationFrame, cancelAnimationFrame, map, every, filter, equal, toFixed, mapToFixed } from "./utils"; | ||
import { AxesOption } from "./Axes"; | ||
@@ -50,3 +50,3 @@ | ||
(v, k) => getDuration( | ||
Math.abs(Math.abs(v) - Math.abs(depaPos[k])), | ||
Math.abs(v - depaPos[k]), | ||
this.options.deceleration), | ||
@@ -146,11 +146,31 @@ ); | ||
let prevPos = info.depaPos; | ||
let prevEasingPer = 0; | ||
const directions = map(prevPos, (value, key) => { | ||
return value <= info.destPos[key] ? 1 : -1; | ||
}); | ||
let prevTime = new Date().getTime(); | ||
info.startTime = prevTime; | ||
info.startTime = new Date().getTime(); | ||
(function loop() { | ||
self._raf = null; | ||
const easingPer = self.easing((new Date().getTime() - info.startTime) / param.duration); | ||
const toPos: Axis = map(info.depaPos, (pos, key) => pos + info.delta[key] * easingPer); | ||
const isCanceled = !self.em.triggerChange(toPos, false, prevPos); | ||
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)); | ||
prevPos = map(toPos, v => toFixed(v)); | ||
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) { | ||
// circular | ||
param.destPos[key] += -directions[key] * (options.range[1] - options.range[0]); | ||
prevPos[key] += -directions[key] * (options.range[1] - options.range[0]); | ||
} | ||
return nextPos; | ||
}); | ||
const isCanceled = !self.em.triggerChange(toPos, false, mapToFixed(prevPos)); | ||
prevPos = toPos; | ||
prevTime = currentTime; | ||
prevEasingPer = easingPer; | ||
if (easingPer >= 1) { | ||
@@ -160,3 +180,3 @@ const destPos = param.destPos; | ||
if (!equal(destPos, self.axm.get(Object.keys(destPos)))) { | ||
self.em.triggerChange(destPos, true, prevPos); | ||
self.em.triggerChange(destPos, true, mapToFixed(prevPos)); | ||
} | ||
@@ -236,3 +256,3 @@ complete(); | ||
movedPos = this.axm.map(movedPos, (v, opt) => { | ||
const {range, circular} = opt; | ||
const { range, circular } = opt; | ||
@@ -239,0 +259,0 @@ if (circular && (circular[0] || circular[1])) { |
@@ -132,2 +132,3 @@ import Component from "@egjs/component"; | ||
static MoveKeyInput; | ||
static RotatePanInput; | ||
@@ -202,3 +203,3 @@ /** | ||
constructor(public axis: { [key: string]: AxisOption } = {}, options: AxesOption, startPos?: Axis) { | ||
constructor(public axis: { [key: string]: AxisOption } = {}, options: AxesOption = {}, startPos?: Axis) { | ||
super(); | ||
@@ -205,0 +206,0 @@ this.options = { |
@@ -97,8 +97,8 @@ import { isOutside, getCirculatedPos } from "./Coordinate"; | ||
} | ||
map( | ||
map<U>( | ||
pos: Axis, | ||
callback: (value: number, options: AxisOption, key: string) => number): Axis { | ||
callback: (value: number, options: AxisOption, key: string) => U) { | ||
const axisOptions = this.axis; | ||
return map(pos, (value, key) => callback(value, axisOptions[key], key)); | ||
return map<number, U>(pos, (value, key) => callback(value, axisOptions[key], key)); | ||
} | ||
@@ -105,0 +105,0 @@ isOutside(axes?: string[]) { |
import Axes from "./Axes"; | ||
export { PanInput } from "./inputType/PanInput"; | ||
export { RotatePanInput } from "./inputType/RotatePanInput"; | ||
export { PinchInput } from "./inputType/PinchInput"; | ||
@@ -4,0 +5,0 @@ export { WheelInput } from "./inputType/WheelInput"; |
import Axes from "./Axes"; | ||
import { PanInput } from "./inputType/PanInput"; | ||
import { RotatePanInput } from "./inputType/RotatePanInput"; | ||
import { PinchInput } from "./inputType/PinchInput"; | ||
@@ -8,2 +9,3 @@ import { WheelInput } from "./inputType/WheelInput"; | ||
Axes.PanInput = PanInput; | ||
Axes.RotatePanInput = RotatePanInput; | ||
Axes.PinchInput = PinchInput; | ||
@@ -10,0 +12,0 @@ Axes.WheelInput = WheelInput; |
@@ -88,4 +88,4 @@ import Hammer, { DIRECTION_ALL, DIRECTION_HORIZONTAL, DIRECTION_NONE, DIRECTION_VERTICAL, Manager, Pan } from "@egjs/hammerjs"; | ||
element: HTMLElement = null; | ||
private observer: IInputTypeObserver; | ||
private _direction; | ||
protected observer: IInputTypeObserver; | ||
protected _direction; | ||
private panRecognizer = null; | ||
@@ -237,3 +237,3 @@ | ||
private onHammerInput(event) { | ||
protected onHammerInput(event) { | ||
if (this.isEnable()) { | ||
@@ -248,3 +248,3 @@ if (event.isFirst) { | ||
private onPanmove(event) { | ||
protected onPanmove(event) { | ||
const userDirection = getDirectionByAngle( | ||
@@ -279,3 +279,3 @@ event.angle, this.options.thresholdAngle); | ||
private onPanend(event) { | ||
protected onPanend(event) { | ||
let offset: number[] = this.getOffset( | ||
@@ -282,0 +282,0 @@ [ |
@@ -97,3 +97,5 @@ import {window} from "./browser"; | ||
} | ||
export function mapToFixed(obj: ObjectInterface<number>) { | ||
return map(obj, value => toFixed(value)); | ||
} | ||
export function map<T, U>(obj: ObjectInterface<T>, callback: (value: T, key: string) => U): ObjectInterface<U> { | ||
@@ -100,0 +102,0 @@ const tranformed: ObjectInterface<U> = {}; |
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
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
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
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
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
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
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
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
1680423
90
15290