New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gesture-helper

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gesture-helper - npm Package Compare versions

Comparing version 0.1.20 to 0.1.21

src/emitter.js

10

demo/demo.js

@@ -11,2 +11,3 @@ import GestureHelper from '../src/gesture-helper.js';

startDirectionLoopCount: 1,
useMomentum: true,
// longTapDuration: 500, // coming soon

@@ -24,7 +25,7 @@ });

gestureCtrl.on('pan.start', function(ev) {
gestureCtrl.on('pan.start', function (ev) {
console.log('pan.start', ev);
});
gestureCtrl.on('pan.end', function(ev) {
gestureCtrl.on('pan.end', function (ev) {
console.log('pan.end', ev);

@@ -35,2 +36,7 @@ demoOutput.innerHTML = JSON.stringify(ev);

gestureCtrl.on('momentum.**', function (ev) {
console.log('momentum.**', ev);
demoOutput.innerHTML = JSON.stringify(ev);
});
function handleAll(ev) {

@@ -37,0 +43,0 @@ console.log(this.event, ev);

1520

dist/index.js

@@ -1,525 +0,3 @@

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("GestureHelper", [], factory);
else if(typeof exports === 'object')
exports["GestureHelper"] = factory();
else
root["GestureHelper"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _eventemitter = __webpack_require__(2);
var _eventemitter2 = _interopRequireDefault(_eventemitter);
var _performanceNow = __webpack_require__(3);
var _performanceNow2 = _interopRequireDefault(_performanceNow);
var _inputdevicecapabilitiesPolyfill = __webpack_require__(4);
var _inputdevicecapabilitiesPolyfill2 = _interopRequireDefault(_inputdevicecapabilitiesPolyfill);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// @TODO: temp polyfill code, should tidy this a bit..
(0, _inputdevicecapabilitiesPolyfill2.default)(window);
var GestureHelper = function (_EventEmitter) {
_inherits(GestureHelper, _EventEmitter);
function GestureHelper() {
_classCallCheck(this, GestureHelper);
var _this = _possibleConstructorReturn(this, _EventEmitter.call(this, {
wildcard: true
}));
_this.mouseMove = function (e) {
_this.handleMove({ e: e, x: e.clientX, y: e.clientY });
};
_this.touchMove = function (e) {
_this.handleMove({ e: e, x: e.touches[0].clientX, y: e.touches[0].clientY });
};
_this.touchStart = function (e) {
_this.handleStart({
x: e.touches[0].clientX,
y: e.touches[0].clientY,
e: e
});
_this.el.addEventListener('touchmove', _this.touchMove, _this.eventOptions);
};
_this.touchEnd = function (e) {
_this.handleEnd(e);
_this.el.removeEventListener('touchmove', _this.touchMove, _this.eventOptions);
};
_this.mouseDown = function (e) {
if (e.sourceCapabilities.firesTouchEvents) return;
_this.handleStart({ x: e.clientX, y: e.clientY, e: e });
_this.el.addEventListener('mousemove', _this.mouseMove, _this.eventOptions);
};
_this.mouseUp = function (e) {
if (e.sourceCapabilities.firesTouchEvents) return;
_this.handleEnd(e);
_this.el.removeEventListener('mousemove', _this.mouseMove, _this.eventOptions);
};
_this.handleEnd = function (e) {
var deltaTime = (0, _performanceNow2.default)() - _this.startTime;
_this.emit('pan.preend', { sourceEvent: e });
if (_this.panning) {
_this.panning = false;
var isSwipe = false;
var swipeDirection = null;
if (_this.velocity.max.x > _this.options.swipeVelocity && _this.startDirection === 'horizontal') {
isSwipe = true;
swipeDirection = _this.velocity.current.x > 0 ? 'right' : 'left';
} else if (_this.velocity.max.y > _this.options.swipeVelocity && _this.startDirection === 'vertical') {
isSwipe = true;
swipeDirection = _this.velocity.current.y > 0 ? 'down' : 'up';
}
_this.emit('pan.end', { isSwipe: isSwipe, swipeDirection: swipeDirection, sourceEvent: e });
} else if (deltaTime <= _this.options.maxTapDuration) {
_this.emit('tap', { srcEvent: e });
}
return;
};
_this.el = arguments.length <= 0 ? undefined : arguments[0];
_this.options = Object.assign({}, {
sensitivity: 5,
passive: false,
capture: false,
swipeVelocity: 0.7,
maxTapDuration: 300,
longTapDuration: 400,
startDirectionLoopCount: 2
}, (arguments.length <= 1 ? undefined : arguments[1]) || {});
_this.panning = false;
_this.startDirection = null;
_this.directionCount = 0;
_this.clearVelocityStats();
// Small feature detect for support of "passive" events
_this.eventOptions = false;
try {
var options = Object.defineProperty({}, "passive", {
get: function get() {
_this.eventOptions = {
passive: !!_this.options.passive,
capture: !!_this.options.capture
};
}
});
_this.el.addEventListener("test", null, options);
} catch (err) {
console.error(err);
_this.eventOptions = {
capture: !!_this.options.capture
};
}
_this.setup();
return _this;
}
GestureHelper.prototype.clearVelocityStats = function clearVelocityStats() {
this.velocity = {
current: { x: 0, y: 0 },
max: { x: 0, y: 0 }
};
};
GestureHelper.prototype.isPanning = function isPanning() {
return this.panning;
};
GestureHelper.prototype.setup = function setup() {
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);
};
GestureHelper.prototype.destroy = function destroy() {
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);
};
GestureHelper.prototype.getStartDirection = function getStartDirection(_ref) {
var _ref$x = _ref.x,
x = _ref$x === undefined ? 0 : _ref$x,
_ref$y = _ref.y,
y = _ref$y === undefined ? 0 : _ref$y;
if (this.directionCount <= this.options.startDirectionLoopCount) {
this.directionCount++;
return null;
} else {
return Math.abs(x) > Math.abs(y) ? 'horizontal' : 'vertical';
}
};
GestureHelper.prototype.handleStart = function handleStart(_ref2) {
var _ref2$x = _ref2.x,
x = _ref2$x === undefined ? 0 : _ref2$x,
_ref2$y = _ref2.y,
y = _ref2$y === undefined ? 0 : _ref2$y,
_ref2$e = _ref2.e,
e = _ref2$e === undefined ? {} : _ref2$e;
// Ensure all settings are reset:
this.startX = x;
this.startY = y;
this.startDirection = null;
this.directionCount = 1;
this.panning = false;
this.startTime = (0, _performanceNow2.default)();
this.clearVelocityStats();
this.emit('pan.prestart', { sourceEvent: e });
};
GestureHelper.prototype.handleMove = function handleMove(_ref3) {
var _ref3$e = _ref3.e,
e = _ref3$e === undefined ? {} : _ref3$e,
_ref3$x = _ref3.x,
x = _ref3$x === undefined ? 0 : _ref3$x,
_ref3$y = _ref3.y,
y = _ref3$y === undefined ? 0 : _ref3$y;
var deltaX = x - this.startX;
var deltaY = y - this.startY;
if (this.startDirection === null) {
this.startDirection = this.getStartDirection({ x: deltaX, y: deltaY });
} else if (!this.panning && (Math.abs(deltaX) > this.options.sensitivity || Math.abs(deltaY) > this.options.sensitivity)) {
this.panning = true;
this.emit('pan.start', {
startDirection: this.startDirection,
sourceEvent: e
});
}
if (this.panning) {
this.emit('pan.all', {
startDirection: this.startDirection,
deltaX: deltaX, deltaY: deltaY,
sourceEvent: e
});
if (this.startDirection === 'horizontal') {
deltaX < 0 ? this.emit('pan.x.left', { delta: deltaX, sourceEvent: e }) : this.emit('pan.x.right', { delta: deltaX, sourceEvent: e });
} else if (this.startDirection === 'vertical') {
deltaY < 0 ? this.emit('pan.y.up', { delta: deltaY, sourceEvent: e }) : this.emit('pan.y.down', { delta: deltaY, sourceEvent: e });
}
// velocity = total distance moved / the time taken
var deltaTime = (0, _performanceNow2.default)() - this.startTime;
this.velocity.current.x = deltaX / deltaTime;
this.velocity.current.y = deltaY / deltaTime;
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));
}
};
return GestureHelper;
}(_eventemitter2.default);
exports.default = GestureHelper;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {var __WEBPACK_AMD_DEFINE_RESULT__;/*!
!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()}(window,(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,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return 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=5)}([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()}: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(this,n(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=[],u=!1,h=-1;function f(){u&&l&&(u=!1,l.length?c=l.concat(c):h=-1,c.length&&p())}function p(){if(!u){var e=a(f);u=!0;for(var t=c.length;t;){for(l=c,c=[];++h<t;)l&&l[h].run();h=-1,t=c.length}l=null,u=!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 y(){}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||u||a(p)},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=y,r.addListener=y,r.once=y,r.off=y,r.removeListener=y,r.removeAllListeners=y,r.emit=y,r.prependListener=y,r.prependOnceListener=y,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){(function(i){var r;
/*!
* EventEmitter2

@@ -530,994 +8,2 @@ * https://github.com/hij1nx/EventEmitter2

* Licensed under the MIT license.
*/
;!function(undefined) {
var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
var defaultMaxListeners = 10;
function init() {
this._events = {};
if (this._conf) {
configure.call(this, this._conf);
}
}
function configure(conf) {
if (conf) {
this._conf = conf;
conf.delimiter && (this.delimiter = conf.delimiter);
this._maxListeners = conf.maxListeners !== undefined ? conf.maxListeners : defaultMaxListeners;
conf.wildcard && (this.wildcard = conf.wildcard);
conf.newListener && (this._newListener = conf.newListener);
conf.removeListener && (this._removeListener = conf.removeListener);
conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak);
if (this.wildcard) {
this.listenerTree = {};
}
} else {
this._maxListeners = defaultMaxListeners;
}
}
function logPossibleMemoryLeak(count, eventName) {
var errorMsg = '(node) warning: possible EventEmitter memory ' +
'leak detected. ' + count + ' listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.';
if(this.verboseMemoryLeak){
errorMsg += ' Event name: ' + eventName + '.';
}
if(typeof process !== 'undefined' && process.emitWarning){
var e = new Error(errorMsg);
e.name = 'MaxListenersExceededWarning';
e.emitter = this;
e.count = count;
process.emitWarning(e);
} else {
console.error(errorMsg);
if (console.trace){
console.trace();
}
}
}
function EventEmitter(conf) {
this._events = {};
this._newListener = false;
this._removeListener = false;
this.verboseMemoryLeak = false;
configure.call(this, conf);
}
EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property
//
// Attention, function return type now is array, always !
// It has zero elements if no any matches found and one or more
// elements (leafs) if there are matches
//
function searchListenerTree(handlers, type, tree, i) {
if (!tree) {
return [];
}
var listeners=[], leaf, len, branch, xTree, xxTree, isolatedBranch, endReached,
typeLength = type.length, currentType = type[i], nextType = type[i+1];
if (i === typeLength && tree._listeners) {
//
// If at the end of the event(s) list and the tree has listeners
// invoke those listeners.
//
if (typeof tree._listeners === 'function') {
handlers && handlers.push(tree._listeners);
return [tree];
} else {
for (leaf = 0, len = tree._listeners.length; leaf < len; leaf++) {
handlers && handlers.push(tree._listeners[leaf]);
}
return [tree];
}
}
if ((currentType === '*' || currentType === '**') || tree[currentType]) {
//
// If the event emitted is '*' at this part
// or there is a concrete match at this patch
//
if (currentType === '*') {
for (branch in tree) {
if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+1));
}
}
return listeners;
} else if(currentType === '**') {
endReached = (i+1 === typeLength || (i+2 === typeLength && nextType === '*'));
if(endReached && tree._listeners) {
// The next element has a _listeners, add it to the handlers.
listeners = listeners.concat(searchListenerTree(handlers, type, tree, typeLength));
}
for (branch in tree) {
if (branch !== '_listeners' && tree.hasOwnProperty(branch)) {
if(branch === '*' || branch === '**') {
if(tree[branch]._listeners && !endReached) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], typeLength));
}
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
} else if(branch === nextType) {
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i+2));
} else {
// No match on this one, shift into the tree but not in the type array.
listeners = listeners.concat(searchListenerTree(handlers, type, tree[branch], i));
}
}
}
return listeners;
}
listeners = listeners.concat(searchListenerTree(handlers, type, tree[currentType], i+1));
}
xTree = tree['*'];
if (xTree) {
//
// If the listener tree will allow any match for this part,
// then recursively explore all branches of the tree
//
searchListenerTree(handlers, type, xTree, i+1);
}
xxTree = tree['**'];
if(xxTree) {
if(i < typeLength) {
if(xxTree._listeners) {
// If we have a listener on a '**', it will catch all, so add its handler.
searchListenerTree(handlers, type, xxTree, typeLength);
}
// Build arrays of matching next branches and others.
for(branch in xxTree) {
if(branch !== '_listeners' && xxTree.hasOwnProperty(branch)) {
if(branch === nextType) {
// We know the next element will match, so jump twice.
searchListenerTree(handlers, type, xxTree[branch], i+2);
} else if(branch === currentType) {
// Current node matches, move into the tree.
searchListenerTree(handlers, type, xxTree[branch], i+1);
} else {
isolatedBranch = {};
isolatedBranch[branch] = xxTree[branch];
searchListenerTree(handlers, type, { '**': isolatedBranch }, i+1);
}
}
}
} else if(xxTree._listeners) {
// We have reached the end and still on a '**'
searchListenerTree(handlers, type, xxTree, typeLength);
} else if(xxTree['*'] && xxTree['*']._listeners) {
searchListenerTree(handlers, type, xxTree['*'], typeLength);
}
}
return listeners;
}
function growListenerTree(type, listener) {
type = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
//
// Looks for two consecutive '**', if so, don't add the event at all.
//
for(var i = 0, len = type.length; i+1 < len; i++) {
if(type[i] === '**' && type[i+1] === '**') {
return;
}
}
var tree = this.listenerTree;
var name = type.shift();
while (name !== undefined) {
if (!tree[name]) {
tree[name] = {};
}
tree = tree[name];
if (type.length === 0) {
if (!tree._listeners) {
tree._listeners = listener;
}
else {
if (typeof tree._listeners === 'function') {
tree._listeners = [tree._listeners];
}
tree._listeners.push(listener);
if (
!tree._listeners.warned &&
this._maxListeners > 0 &&
tree._listeners.length > this._maxListeners
) {
tree._listeners.warned = true;
logPossibleMemoryLeak.call(this, tree._listeners.length, name);
}
}
return true;
}
name = type.shift();
}
return true;
}
// By default EventEmitters will print a warning if more than
// 10 listeners are added to it. This is a useful default which
// helps finding memory leaks.
//
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.delimiter = '.';
EventEmitter.prototype.setMaxListeners = function(n) {
if (n !== undefined) {
this._maxListeners = n;
if (!this._conf) this._conf = {};
this._conf.maxListeners = n;
}
};
EventEmitter.prototype.event = '';
EventEmitter.prototype.once = function(event, fn) {
return this._once(event, fn, false);
};
EventEmitter.prototype.prependOnceListener = function(event, fn) {
return this._once(event, fn, true);
};
EventEmitter.prototype._once = function(event, fn, prepend) {
this._many(event, 1, fn, prepend);
return this;
};
EventEmitter.prototype.many = function(event, ttl, fn) {
return this._many(event, ttl, fn, false);
}
EventEmitter.prototype.prependMany = function(event, ttl, fn) {
return this._many(event, ttl, fn, true);
}
EventEmitter.prototype._many = function(event, ttl, fn, prepend) {
var self = this;
if (typeof fn !== 'function') {
throw new Error('many only accepts instances of Function');
}
function listener() {
if (--ttl === 0) {
self.off(event, listener);
}
return fn.apply(this, arguments);
}
listener._origin = fn;
this._on(event, listener, prepend);
return self;
};
EventEmitter.prototype.emit = function() {
this._events || init.call(this);
var type = arguments[0];
if (type === 'newListener' && !this._newListener) {
if (!this._events.newListener) {
return false;
}
}
var al = arguments.length;
var args,l,i,j;
var handler;
if (this._all && this._all.length) {
handler = this._all.slice();
if (al > 3) {
args = new Array(al);
for (j = 0; j < al; j++) args[j] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
handler[i].call(this, type);
break;
case 2:
handler[i].call(this, type, arguments[1]);
break;
case 3:
handler[i].call(this, type, arguments[1], arguments[2]);
break;
default:
handler[i].apply(this, args);
}
}
}
if (this.wildcard) {
handler = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
} else {
handler = this._events[type];
if (typeof handler === 'function') {
this.event = type;
switch (al) {
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
default:
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
handler.apply(this, args);
}
return true;
} else if (handler) {
// need to make copy of handlers because list can change in the middle
// of emit call
handler = handler.slice();
}
}
if (handler && handler.length) {
if (al > 3) {
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
handler[i].call(this);
break;
case 2:
handler[i].call(this, arguments[1]);
break;
case 3:
handler[i].call(this, arguments[1], arguments[2]);
break;
default:
handler[i].apply(this, args);
}
}
return true;
} else if (!this._all && type === 'error') {
if (arguments[1] instanceof Error) {
throw arguments[1]; // Unhandled 'error' event
} else {
throw new Error("Uncaught, unspecified 'error' event.");
}
return false;
}
return !!this._all;
};
EventEmitter.prototype.emitAsync = function() {
this._events || init.call(this);
var type = arguments[0];
if (type === 'newListener' && !this._newListener) {
if (!this._events.newListener) { return Promise.resolve([false]); }
}
var promises= [];
var al = arguments.length;
var args,l,i,j;
var handler;
if (this._all) {
if (al > 3) {
args = new Array(al);
for (j = 1; j < al; j++) args[j] = arguments[j];
}
for (i = 0, l = this._all.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
promises.push(this._all[i].call(this, type));
break;
case 2:
promises.push(this._all[i].call(this, type, arguments[1]));
break;
case 3:
promises.push(this._all[i].call(this, type, arguments[1], arguments[2]));
break;
default:
promises.push(this._all[i].apply(this, args));
}
}
}
if (this.wildcard) {
handler = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
} else {
handler = this._events[type];
}
if (typeof handler === 'function') {
this.event = type;
switch (al) {
case 1:
promises.push(handler.call(this));
break;
case 2:
promises.push(handler.call(this, arguments[1]));
break;
case 3:
promises.push(handler.call(this, arguments[1], arguments[2]));
break;
default:
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
promises.push(handler.apply(this, args));
}
} else if (handler && handler.length) {
handler = handler.slice();
if (al > 3) {
args = new Array(al - 1);
for (j = 1; j < al; j++) args[j - 1] = arguments[j];
}
for (i = 0, l = handler.length; i < l; i++) {
this.event = type;
switch (al) {
case 1:
promises.push(handler[i].call(this));
break;
case 2:
promises.push(handler[i].call(this, arguments[1]));
break;
case 3:
promises.push(handler[i].call(this, arguments[1], arguments[2]));
break;
default:
promises.push(handler[i].apply(this, args));
}
}
} else if (!this._all && type === 'error') {
if (arguments[1] instanceof Error) {
return Promise.reject(arguments[1]); // Unhandled 'error' event
} else {
return Promise.reject("Uncaught, unspecified 'error' event.");
}
}
return Promise.all(promises);
};
EventEmitter.prototype.on = function(type, listener) {
return this._on(type, listener, false);
};
EventEmitter.prototype.prependListener = function(type, listener) {
return this._on(type, listener, true);
};
EventEmitter.prototype.onAny = function(fn) {
return this._onAny(fn, false);
};
EventEmitter.prototype.prependAny = function(fn) {
return this._onAny(fn, true);
};
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
EventEmitter.prototype._onAny = function(fn, prepend){
if (typeof fn !== 'function') {
throw new Error('onAny only accepts instances of Function');
}
if (!this._all) {
this._all = [];
}
// Add the function to the event listener collection.
if(prepend){
this._all.unshift(fn);
}else{
this._all.push(fn);
}
return this;
}
EventEmitter.prototype._on = function(type, listener, prepend) {
if (typeof type === 'function') {
this._onAny(type, listener);
return this;
}
if (typeof listener !== 'function') {
throw new Error('on only accepts instances of Function');
}
this._events || init.call(this);
// To avoid recursion in the case that type == "newListeners"! Before
// adding it to the listeners, first emit "newListeners".
if (this._newListener)
this.emit('newListener', type, listener);
if (this.wildcard) {
growListenerTree.call(this, type, listener);
return this;
}
if (!this._events[type]) {
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
}
else {
if (typeof this._events[type] === 'function') {
// Change to array.
this._events[type] = [this._events[type]];
}
// If we've already got an array, just add
if(prepend){
this._events[type].unshift(listener);
}else{
this._events[type].push(listener);
}
// Check for listener leak
if (
!this._events[type].warned &&
this._maxListeners > 0 &&
this._events[type].length > this._maxListeners
) {
this._events[type].warned = true;
logPossibleMemoryLeak.call(this, this._events[type].length, type);
}
}
return this;
}
EventEmitter.prototype.off = function(type, listener) {
if (typeof listener !== 'function') {
throw new Error('removeListener only takes instances of Function');
}
var handlers,leafs=[];
if(this.wildcard) {
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
}
else {
// does not use listeners(), so no side effect of creating _events[type]
if (!this._events[type]) return this;
handlers = this._events[type];
leafs.push({_listeners:handlers});
}
for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
var leaf = leafs[iLeaf];
handlers = leaf._listeners;
if (isArray(handlers)) {
var position = -1;
for (var i = 0, length = handlers.length; i < length; i++) {
if (handlers[i] === listener ||
(handlers[i].listener && handlers[i].listener === listener) ||
(handlers[i]._origin && handlers[i]._origin === listener)) {
position = i;
break;
}
}
if (position < 0) {
continue;
}
if(this.wildcard) {
leaf._listeners.splice(position, 1);
}
else {
this._events[type].splice(position, 1);
}
if (handlers.length === 0) {
if(this.wildcard) {
delete leaf._listeners;
}
else {
delete this._events[type];
}
}
if (this._removeListener)
this.emit("removeListener", type, listener);
return this;
}
else if (handlers === listener ||
(handlers.listener && handlers.listener === listener) ||
(handlers._origin && handlers._origin === listener)) {
if(this.wildcard) {
delete leaf._listeners;
}
else {
delete this._events[type];
}
if (this._removeListener)
this.emit("removeListener", type, listener);
}
}
function recursivelyGarbageCollect(root) {
if (root === undefined) {
return;
}
var keys = Object.keys(root);
for (var i in keys) {
var key = keys[i];
var obj = root[key];
if ((obj instanceof Function) || (typeof obj !== "object") || (obj === null))
continue;
if (Object.keys(obj).length > 0) {
recursivelyGarbageCollect(root[key]);
}
if (Object.keys(obj).length === 0) {
delete root[key];
}
}
}
recursivelyGarbageCollect(this.listenerTree);
return this;
};
EventEmitter.prototype.offAny = function(fn) {
var i = 0, l = 0, fns;
if (fn && this._all && this._all.length > 0) {
fns = this._all;
for(i = 0, l = fns.length; i < l; i++) {
if(fn === fns[i]) {
fns.splice(i, 1);
if (this._removeListener)
this.emit("removeListenerAny", fn);
return this;
}
}
} else {
fns = this._all;
if (this._removeListener) {
for(i = 0, l = fns.length; i < l; i++)
this.emit("removeListenerAny", fns[i]);
}
this._all = [];
}
return this;
};
EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
EventEmitter.prototype.removeAllListeners = function(type) {
if (type === undefined) {
!this._events || init.call(this);
return this;
}
if (this.wildcard) {
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
var leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
for (var iLeaf=0; iLeaf<leafs.length; iLeaf++) {
var leaf = leafs[iLeaf];
leaf._listeners = null;
}
}
else if (this._events) {
this._events[type] = null;
}
return this;
};
EventEmitter.prototype.listeners = function(type) {
if (this.wildcard) {
var handlers = [];
var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
searchListenerTree.call(this, handlers, ns, this.listenerTree, 0);
return handlers;
}
this._events || init.call(this);
if (!this._events[type]) this._events[type] = [];
if (!isArray(this._events[type])) {
this._events[type] = [this._events[type]];
}
return this._events[type];
};
EventEmitter.prototype.eventNames = function(){
return Object.keys(this._events);
}
EventEmitter.prototype.listenerCount = function(type) {
return this.listeners(type).length;
};
EventEmitter.prototype.listenersAny = function() {
if(this._all) {
return this._all;
}
else {
return [];
}
};
if (true) {
// AMD. Register as an anonymous module.
!(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
return EventEmitter;
}.call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else if (typeof exports === 'object') {
// CommonJS
module.exports = EventEmitter;
}
else {
// Browser global.
window.EventEmitter2 = EventEmitter;
}
}();
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {// Generated by CoffeeScript 1.12.2
(function() {
var getNanoSeconds, hrtime, loadTime, moduleLoadTime, nodeLoadTime, upTime;
if ((typeof performance !== "undefined" && performance !== null) && performance.now) {
module.exports = function() {
return performance.now();
};
} else if ((typeof process !== "undefined" && process !== null) && process.hrtime) {
module.exports = function() {
return (getNanoSeconds() - nodeLoadTime) / 1e6;
};
hrtime = process.hrtime;
getNanoSeconds = function() {
var hr;
hr = hrtime();
return hr[0] * 1e9 + hr[1];
};
moduleLoadTime = getNanoSeconds();
upTime = process.uptime() * 1e9;
nodeLoadTime = moduleLoadTime - upTime;
} else if (Date.now) {
module.exports = function() {
return Date.now() - loadTime;
};
loadTime = Date.now();
} else {
module.exports = function() {
return new Date().getTime() - loadTime;
};
loadTime = new Date().getTime();
}
}).call(this);
//# sourceMappingURL=performance-now.js.map
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0)))
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
/* inputdevicecapabilities-polyfill.js - https://github.com/WICG/InputDeviceCapabilities
*
* Uses a (not perfectly accurate) heuristic to implement
* UIEvent.sourceCapabilities and InputDeviceCapabilities.firesTouchEvents.
* Assumptions:
* - If sourceCapabilities is consulted on an event, it will be first read within
* one second of the original event being dispatched. We could, instead,
* determine the sourceCapabilities as soon as any UIEvent is dispatched (eg.
* by hooking addEventListener) but that woudln't work for legacy onevent
* style handlers.
* - Touch and non-touch input devices aren't both being used within one
* second of eachother. Eg. if you tap the screen then quickly move the
* mouse, we may incorrectly attribute the mouse movement to the touch
* device.
*
* Browser support:
* - Verified working on:
* - Chrome 43 (Windows, Linux and Android)
* - IE 11 (Windows)
* - Firefox 38 (Linux)
* - Safari 8 (Mac and iOS)
* - Event constructors aren't supported by IE at all.
* - IE on Windows phone isn't supported properly (https://github.com/WICG/InputDeviceCapabilities/issues/13)
* - Won't work in IE prior to version 9 (due to lack of Object.defineProperty)
*/
function InputDeviceCapabilities(global) {
'use strict';
if ('InputDeviceCapabilities' in global || 'sourceCapabilities' in UIEvent.prototype) return;
function InputDeviceCapabilities(inputDeviceCapabilitiesInit) {
Object.defineProperty(this, '__firesTouchEvents', {
value: inputDeviceCapabilitiesInit && 'firesTouchEvents' in inputDeviceCapabilitiesInit ? inputDeviceCapabilitiesInit.firesTouchEvents : false,
writable: false,
enumerable: false
});
};
// Put the attributes prototype as getter functions to match the IDL.
InputDeviceCapabilities.prototype = {
get firesTouchEvents() {
return this.__firesTouchEvents;
}
};
global.InputDeviceCapabilities = InputDeviceCapabilities;
var touchDevice = new InputDeviceCapabilities({ firesTouchEvents: true });
var nonTouchDevice = new InputDeviceCapabilities({ firesTouchEvents: false });
// Keep track of the last time we saw a touch event. Note that if you don't
// already have touch handlers on your document, this can have unfortunate
// consequences for scrolling performance. See https://plus.google.com/+RickByers/posts/cmzrtyBYPQc.
var lastTouchTime;
function touchHandler(event) {
lastTouchTime = Date.now();
};
document.addEventListener('touchstart', touchHandler, true);
document.addEventListener('touchmove', touchHandler, true);
document.addEventListener('touchend', touchHandler, true);
document.addEventListener('touchcancel', touchHandler, true);
var specifiedSourceCapabilitiesName = '__inputDeviceCapabilitiesPolyfill_specifiedSourceCapabilities';
// A few UIEvents aren't really input events and so should always have a null
// source capabilities. Arguably we should have a list of opt-in event types instead,
// but that probably depends on ultimately how we want to specify this behavior.
var eventTypesWithNoSourceCapabilities = ['resize', 'error', 'load', 'unload', 'abort'];
// We assume that any UI event that occurs within this many ms from a touch
// event is caused by a touch device. This needs to be a little longer than
// the maximum tap delay on various browsers (350ms in Safari) while remaining
// as short as possible to reduce the risk of confusing other input that happens
// to come shortly after touch input.
var touchTimeConstant = 1000;
Object.defineProperty(UIEvent.prototype, 'sourceCapabilities', {
get: function get() {
// Handle script-generated events and events which have already had their
// sourceCapabilities read.
if (specifiedSourceCapabilitiesName in this) return this[specifiedSourceCapabilitiesName];
// Handle non-input events.
if (eventTypesWithNoSourceCapabilities.indexOf(this.type) >= 0) return null;
// touch events may not be supported by this browser at all (eg. IE desktop).
if (!('TouchEvent' in global)) return nonTouchDevice;
// Touch events are always generated from devices that fire touch events.
if (this instanceof TouchEvent) return touchDevice;
// Pointer events are special - they may come before a touch event.
if ('PointerEvent' in global && this instanceof PointerEvent) {
if (this.pointerType == "touch") return touchDevice;
return nonTouchDevice;
}
// Otherwise use recent touch events to decide if this event is likely due
// to a touch device or not.
var sourceCapabilities = Date.now() < lastTouchTime + touchTimeConstant ? touchDevice : nonTouchDevice;
// Cache the value to ensure it can't change over the life of the event.
Object.defineProperty(this, specifiedSourceCapabilitiesName, {
value: sourceCapabilities,
writable: false
});
return sourceCapabilities;
},
configurable: true,
enumerable: true
});
// Add support for supplying a sourceCapabilities from JS in all UIEvent constructors.
function augmentEventConstructor(constructorName) {
if (!(constructorName in global)) return;
// IE doesn't support event constructors at all.
// In Safari typeof constructor is 'object' while it's 'function' in other browsers.
if (!('length' in global[constructorName]) || global[constructorName].length < 1) return;
var origCtor = global[constructorName];
global[constructorName] = function (type, initDict) {
var sourceCapabilities = initDict && initDict.sourceCapabilities ? initDict.sourceCapabilities : null;
// Need to explicitly remove sourceCapabilities from the dictionary as it would cause
// a type error in blink when InputDeviceCapabilities support is disabled.
if (initDict) delete initDict.sourceCapabilities;
var evt = new origCtor(type, initDict);
// Stash the sourceCapabilities value away for use by the UIEvent.sourceCapabilities
// getter. We could instead shadow the property on this instance, but
// that would be subtly different than the specified API.
Object.defineProperty(evt, specifiedSourceCapabilitiesName, {
value: sourceCapabilities,
writable: false
});
return evt;
};
global[constructorName].prototype = origCtor.prototype;
};
// Note that SVGZoomEvent desn't yet have constructors defined.
var uiEventConstructors = ['UIEvent', 'MouseEvent', 'TouchEvent', 'InputEvent', 'CompositionEvent', 'FocusEvent', 'KeyboardEvent', 'WheelEvent', 'PointerEvent'];
for (var i = 0; i < uiEventConstructors.length; i++) {
augmentEventConstructor(uiEventConstructors[i]);
} // Ensure events created with document.createEvent always get a null sourceCapabilities
var origCreateEvent = Document.prototype.createEvent;
Document.prototype.createEvent = function (type) {
var evt = origCreateEvent.call(this, type);
if (evt instanceof UIEvent) {
Object.defineProperty(evt, specifiedSourceCapabilitiesName, {
value: null,
writable: false
});
return evt;
}
};
}
exports.default = InputDeviceCapabilities;
/***/ })
/******/ ])["default"];
});
*/!function(s){var o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};function a(){this._events={},this._conf&&l.call(this,this._conf)}function l(e){e?(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),this._maxListeners=void 0!==e.maxListeners?e.maxListeners:10,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=10}function c(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.error(n),console.trace&&console.trace()}function u(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}function h(e,t,n,i){if(!n)return[];var r,s,o,a,l,c,u,f=[],p=t.length,v=t[i],y=t[i+1];if(i===p&&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)&&(f=f.concat(h(e,t,n[o],i+1)));return f}if("**"===v){for(o in(u=i+1===p||i+2===p&&"*"===y)&&n._listeners&&(f=f.concat(h(e,t,n,p))),n)"_listeners"!==o&&n.hasOwnProperty(o)&&("*"===o||"**"===o?(n[o]._listeners&&!u&&(f=f.concat(h(e,t,n[o],p))),f=f.concat(h(e,t,n[o],i))):f=o===y?f.concat(h(e,t,n[o],i+2)):f.concat(h(e,t,n[o],i)));return f}f=f.concat(h(e,t,n[v],i+1))}if((a=n["*"])&&h(e,t,a,i+1),l=n["**"])if(i<p)for(o in l._listeners&&h(e,t,l,p),l)"_listeners"!==o&&l.hasOwnProperty(o)&&(o===y?h(e,t,l[o],i+2):o===v?h(e,t,l[o],i+1):((c={})[o]=l[o],h(e,t,{"**":c},i+1)));else l._listeners?h(e,t,l,p):l["*"]&&l["*"]._listeners&&h(e,t,l["*"],p);return f}function f(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,s=e.shift();void 0!==s;){if(r[s]||(r[s]={}),r=r[s],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,c.call(this,r._listeners.length,s))):r._listeners=t,!0;s=e.shift()}return!0}u.EventEmitter2=u,u.prototype.delimiter=".",u.prototype.setMaxListeners=function(e){void 0!==e&&(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||a.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 l="string"==typeof e?e.split(this.delimiter):e.slice();h.call(this,s,l,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||a.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=[],l=arguments.length;if(this._all){if(l>3)for(t=new Array(l),r=1;r<l;r++)t[r]=arguments[r];for(i=0,n=this._all.length;i<n;i++)switch(this.event=e,l){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();h.call(this,s,c,this.listenerTree,0)}else s=this._events[e];if("function"==typeof s)switch(this.event=e,l){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(l-1),r=1;r<l;r++)t[r-1]=arguments[r];o.push(s.apply(this,t))}else if(s&&s.length){if(s=s.slice(),l>3)for(t=new Array(l-1),r=1;r<l;r++)t[r-1]=arguments[r];for(i=0,n=s.length;i<n;i++)switch(this.event=e,l){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||a.call(this),this._newListener&&this.emit("newListener",e,t),this.wildcard?(f.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,c.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=h.call(this,null,r,this.listenerTree,0)}else{if(!this._events[e])return this;n=this._events[e],i.push({_listeners:n})}for(var s=0;s<i.length;s++){var a=i[s];if(n=a._listeners,o(n)){for(var l=-1,c=0,u=n.length;c<u;c++)if(n[c]===t||n[c].listener&&n[c].listener===t||n[c]._origin&&n[c]._origin===t){l=c;break}if(l<0)continue;return this.wildcard?a._listeners.splice(l,1):this._events[e].splice(l,1),0===n.length&&(this.wildcard?delete a._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 a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return function e(t){if(void 0!==t){var n=Object.keys(t);for(var i in n){var r=n[i],s=t[r];s instanceof Function||"object"!=typeof s||null===s||(Object.keys(s).length>0&&e(t[r]),0===Object.keys(s).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(void 0===e)return!this._events||a.call(this),this;if(this.wildcard)for(var t="string"==typeof e?e.split(this.delimiter):e.slice(),n=h.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 h.call(this,t,n,this.listenerTree,0),t}return this._events||a.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:[]},void 0===(r=function(){return u}.call(t,n,t,e))||(e.exports=r)}()}).call(this,n(1))},function(e,t,n){(function(t){for(var i=n(0),r="undefined"==typeof window?t:window,s=["moz","webkit"],o="AnimationFrame",a=r["request"+o],l=r["cancel"+o]||r["cancelRequest"+o],c=0;!a&&c<s.length;c++)a=r[s[c]+"Request"+o],l=r[s[c]+"Cancel"+o]||r[s[c]+"CancelRequest"+o];if(!a||!l){var u=0,h=0,f=[];a=function(e){if(0===f.length){var t=i(),n=Math.max(0,1e3/60-(t-u));u=n+t,setTimeout((function(){var e=f.slice(0);f.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(u)}catch(e){setTimeout((function(){throw e}),0)}}),Math.round(n))}return f.push({handle:++h,callback:e,cancelled:!1}),h},l=function(e){for(var t=0;t<f.length;t++)f[t].handle===e&&(f[t].cancelled=!0)}}e.exports=function(e){return a.call(r,e)},e.exports.cancel=function(){l.apply(r,arguments)},e.exports.polyfill=function(e){e||(e=r),e.requestAnimationFrame=a,e.cancelAnimationFrame=l}}).call(this,n(4))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);var i=n(2),r=n.n(i),s=n(0),o=n.n(s),a=n(3),l=n.n(a),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.velocity,n=void 0===t?{x:0,y:0}:t,i=e.from,r=void 0===i?{x:0,y:0}:i,s=e.power,a=void 0===s?.8:s,c=e.timeConstant,u=void 0===c?350:c,h=e.restDelta,f=void 0===h?.5:h,p=(e.roundDestination,e.emitter),v=0,y=null;Math.abs(n.x)>Math.abs(n.y)?(n.x,r.x,y=n.x<0?"left":"right"):(n.y,r.y,y=n.y<0?"up":"down");var d=o()(),m=a*n.x,_=a*n.y,w=Math.round(r.x+m),b=Math.round(r.y+_),g=w,E=b;function x(){l()((function(){v=o()()-d;var e=-m*Math.exp(-v/u),t=-_*Math.exp(-v/u),n=e>f||e<-f,i=t>f||t<-f,r=n?g+e:g,s=i?E+t:E;switch(p.emit("momentum.all",{deltaX:r,deltaY:s}),y){case"up":case"down":p.emit("momentum.y.".concat(y),{delta:s});break;case"left":case"right":p.emit("momentum.x.".concat(y),{delta:r})}n||i?x():(console.log("stopping!"),p.emit("momentum.end",{}))}))}return p.emit("momentum.start"),{start:x,stop:function(){isMovingX=!1,isMovingY=!1}}};var u=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",u,!0),document.addEventListener("touchmove",u,!0),document.addEventListener("touchend",u,!0),document.addEventListener("touchcancel",u,!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++)h(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 u(e){t=Date.now()}function h(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}}};function h(e){return(h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function v(e,t){return!t||"object"!==h(t)&&"function"!=typeof t?d(e):t}function y(e){return(y=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"default",(function(){return w})),u(window);var w=function(e){function t(){var e;f(this,t),_(d(e=v(this,y(t).call(this,{wildcard:!0}))),"mouseMove",(function(t){e.handleMove({e:t,x:t.clientX,y:t.clientY})})),_(d(e),"touchMove",(function(t){e.handleMove({e:t,x:t.touches[0].clientX,y:t.touches[0].clientY})})),_(d(e),"touchStart",(function(t){e.handleStart({x:t.touches[0].clientX,y:t.touches[0].clientY,e:t}),e.el.addEventListener("touchmove",e.touchMove,e.eventOptions)})),_(d(e),"touchEnd",(function(t){e.handleEnd(t),e.el.removeEventListener("touchmove",e.touchMove,e.eventOptions)})),_(d(e),"mouseDown",(function(t){t.sourceCapabilities.firesTouchEvents||(e.handleStart({x:t.clientX,y:t.clientY,e:t}),e.el.addEventListener("mousemove",e.mouseMove,e.eventOptions))})),_(d(e),"mouseUp",(function(t){t.sourceCapabilities.firesTouchEvents||(e.handleEnd(t),e.el.removeEventListener("mousemove",e.mouseMove,e.eventOptions))})),_(d(e),"handleEnd",(function(t){var n=o()()-e.startTime;if(e.emit("pan.preend",{sourceEvent:t}),e.panning){e.panning=!1;var i=!1,r=null;e.velocity.max.x>e.options.swipeVelocity&&"horizontal"===e.startDirection?(i=!0,r=e.velocity.current.x>0?"right":"left"):e.velocity.max.y>e.options.swipeVelocity&&"vertical"===e.startDirection&&(i=!0,r=e.velocity.current.y>0?"down":"up"),e.emit("pan.end",{isSwipe:i,swipeDirection:r,sourceEvent:t}),e.options.useMomentum&&(e.momentum=c({velocity:{x:e.velocity.current.x,y:e.velocity.current.y},from:{x:e.lastDeltaX,y:e.lastDeltaY},emitter:d(e)}),e.momentum.start())}else n<=e.options.maxTapDuration&&e.emit("tap",{srcEvent:t})})),e.el=arguments.length<=0?void 0:arguments[0],e.options=Object.assign({},{sensitivity:5,passive:!1,capture:!1,swipeVelocity:.7,maxTapDuration:300,longTapDuration:400,startDirectionLoopCount:2},(arguments.length<=1?void 0:arguments[1])||{}),e.panning=!1,e.startDirection=null,e.directionCount=0,e.clearVelocityStats(),e.eventOptions=!1;try{var n=Object.defineProperty({},"passive",{get:function(){e.eventOptions={passive:!!e.options.passive,capture:!!e.options.capture}}});e.el.addEventListener("test",null,n)}catch(t){console.error(t),e.eventOptions={capture:!!e.options.capture}}return e.setup(),e}var n,i,r;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(t,e),n=t,(i=[{key:"clearVelocityStats",value:function(){this.velocity={current:{x:0,y:0},max:{x:0,y:0}}}},{key:"isPanning",value:function(){return this.panning}},{key:"setup",value: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)}},{key:"destroy",value: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)}},{key:"getStartDirection",value: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"}},{key:"handleStart",value:function(e){var t=e.x,n=void 0===t?0:t,i=e.y,r=void 0===i?0:i,s=e.e,a=void 0===s?{}:s;this.startX=n,this.startY=r,this.startDirection=null,this.directionCount=1,this.panning=!1,this.startTime=o()(),this.clearVelocityStats(),this.emit("pan.prestart",{sourceEvent:a})}},{key:"handleMove",value:function(e){var t=e.e,n=void 0===t?{}:t,i=e.x,r=void 0===i?0:i,s=e.y,a=void 0===s?0:s,l=r-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 u=o()()-this.startTime;this.velocity.current.x=l/u*100,this.velocity.current.y=c/u*100,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)),this.lastDeltaX=l,this.lastDeltaY=c}}}])&&p(n.prototype,i),r&&p(n,r),t}(r.a)}]).default}));
{
"name": "gesture-helper",
"version": "0.1.20",
"version": "0.1.21",
"description": "a *tiny* touch & mouse library to help make tracking touch interactions more simple.",

@@ -16,18 +16,6 @@ "unpkg": "dist/index.min.js",

"license": "MIT",
"devDependencies": {
"babel-core": "^6.3.2",
"babel-loader": "^7.1.2",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-es2015": "^6.24.1",
"html-webpack-plugin": "^2.30.1",
"uglifyjs-webpack-plugin": "^1.2.2",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.7.1"
},
"scripts": {
"demo": "webpack-dev-server --config ./webpack.demo.config.js --colors --open",
"build-split": "webpack --config ./webpack.split.config.js",
"build-normal": "webpack --config ./webpack.config.js",
"build-min": "webpack --config ./webpack.min.config.js",
"build": "yarn build-normal; yarn build-min",
"build": "webpack --config ./webpack.config.js",
"prebuild": "rm -rf dist",
"prepublish": "yarn build"

@@ -37,4 +25,15 @@ },

"eventemitter2": "^5.0.1",
"performance-now": "^2.1.0"
"performance-now": "^2.1.0",
"raf": "^3.4.0"
},
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/preset-env": "^7.8.4",
"babel-loader": "^8.0.6",
"html-webpack-plugin": "^3.2.0",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.1.11"
}
}

