gesture-helper
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -346,2 +346,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var deltaTime = (0, _performanceNow2.default)() - _this.startTime; | ||
_this.emit('pan.preend', { sourceEvent: e }); | ||
if (_this.panning) { | ||
@@ -348,0 +350,0 @@ _this.panning = false; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("GestureHelper",[],t):"object"==typeof exports?exports.GestureHelper=t():e.GestureHelper=t()}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}([function(e,t){var n,i,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var l,c=[],h=!1,u=-1;function p(){h&&l&&(h=!1,l.length?c=l.concat(c):u=-1,c.length&&f())}function f(){if(!h){var e=a(p);h=!0;for(var t=c.length;t;){for(l=c,c=[];++u<t;)l&&l[u].run();u=-1,t=c.length}l=null,h=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function d(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new v(e,t)),1!==c.length||h||a(f)},v.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=d,r.addListener=d,r.once=d,r.off=d,r.removeListener=d,r.removeAllListeners=d,r.emit=d,r.prependListener=d,r.prependOnceListener=d,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(e,t,n){"use strict";t.__esModule=!0;var i=s(n(2)),r=s(n(3));function s(e){return e&&e.__esModule?e:{default:e}}(0,s(n(4)).default)(window);var o=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,{wildcard:!0}));n.mouseMove=function(e){n.handleMove({e:e,x:e.clientX,y:e.clientY})},n.touchMove=function(e){n.handleMove({e:e,x:e.touches[0].clientX,y:e.touches[0].clientY})},n.touchStart=function(e){n.handleStart({x:e.touches[0].clientX,y:e.touches[0].clientY,e:e}),n.el.addEventListener("touchmove",n.touchMove,n.eventOptions)},n.touchEnd=function(e){n.handleEnd(e),n.el.removeEventListener("touchmove",n.touchMove,n.eventOptions)},n.mouseDown=function(e){e.sourceCapabilities.firesTouchEvents||(n.handleStart({x:e.clientX,y:e.clientY,e:e}),n.el.addEventListener("mousemove",n.mouseMove,n.eventOptions))},n.mouseUp=function(e){e.sourceCapabilities.firesTouchEvents||(n.handleEnd(e),n.el.removeEventListener("mousemove",n.mouseMove,n.eventOptions))},n.handleEnd=function(e){var t=(0,r.default)()-n.startTime;if(n.panning){n.panning=!1;var i=!1,s=null;n.velocity.max.x>n.options.swipeVelocity&&"horizontal"===n.startDirection?(i=!0,s=n.velocity.current.x>0?"right":"left"):n.velocity.max.y>n.options.swipeVelocity&&"vertical"===n.startDirection&&(i=!0,s=n.velocity.current.y>0?"down":"up"),n.emit("pan.end",{isSwipe:i,swipeDirection:s,sourceEvent:e})}else t<=n.options.maxTapDuration&&n.emit("tap",{srcEvent:e})},n.el=arguments.length<=0?void 0:arguments[0],n.options=Object.assign({},{sensitivity:5,passive:!1,capture:!1,swipeVelocity:.7,maxTapDuration:300,longTapDuration:400,startDirectionLoopCount:2},(arguments.length<=1?void 0:arguments[1])||{}),n.panning=!1,n.startDirection=null,n.directionCount=0,n.clearVelocityStats(),n.eventOptions=!1;try{var i=Object.defineProperty({},"passive",{get:function(){n.eventOptions={passive:!!n.options.passive,capture:!!n.options.capture}}});n.el.addEventListener("test",null,i)}catch(e){n.eventOptions={capture:!!n.options.capture}}return n.setup(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.clearVelocityStats=function(){this.velocity={current:{x:0,y:0},max:{x:0,y:0}}},t.prototype.isPanning=function(){return this.panning},t.prototype.setup=function(){this.el.addEventListener("mousedown",this.mouseDown,this.eventOptions),this.el.addEventListener("mouseup",this.mouseUp,this.eventOptions),this.el.addEventListener("touchstart",this.touchStart,this.eventOptions),this.el.addEventListener("touchend",this.touchEnd,this.eventOptions),this.el.addEventListener("touchcancel",this.touchEnd,this.eventOptions)},t.prototype.destroy=function(){this.el.removeEventListener("mousedown",this.mouseDown,this.eventOptions),this.el.removeEventListener("mouseup",this.mouseUp,this.eventOptions),this.el.removeEventListener("mousemove",this.mouseMove,this.eventOptions),this.el.removeEventListener("touchstart",this.touchStart,this.eventOptions),this.el.removeEventListener("touchend",this.touchEnd,this.eventOptions),this.el.removeEventListener("touchcancel",this.touchEnd,this.eventOptions),this.el.removeEventListener("touchmove",this.touchMove,this.eventOptions)},t.prototype.getStartDirection=function(e){var t=e.x,n=void 0===t?0:t,i=e.y,r=void 0===i?0:i;return this.directionCount<=this.options.startDirectionLoopCount?(this.directionCount++,null):Math.abs(n)>Math.abs(r)?"horizontal":"vertical"},t.prototype.handleStart=function(e){var t=e.x,n=void 0===t?0:t,i=e.y,s=void 0===i?0:i,o=e.e,a=void 0===o?{}:o;this.startX=n,this.startY=s,this.startDirection=null,this.directionCount=1,this.panning=!1,this.startTime=(0,r.default)(),this.clearVelocityStats(),this.emit("pan.prestart",{sourceEvent:a})},t.prototype.handleMove=function(e){var t=e.e,n=void 0===t?{}:t,i=e.x,s=void 0===i?0:i,o=e.y,a=void 0===o?0:o,l=s-this.startX,c=a-this.startY;if(null===this.startDirection?this.startDirection=this.getStartDirection({x:l,y:c}):!this.panning&&(Math.abs(l)>this.options.sensitivity||Math.abs(c)>this.options.sensitivity)&&(this.panning=!0,this.emit("pan.start",{startDirection:this.startDirection,sourceEvent:n})),this.panning){this.emit("pan.all",{startDirection:this.startDirection,deltaX:l,deltaY:c,sourceEvent:n}),"horizontal"===this.startDirection?l<0?this.emit("pan.x.left",{delta:l,sourceEvent:n}):this.emit("pan.x.right",{delta:l,sourceEvent:n}):"vertical"===this.startDirection&&(c<0?this.emit("pan.y.up",{delta:c,sourceEvent:n}):this.emit("pan.y.down",{delta:c,sourceEvent:n}));var h=(0,r.default)()-this.startTime;this.velocity.current.x=l/h,this.velocity.current.y=c/h,this.velocity.max.x=Math.max(this.velocity.max.x,Math.abs(this.velocity.current.x)),this.velocity.max.y=Math.max(this.velocity.max.y,Math.abs(this.velocity.current.y))}},t}(i.default);t.default=o},function(e,t,n){(function(i){var r;!function(s){var o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;function l(){this._events={},this._conf&&c.call(this,this._conf)}function c(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._maxListeners=e.maxListeners!==s?e.maxListeners:a,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._maxListeners=a}function h(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),void 0!==i&&i.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,i.emitWarning(r)}else console.trace}function u(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,e)}function p(e,t,n,i){if(!n)return[];var r,s,o,a,l,c,h,u=[],f=t.length,v=t[i],d=t[i+1];if(i===f&&n._listeners){if("function"==typeof n._listeners)return e&&e.push(n._listeners),[n];for(r=0,s=n._listeners.length;r<s;r++)e&&e.push(n._listeners[r]);return[n]}if("*"===v||"**"===v||n[v]){if("*"===v){for(o in n)"_listeners"!==o&&n.hasOwnProperty(o)&&(u=u.concat(p(e,t,n[o],i+1)));return u}if("**"===v){for(o in(h=i+1===f||i+2===f&&"*"===d)&&n._listeners&&(u=u.concat(p(e,t,n,f))),n)"_listeners"!==o&&n.hasOwnProperty(o)&&("*"===o||"**"===o?(n[o]._listeners&&!h&&(u=u.concat(p(e,t,n[o],f))),u=u.concat(p(e,t,n[o],i))):u=o===d?u.concat(p(e,t,n[o],i+2)):u.concat(p(e,t,n[o],i)));return u}u=u.concat(p(e,t,n[v],i+1))}if((a=n["*"])&&p(e,t,a,i+1),l=n["**"])if(i<f)for(o in l._listeners&&p(e,t,l,f),l)"_listeners"!==o&&l.hasOwnProperty(o)&&(o===d?p(e,t,l[o],i+2):o===v?p(e,t,l[o],i+1):((c={})[o]=l[o],p(e,t,{"**":c},i+1)));else l._listeners?p(e,t,l,f):l["*"]&&l["*"]._listeners&&p(e,t,l["*"],f);return u}u.EventEmitter2=u,u.prototype.delimiter=".",u.prototype.setMaxListeners=function(e){e!==s&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},u.prototype.event="",u.prototype.once=function(e,t){return this._once(e,t,!1)},u.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},u.prototype._once=function(e,t,n){return this._many(e,1,t,n),this},u.prototype.many=function(e,t,n){return this._many(e,t,n,!1)},u.prototype.prependMany=function(e,t,n){return this._many(e,t,n,!0)},u.prototype._many=function(e,t,n,i){var r=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&r.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,i),r},u.prototype.emit=function(){this._events||l.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return!1;var t,n,i,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r<o;r++)t[r]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,o){case 1:s[i].call(this,e);break;case 2:s[i].call(this,e,arguments[1]);break;case 3:s[i].call(this,e,arguments[1],arguments[2]);break;default:s[i].apply(this,t)}}if(this.wildcard){s=[];var a="string"==typeof e?e.split(this.delimiter):e.slice();p.call(this,s,a,this.listenerTree,0)}else{if("function"==typeof(s=this._events[e])){switch(this.event=e,o){case 1:s.call(this);break;case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(o-1),r=1;r<o;r++)t[r-1]=arguments[r];s.apply(this,t)}return!0}s&&(s=s.slice())}if(s&&s.length){if(o>3)for(t=new Array(o-1),r=1;r<o;r++)t[r-1]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,o){case 1:s[i].call(this);break;case 2:s[i].call(this,arguments[1]);break;case 3:s[i].call(this,arguments[1],arguments[2]);break;default:s[i].apply(this,t)}return!0}if(!this._all&&"error"===e)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},u.prototype.emitAsync=function(){this._events||l.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);var t,n,i,r,s,o=[],a=arguments.length;if(this._all){if(a>3)for(t=new Array(a),r=1;r<a;r++)t[r]=arguments[r];for(i=0,n=this._all.length;i<n;i++)switch(this.event=e,a){case 1:o.push(this._all[i].call(this,e));break;case 2:o.push(this._all[i].call(this,e,arguments[1]));break;case 3:o.push(this._all[i].call(this,e,arguments[1],arguments[2]));break;default:o.push(this._all[i].apply(this,t))}}if(this.wildcard){s=[];var c="string"==typeof e?e.split(this.delimiter):e.slice();p.call(this,s,c,this.listenerTree,0)}else s=this._events[e];if("function"==typeof s)switch(this.event=e,a){case 1:o.push(s.call(this));break;case 2:o.push(s.call(this,arguments[1]));break;case 3:o.push(s.call(this,arguments[1],arguments[2]));break;default:for(t=new Array(a-1),r=1;r<a;r++)t[r-1]=arguments[r];o.push(s.apply(this,t))}else if(s&&s.length){if(s=s.slice(),a>3)for(t=new Array(a-1),r=1;r<a;r++)t[r-1]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,a){case 1:o.push(s[i].call(this));break;case 2:o.push(s[i].call(this,arguments[1]));break;case 3:o.push(s[i].call(this,arguments[1],arguments[2]));break;default:o.push(s[i].apply(this,t))}}else if(!this._all&&"error"===e)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(o)},u.prototype.on=function(e,t){return this._on(e,t,!1)},u.prototype.prependListener=function(e,t){return this._on(e,t,!0)},u.prototype.onAny=function(e){return this._onAny(e,!1)},u.prototype.prependAny=function(e){return this._onAny(e,!0)},u.prototype.addListener=u.prototype.on,u.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},u.prototype._on=function(e,t,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");return this._events||l.call(this),this._newListener&&this.emit("newListener",e,t),this.wildcard?(function(e,t){for(var n=0,i=(e="string"==typeof e?e.split(this.delimiter):e.slice()).length;n+1<i;n++)if("**"===e[n]&&"**"===e[n+1])return;for(var r=this.listenerTree,o=e.shift();o!==s;){if(r[o]||(r[o]={}),r=r[o],0===e.length)return r._listeners?("function"==typeof r._listeners&&(r._listeners=[r._listeners]),r._listeners.push(t),!r._listeners.warned&&this._maxListeners>0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,h.call(this,r._listeners.length,o))):r._listeners=t,!0;o=e.shift()}return!0}.call(this,e,t),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=t,this)},u.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();i=p.call(this,null,r,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var a=0;a<i.length;a++){var l=i[a];if(n=l._listeners,o(n)){for(var c=-1,h=0,u=n.length;h<u;h++)if(n[h]===t||n[h].listener&&n[h].listener===t||n[h]._origin&&n[h]._origin===t){c=h;break}if(c<0)continue;return this.wildcard?l._listeners.splice(c,1):this._events[e].splice(c,1),0===n.length&&(this.wildcard?delete l._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete l._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return function e(t){if(t!==s){var n=Object.keys(t);for(var i in n){var r=n[i],o=t[r];o instanceof Function||"object"!=typeof o||null===o||(Object.keys(o).length>0&&e(t[r]),0===Object.keys(o).length&&delete t[r])}}}(this.listenerTree),this},u.prototype.offAny=function(e){var t,n=0,i=0;if(e&&this._all&&this._all.length>0){for(n=0,i=(t=this._all).length;n<i;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,i=t.length;n<i;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},u.prototype.removeListener=u.prototype.off,u.prototype.removeAllListeners=function(e){if(e===s)return!this._events||l.call(this),this;if(this.wildcard)for(var t="string"==typeof e?e.split(this.delimiter):e.slice(),n=p.call(this,null,t,this.listenerTree,0),i=0;i<n.length;i++){n[i]._listeners=null}else this._events&&(this._events[e]=null);return this},u.prototype.listeners=function(e){if(this.wildcard){var t=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return p.call(this,t,n,this.listenerTree,0),t}return this._events||l.call(this),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]},u.prototype.eventNames=function(){return Object.keys(this._events)},u.prototype.listenerCount=function(e){return this.listeners(e).length},u.prototype.listenersAny=function(){return this._all?this._all:[]},(r=function(){return u}.call(t,n,t,e))===s||(e.exports=r)}()}).call(t,n(0))},function(e,t,n){(function(t){(function(){var n,i,r,s,o,a;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:void 0!==t&&null!==t&&t.hrtime?(e.exports=function(){return(n()-o)/1e6},i=t.hrtime,s=(n=function(){var e;return 1e9*(e=i())[0]+e[1]})(),a=1e9*t.uptime(),o=s-a):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)}).call(t,n(0))},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e){if(!("InputDeviceCapabilities"in e||"sourceCapabilities"in UIEvent.prototype)){c.prototype={get firesTouchEvents(){return this.__firesTouchEvents}},e.InputDeviceCapabilities=c;var t,n=new c({firesTouchEvents:!0}),i=new c({firesTouchEvents:!1});document.addEventListener("touchstart",h,!0),document.addEventListener("touchmove",h,!0),document.addEventListener("touchend",h,!0),document.addEventListener("touchcancel",h,!0);var r="__inputDeviceCapabilitiesPolyfill_specifiedSourceCapabilities",s=["resize","error","load","unload","abort"];Object.defineProperty(UIEvent.prototype,"sourceCapabilities",{get:function(){if(r in this)return this[r];if(s.indexOf(this.type)>=0)return null;if(!("TouchEvent"in e))return i;if(this instanceof TouchEvent)return n;if("PointerEvent"in e&&this instanceof PointerEvent)return"touch"==this.pointerType?n:i;var o=Date.now()<t+1e3?n:i;return Object.defineProperty(this,r,{value:o,writable:!1}),o},configurable:!0,enumerable:!0});for(var o=["UIEvent","MouseEvent","TouchEvent","InputEvent","CompositionEvent","FocusEvent","KeyboardEvent","WheelEvent","PointerEvent"],a=0;a<o.length;a++)u(o[a]);var l=Document.prototype.createEvent;Document.prototype.createEvent=function(e){var t=l.call(this,e);if(t instanceof UIEvent)return Object.defineProperty(t,r,{value:null,writable:!1}),t}}function c(e){Object.defineProperty(this,"__firesTouchEvents",{value:!!(e&&"firesTouchEvents"in e)&&e.firesTouchEvents,writable:!1,enumerable:!1})}function h(e){t=Date.now()}function u(t){if(t in e&&"length"in e[t]&&!(e[t].length<1)){var n=e[t];e[t]=function(e,t){var i=t&&t.sourceCapabilities?t.sourceCapabilities:null;t&&delete t.sourceCapabilities;var s=new n(e,t);return Object.defineProperty(s,r,{value:i,writable:!1}),s},e[t].prototype=n.prototype}}}}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("GestureHelper",[],t):"object"==typeof exports?exports.GestureHelper=t():e.GestureHelper=t()}(this,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}([function(e,t){var n,i,r=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{i="function"==typeof clearTimeout?clearTimeout:o}catch(e){i=o}}();var l,c=[],h=!1,u=-1;function p(){h&&l&&(h=!1,l.length?c=l.concat(c):u=-1,c.length&&f())}function f(){if(!h){var e=a(p);h=!0;for(var t=c.length;t;){for(l=c,c=[];++u<t;)l&&l[u].run();u=-1,t=c.length}l=null,h=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===o||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function d(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new v(e,t)),1!==c.length||h||a(f)},v.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=d,r.addListener=d,r.once=d,r.off=d,r.removeListener=d,r.removeAllListeners=d,r.emit=d,r.prependListener=d,r.prependOnceListener=d,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},function(e,t,n){"use strict";t.__esModule=!0;var i=s(n(2)),r=s(n(3));function s(e){return e&&e.__esModule?e:{default:e}}(0,s(n(4)).default)(window);var o=function(e){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,e.call(this,{wildcard:!0}));n.mouseMove=function(e){n.handleMove({e:e,x:e.clientX,y:e.clientY})},n.touchMove=function(e){n.handleMove({e:e,x:e.touches[0].clientX,y:e.touches[0].clientY})},n.touchStart=function(e){n.handleStart({x:e.touches[0].clientX,y:e.touches[0].clientY,e:e}),n.el.addEventListener("touchmove",n.touchMove,n.eventOptions)},n.touchEnd=function(e){n.handleEnd(e),n.el.removeEventListener("touchmove",n.touchMove,n.eventOptions)},n.mouseDown=function(e){e.sourceCapabilities.firesTouchEvents||(n.handleStart({x:e.clientX,y:e.clientY,e:e}),n.el.addEventListener("mousemove",n.mouseMove,n.eventOptions))},n.mouseUp=function(e){e.sourceCapabilities.firesTouchEvents||(n.handleEnd(e),n.el.removeEventListener("mousemove",n.mouseMove,n.eventOptions))},n.handleEnd=function(e){var t=(0,r.default)()-n.startTime;if(n.emit("pan.preend",{sourceEvent:e}),n.panning){n.panning=!1;var i=!1,s=null;n.velocity.max.x>n.options.swipeVelocity&&"horizontal"===n.startDirection?(i=!0,s=n.velocity.current.x>0?"right":"left"):n.velocity.max.y>n.options.swipeVelocity&&"vertical"===n.startDirection&&(i=!0,s=n.velocity.current.y>0?"down":"up"),n.emit("pan.end",{isSwipe:i,swipeDirection:s,sourceEvent:e})}else t<=n.options.maxTapDuration&&n.emit("tap",{srcEvent:e})},n.el=arguments.length<=0?void 0:arguments[0],n.options=Object.assign({},{sensitivity:5,passive:!1,capture:!1,swipeVelocity:.7,maxTapDuration:300,longTapDuration:400,startDirectionLoopCount:2},(arguments.length<=1?void 0:arguments[1])||{}),n.panning=!1,n.startDirection=null,n.directionCount=0,n.clearVelocityStats(),n.eventOptions=!1;try{var i=Object.defineProperty({},"passive",{get:function(){n.eventOptions={passive:!!n.options.passive,capture:!!n.options.capture}}});n.el.addEventListener("test",null,i)}catch(e){n.eventOptions={capture:!!n.options.capture}}return n.setup(),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t.prototype.clearVelocityStats=function(){this.velocity={current:{x:0,y:0},max:{x:0,y:0}}},t.prototype.isPanning=function(){return this.panning},t.prototype.setup=function(){this.el.addEventListener("mousedown",this.mouseDown,this.eventOptions),this.el.addEventListener("mouseup",this.mouseUp,this.eventOptions),this.el.addEventListener("touchstart",this.touchStart,this.eventOptions),this.el.addEventListener("touchend",this.touchEnd,this.eventOptions),this.el.addEventListener("touchcancel",this.touchEnd,this.eventOptions)},t.prototype.destroy=function(){this.el.removeEventListener("mousedown",this.mouseDown,this.eventOptions),this.el.removeEventListener("mouseup",this.mouseUp,this.eventOptions),this.el.removeEventListener("mousemove",this.mouseMove,this.eventOptions),this.el.removeEventListener("touchstart",this.touchStart,this.eventOptions),this.el.removeEventListener("touchend",this.touchEnd,this.eventOptions),this.el.removeEventListener("touchcancel",this.touchEnd,this.eventOptions),this.el.removeEventListener("touchmove",this.touchMove,this.eventOptions)},t.prototype.getStartDirection=function(e){var t=e.x,n=void 0===t?0:t,i=e.y,r=void 0===i?0:i;return this.directionCount<=this.options.startDirectionLoopCount?(this.directionCount++,null):Math.abs(n)>Math.abs(r)?"horizontal":"vertical"},t.prototype.handleStart=function(e){var t=e.x,n=void 0===t?0:t,i=e.y,s=void 0===i?0:i,o=e.e,a=void 0===o?{}:o;this.startX=n,this.startY=s,this.startDirection=null,this.directionCount=1,this.panning=!1,this.startTime=(0,r.default)(),this.clearVelocityStats(),this.emit("pan.prestart",{sourceEvent:a})},t.prototype.handleMove=function(e){var t=e.e,n=void 0===t?{}:t,i=e.x,s=void 0===i?0:i,o=e.y,a=void 0===o?0:o,l=s-this.startX,c=a-this.startY;if(null===this.startDirection?this.startDirection=this.getStartDirection({x:l,y:c}):!this.panning&&(Math.abs(l)>this.options.sensitivity||Math.abs(c)>this.options.sensitivity)&&(this.panning=!0,this.emit("pan.start",{startDirection:this.startDirection,sourceEvent:n})),this.panning){this.emit("pan.all",{startDirection:this.startDirection,deltaX:l,deltaY:c,sourceEvent:n}),"horizontal"===this.startDirection?l<0?this.emit("pan.x.left",{delta:l,sourceEvent:n}):this.emit("pan.x.right",{delta:l,sourceEvent:n}):"vertical"===this.startDirection&&(c<0?this.emit("pan.y.up",{delta:c,sourceEvent:n}):this.emit("pan.y.down",{delta:c,sourceEvent:n}));var h=(0,r.default)()-this.startTime;this.velocity.current.x=l/h,this.velocity.current.y=c/h,this.velocity.max.x=Math.max(this.velocity.max.x,Math.abs(this.velocity.current.x)),this.velocity.max.y=Math.max(this.velocity.max.y,Math.abs(this.velocity.current.y))}},t}(i.default);t.default=o},function(e,t,n){(function(i){var r;!function(s){var o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=10;function l(){this._events={},this._conf&&c.call(this,this._conf)}function c(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._maxListeners=e.maxListeners!==s?e.maxListeners:a,e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._maxListeners=a}function h(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),void 0!==i&&i.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,i.emitWarning(r)}else console.trace}function u(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,c.call(this,e)}function p(e,t,n,i){if(!n)return[];var r,s,o,a,l,c,h,u=[],f=t.length,v=t[i],d=t[i+1];if(i===f&&n._listeners){if("function"==typeof n._listeners)return e&&e.push(n._listeners),[n];for(r=0,s=n._listeners.length;r<s;r++)e&&e.push(n._listeners[r]);return[n]}if("*"===v||"**"===v||n[v]){if("*"===v){for(o in n)"_listeners"!==o&&n.hasOwnProperty(o)&&(u=u.concat(p(e,t,n[o],i+1)));return u}if("**"===v){for(o in(h=i+1===f||i+2===f&&"*"===d)&&n._listeners&&(u=u.concat(p(e,t,n,f))),n)"_listeners"!==o&&n.hasOwnProperty(o)&&("*"===o||"**"===o?(n[o]._listeners&&!h&&(u=u.concat(p(e,t,n[o],f))),u=u.concat(p(e,t,n[o],i))):u=o===d?u.concat(p(e,t,n[o],i+2)):u.concat(p(e,t,n[o],i)));return u}u=u.concat(p(e,t,n[v],i+1))}if((a=n["*"])&&p(e,t,a,i+1),l=n["**"])if(i<f)for(o in l._listeners&&p(e,t,l,f),l)"_listeners"!==o&&l.hasOwnProperty(o)&&(o===d?p(e,t,l[o],i+2):o===v?p(e,t,l[o],i+1):((c={})[o]=l[o],p(e,t,{"**":c},i+1)));else l._listeners?p(e,t,l,f):l["*"]&&l["*"]._listeners&&p(e,t,l["*"],f);return u}u.EventEmitter2=u,u.prototype.delimiter=".",u.prototype.setMaxListeners=function(e){e!==s&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},u.prototype.event="",u.prototype.once=function(e,t){return this._once(e,t,!1)},u.prototype.prependOnceListener=function(e,t){return this._once(e,t,!0)},u.prototype._once=function(e,t,n){return this._many(e,1,t,n),this},u.prototype.many=function(e,t,n){return this._many(e,t,n,!1)},u.prototype.prependMany=function(e,t,n){return this._many(e,t,n,!0)},u.prototype._many=function(e,t,n,i){var r=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&r.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,i),r},u.prototype.emit=function(){this._events||l.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return!1;var t,n,i,r,s,o=arguments.length;if(this._all&&this._all.length){if(s=this._all.slice(),o>3)for(t=new Array(o),r=0;r<o;r++)t[r]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,o){case 1:s[i].call(this,e);break;case 2:s[i].call(this,e,arguments[1]);break;case 3:s[i].call(this,e,arguments[1],arguments[2]);break;default:s[i].apply(this,t)}}if(this.wildcard){s=[];var a="string"==typeof e?e.split(this.delimiter):e.slice();p.call(this,s,a,this.listenerTree,0)}else{if("function"==typeof(s=this._events[e])){switch(this.event=e,o){case 1:s.call(this);break;case 2:s.call(this,arguments[1]);break;case 3:s.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(o-1),r=1;r<o;r++)t[r-1]=arguments[r];s.apply(this,t)}return!0}s&&(s=s.slice())}if(s&&s.length){if(o>3)for(t=new Array(o-1),r=1;r<o;r++)t[r-1]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,o){case 1:s[i].call(this);break;case 2:s[i].call(this,arguments[1]);break;case 3:s[i].call(this,arguments[1],arguments[2]);break;default:s[i].apply(this,t)}return!0}if(!this._all&&"error"===e)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},u.prototype.emitAsync=function(){this._events||l.call(this);var e=arguments[0];if("newListener"===e&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);var t,n,i,r,s,o=[],a=arguments.length;if(this._all){if(a>3)for(t=new Array(a),r=1;r<a;r++)t[r]=arguments[r];for(i=0,n=this._all.length;i<n;i++)switch(this.event=e,a){case 1:o.push(this._all[i].call(this,e));break;case 2:o.push(this._all[i].call(this,e,arguments[1]));break;case 3:o.push(this._all[i].call(this,e,arguments[1],arguments[2]));break;default:o.push(this._all[i].apply(this,t))}}if(this.wildcard){s=[];var c="string"==typeof e?e.split(this.delimiter):e.slice();p.call(this,s,c,this.listenerTree,0)}else s=this._events[e];if("function"==typeof s)switch(this.event=e,a){case 1:o.push(s.call(this));break;case 2:o.push(s.call(this,arguments[1]));break;case 3:o.push(s.call(this,arguments[1],arguments[2]));break;default:for(t=new Array(a-1),r=1;r<a;r++)t[r-1]=arguments[r];o.push(s.apply(this,t))}else if(s&&s.length){if(s=s.slice(),a>3)for(t=new Array(a-1),r=1;r<a;r++)t[r-1]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,a){case 1:o.push(s[i].call(this));break;case 2:o.push(s[i].call(this,arguments[1]));break;case 3:o.push(s[i].call(this,arguments[1],arguments[2]));break;default:o.push(s[i].apply(this,t))}}else if(!this._all&&"error"===e)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(o)},u.prototype.on=function(e,t){return this._on(e,t,!1)},u.prototype.prependListener=function(e,t){return this._on(e,t,!0)},u.prototype.onAny=function(e){return this._onAny(e,!1)},u.prototype.prependAny=function(e){return this._onAny(e,!0)},u.prototype.addListener=u.prototype.on,u.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},u.prototype._on=function(e,t,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");return this._events||l.call(this),this._newListener&&this.emit("newListener",e,t),this.wildcard?(function(e,t){for(var n=0,i=(e="string"==typeof e?e.split(this.delimiter):e.slice()).length;n+1<i;n++)if("**"===e[n]&&"**"===e[n+1])return;for(var r=this.listenerTree,o=e.shift();o!==s;){if(r[o]||(r[o]={}),r=r[o],0===e.length)return r._listeners?("function"==typeof r._listeners&&(r._listeners=[r._listeners]),r._listeners.push(t),!r._listeners.warned&&this._maxListeners>0&&r._listeners.length>this._maxListeners&&(r._listeners.warned=!0,h.call(this,r._listeners.length,o))):r._listeners=t,!0;o=e.shift()}return!0}.call(this,e,t),this):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),n?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,h.call(this,this._events[e].length,e))):this._events[e]=t,this)},u.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,i=[];if(this.wildcard){var r="string"==typeof e?e.split(this.delimiter):e.slice();i=p.call(this,null,r,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var a=0;a<i.length;a++){var l=i[a];if(n=l._listeners,o(n)){for(var c=-1,h=0,u=n.length;h<u;h++)if(n[h]===t||n[h].listener&&n[h].listener===t||n[h]._origin&&n[h]._origin===t){c=h;break}if(c<0)continue;return this.wildcard?l._listeners.splice(c,1):this._events[e].splice(c,1),0===n.length&&(this.wildcard?delete l._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(n===t||n.listener&&n.listener===t||n._origin&&n._origin===t)&&(this.wildcard?delete l._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return function e(t){if(t!==s){var n=Object.keys(t);for(var i in n){var r=n[i],o=t[r];o instanceof Function||"object"!=typeof o||null===o||(Object.keys(o).length>0&&e(t[r]),0===Object.keys(o).length&&delete t[r])}}}(this.listenerTree),this},u.prototype.offAny=function(e){var t,n=0,i=0;if(e&&this._all&&this._all.length>0){for(n=0,i=(t=this._all).length;n<i;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,i=t.length;n<i;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},u.prototype.removeListener=u.prototype.off,u.prototype.removeAllListeners=function(e){if(e===s)return!this._events||l.call(this),this;if(this.wildcard)for(var t="string"==typeof e?e.split(this.delimiter):e.slice(),n=p.call(this,null,t,this.listenerTree,0),i=0;i<n.length;i++){n[i]._listeners=null}else this._events&&(this._events[e]=null);return this},u.prototype.listeners=function(e){if(this.wildcard){var t=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return p.call(this,t,n,this.listenerTree,0),t}return this._events||l.call(this),this._events[e]||(this._events[e]=[]),o(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]},u.prototype.eventNames=function(){return Object.keys(this._events)},u.prototype.listenerCount=function(e){return this.listeners(e).length},u.prototype.listenersAny=function(){return this._all?this._all:[]},(r=function(){return u}.call(t,n,t,e))===s||(e.exports=r)}()}).call(t,n(0))},function(e,t,n){(function(t){(function(){var n,i,r,s,o,a;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:void 0!==t&&null!==t&&t.hrtime?(e.exports=function(){return(n()-o)/1e6},i=t.hrtime,s=(n=function(){var e;return 1e9*(e=i())[0]+e[1]})(),a=1e9*t.uptime(),o=s-a):Date.now?(e.exports=function(){return Date.now()-r},r=Date.now()):(e.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(this)}).call(t,n(0))},function(e,t,n){"use strict";t.__esModule=!0,t.default=function(e){if(!("InputDeviceCapabilities"in e||"sourceCapabilities"in UIEvent.prototype)){c.prototype={get firesTouchEvents(){return this.__firesTouchEvents}},e.InputDeviceCapabilities=c;var t,n=new c({firesTouchEvents:!0}),i=new c({firesTouchEvents:!1});document.addEventListener("touchstart",h,!0),document.addEventListener("touchmove",h,!0),document.addEventListener("touchend",h,!0),document.addEventListener("touchcancel",h,!0);var r="__inputDeviceCapabilitiesPolyfill_specifiedSourceCapabilities",s=["resize","error","load","unload","abort"];Object.defineProperty(UIEvent.prototype,"sourceCapabilities",{get:function(){if(r in this)return this[r];if(s.indexOf(this.type)>=0)return null;if(!("TouchEvent"in e))return i;if(this instanceof TouchEvent)return n;if("PointerEvent"in e&&this instanceof PointerEvent)return"touch"==this.pointerType?n:i;var o=Date.now()<t+1e3?n:i;return Object.defineProperty(this,r,{value:o,writable:!1}),o},configurable:!0,enumerable:!0});for(var o=["UIEvent","MouseEvent","TouchEvent","InputEvent","CompositionEvent","FocusEvent","KeyboardEvent","WheelEvent","PointerEvent"],a=0;a<o.length;a++)u(o[a]);var l=Document.prototype.createEvent;Document.prototype.createEvent=function(e){var t=l.call(this,e);if(t instanceof UIEvent)return Object.defineProperty(t,r,{value:null,writable:!1}),t}}function c(e){Object.defineProperty(this,"__firesTouchEvents",{value:!!(e&&"firesTouchEvents"in e)&&e.firesTouchEvents,writable:!1,enumerable:!1})}function h(e){t=Date.now()}function u(t){if(t in e&&"length"in e[t]&&!(e[t].length<1)){var n=e[t];e[t]=function(e,t){var i=t&&t.sourceCapabilities?t.sourceCapabilities:null;t&&delete t.sourceCapabilities;var s=new n(e,t);return Object.defineProperty(s,r,{value:i,writable:!1}),s},e[t].prototype=n.prototype}}}}]).default}); |
{ | ||
"name": "gesture-helper", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "a *tiny* touch & mouse library to help make tracking touch interactions more simple.", | ||
@@ -5,0 +5,0 @@ "unpkg": "dist/index.min.js", |
@@ -184,2 +184,4 @@ 'use strict'; | ||
const deltaTime = perfNow() - this.startTime; | ||
this.emit('pan.preend', { sourceEvent: e }); | ||
if (this.panning) { | ||
@@ -186,0 +188,0 @@ this.panning = false; |
95152
1781