@@ -19,2 +19,7 @@ # gesture-helper

pan.x.** // (wildcard for both left and right movement progress events)
momentum.** //
momentum.start //
momentum.all //
momentum.y.** //
momentum.x.** //
```

@@ -21,0 +26,0 @@

@@ -5,2 +5,3 @@ 'use strict';

import perfNow from 'performance-now';
import momentum from './momentum';

@@ -176,6 +177,8 @@ // @TODO: temp polyfill code, should tidy this a bit..

const deltaTime = perfNow() - this.startTime;
this.velocity.current.x = deltaX / deltaTime;
this.velocity.current.y = deltaY / deltaTime;
this.velocity.current.x = deltaX / deltaTime * 100;
this.velocity.current.y = deltaY / deltaTime * 100;
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));
this.lastDeltaX = deltaX;
this.lastDeltaY = deltaY;
}

@@ -204,2 +207,20 @@ }

this.emit('pan.end', { isSwipe, swipeDirection, sourceEvent: e });
if (this.options.useMomentum) {
this.momentum = momentum({
velocity: {
x: this.velocity.current.x,
y: this.velocity.current.y,
},
from: {
x: this.lastDeltaX,
y: this.lastDeltaY,
},
// @TODO, this feels pretty sloppy.
// There must be a nicer way to structure this lib
emitter: this,
});
this.momentum.start();
}
} else if (deltaTime <= this.options.maxTapDuration) {

@@ -206,0 +227,0 @@ this.emit('tap', { srcEvent: e });

@@ -1,2 +0,3 @@

/* inputdevicecapabilities-polyfill.js - https://github.com/WICG/InputDeviceCapabilities
/* inputdevicecapabilities-polyfill.js -
https://github.com/WICG/InputDeviceCapabilities
*

@@ -30,12 +31,12 @@ * Uses a (not perfectly accurate) heuristic to implement

if ('InputDeviceCapabilities' in global|| 'sourceCapabilities' in UIEvent.prototype)
if ('InputDeviceCapabilities' in global || 'sourceCapabilities' in UIEvent.prototype)
return;
function InputDeviceCapabilities(inputDeviceCapabilitiesInit) {
Object.defineProperty(this, '__firesTouchEvents', {
value: (inputDeviceCapabilitiesInit && 'firesTouchEvents' in inputDeviceCapabilitiesInit) ?
inputDeviceCapabilitiesInit.firesTouchEvents : false,
writable: false,
enumerable: false
});
Object.defineProperty(this, '__firesTouchEvents', {
value: (inputDeviceCapabilitiesInit && 'firesTouchEvents' in inputDeviceCapabilitiesInit) ?
inputDeviceCapabilitiesInit.firesTouchEvents : false,
writable: false,
enumerable: false
});
};

@@ -50,4 +51,4 @@ // Put the attributes prototype as getter functions to match the IDL.

var touchDevice = new InputDeviceCapabilities({firesTouchEvents:true});
var nonTouchDevice = new InputDeviceCapabilities({firesTouchEvents:false});
var touchDevice = new InputDeviceCapabilities({ firesTouchEvents: true });
var nonTouchDevice = new InputDeviceCapabilities({ firesTouchEvents: false });

@@ -81,3 +82,3 @@ // Keep track of the last time we saw a touch event. Note that if you don't

Object.defineProperty(UIEvent.prototype, 'sourceCapabilities', {
get: function() {
get: function () {
// Handle script-generated events and events which have already had their

@@ -134,3 +135,3 @@ // sourceCapabilities read.

var origCtor = global[constructorName];
global[constructorName] = function(type, initDict) {
global[constructorName] = function (type, initDict) {
var sourceCapabilities = (initDict && initDict.sourceCapabilities) ? initDict.sourceCapabilities : null;

@@ -161,3 +162,3 @@ // Need to explicitly remove sourceCapabilities from the dictionary as it would cause

var origCreateEvent = Document.prototype.createEvent;
Document.prototype.createEvent = function(type) {
Document.prototype.createEvent = function (type) {
var evt = origCreateEvent.call(this, type);

@@ -164,0 +165,0 @@ if (evt instanceof UIEvent) {

@@ -10,2 +10,3 @@ 'use strict';

},
mode: 'production',
output: {

@@ -22,3 +23,3 @@ path: require('path').resolve('./dist/'),

resolve: {
modules: [ 'node_modules', ],
modules: ['node_modules',],
descriptionFiles: ['package.json'],

@@ -33,11 +34,8 @@ },

loader: 'babel-loader',
query: {
babelrc: false,
presets: [
['es2015', { loose: true }],
],
options: {
presets: ['@babel/preset-env'],
plugins: [
'transform-class-properties',
"@babel/plugin-proposal-class-properties",
]
}
},
}

@@ -44,0 +42,0 @@ ]

@@ -6,2 +6,4 @@ 'use strict';

config.mode = 'development';
config.devtool = 'eval-source-map';
config.entry = {

@@ -8,0 +10,0 @@ index: './demo/demo.js',

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc