rc-gesture
Version:
Support gesture for react component
1,395 lines (1,205 loc) • 79.2 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["rc-gesture"] = factory(require("react"));
else
root["rc-gesture"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_90__) {
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;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // 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 = 91);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
var core = module.exports = { version: '2.5.7' };
if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef
/***/ }),
/* 1 */
/***/ (function(module, exports) {
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
var global = module.exports = typeof window != 'undefined' && window.Math == Math
? window : typeof self != 'undefined' && self.Math == Math ? self
// eslint-disable-next-line no-new-func
: Function('return this')();
if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
// Thank's IE8 for his funny defineProperty
module.exports = !__webpack_require__(11)(function () {
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
});
/***/ }),
/* 3 */
/***/ (function(module, exports) {
var hasOwnProperty = {}.hasOwnProperty;
module.exports = function (it, key) {
return hasOwnProperty.call(it, key);
};
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
var anObject = __webpack_require__(10);
var IE8_DOM_DEFINE = __webpack_require__(34);
var toPrimitive = __webpack_require__(26);
var dP = Object.defineProperty;
exports.f = __webpack_require__(2) ? Object.defineProperty : function defineProperty(O, P, Attributes) {
anObject(O);
P = toPrimitive(P, true);
anObject(Attributes);
if (IE8_DOM_DEFINE) try {
return dP(O, P, Attributes);
} catch (e) { /* empty */ }
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!');
if ('value' in Attributes) O[P] = Attributes.value;
return O;
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(1);
var core = __webpack_require__(0);
var ctx = __webpack_require__(32);
var hide = __webpack_require__(6);
var has = __webpack_require__(3);
var PROTOTYPE = 'prototype';
var $export = function (type, name, source) {
var IS_FORCED = type & $export.F;
var IS_GLOBAL = type & $export.G;
var IS_STATIC = type & $export.S;
var IS_PROTO = type & $export.P;
var IS_BIND = type & $export.B;
var IS_WRAP = type & $export.W;
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {});
var expProto = exports[PROTOTYPE];
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE];
var key, own, out;
if (IS_GLOBAL) source = name;
for (key in source) {
// contains in native
own = !IS_FORCED && target && target[key] !== undefined;
if (own && has(exports, key)) continue;
// export native or passed
out = own ? target[key] : source[key];
// prevent global pollution for namespaces
exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
// bind timers to global for call from export context
: IS_BIND && own ? ctx(out, global)
// wrap global constructors for prevent change them in library
: IS_WRAP && target[key] == out ? (function (C) {
var F = function (a, b, c) {
if (this instanceof C) {
switch (arguments.length) {
case 0: return new C();
case 1: return new C(a);
case 2: return new C(a, b);
} return new C(a, b, c);
} return C.apply(this, arguments);
};
F[PROTOTYPE] = C[PROTOTYPE];
return F;
// make static versions for prototype methods
})(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
// export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
if (IS_PROTO) {
(exports.virtual || (exports.virtual = {}))[key] = out;
// export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out);
}
}
};
// type bitmap
$export.F = 1; // forced
$export.G = 2; // global
$export.S = 4; // static
$export.P = 8; // proto
$export.B = 16; // bind
$export.W = 32; // wrap
$export.U = 64; // safe
$export.R = 128; // real proto method for `library`
module.exports = $export;
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
var dP = __webpack_require__(4);
var createDesc = __webpack_require__(15);
module.exports = __webpack_require__(2) ? function (object, key, value) {
return dP.f(object, key, createDesc(1, value));
} : function (object, key, value) {
object[key] = value;
return object;
};
/***/ }),
/* 7 */
/***/ (function(module, exports) {
module.exports = function (it) {
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
// to indexed object, toObject with fallback for non-array-like ES3 strings
var IObject = __webpack_require__(35);
var defined = __webpack_require__(17);
module.exports = function (it) {
return IObject(defined(it));
};
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
var store = __webpack_require__(24)('wks');
var uid = __webpack_require__(16);
var Symbol = __webpack_require__(1).Symbol;
var USE_SYMBOL = typeof Symbol == 'function';
var $exports = module.exports = function (name) {
return store[name] || (store[name] =
USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
};
$exports.store = store;
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(7);
module.exports = function (it) {
if (!isObject(it)) throw TypeError(it + ' is not an object!');
return it;
};
/***/ }),
/* 11 */
/***/ (function(module, exports) {
module.exports = function (exec) {
try {
return !!exec();
} catch (e) {
return true;
}
};
/***/ }),
/* 12 */
/***/ (function(module, exports) {
module.exports = true;
/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.14 / 15.2.3.14 Object.keys(O)
var $keys = __webpack_require__(39);
var enumBugKeys = __webpack_require__(18);
module.exports = Object.keys || function keys(O) {
return $keys(O, enumBugKeys);
};
/***/ }),
/* 14 */
/***/ (function(module, exports) {
exports.f = {}.propertyIsEnumerable;
/***/ }),
/* 15 */
/***/ (function(module, exports) {
module.exports = function (bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value: value
};
};
/***/ }),
/* 16 */
/***/ (function(module, exports) {
var id = 0;
var px = Math.random();
module.exports = function (key) {
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
};
/***/ }),
/* 17 */
/***/ (function(module, exports) {
// 7.2.1 RequireObjectCoercible(argument)
module.exports = function (it) {
if (it == undefined) throw TypeError("Can't call method on " + it);
return it;
};
/***/ }),
/* 18 */
/***/ (function(module, exports) {
// IE 8- don't enum bug keys
module.exports = (
'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
).split(',');
/***/ }),
/* 19 */
/***/ (function(module, exports) {
module.exports = {};
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
var anObject = __webpack_require__(10);
var dPs = __webpack_require__(72);
var enumBugKeys = __webpack_require__(18);
var IE_PROTO = __webpack_require__(23)('IE_PROTO');
var Empty = function () { /* empty */ };
var PROTOTYPE = 'prototype';
// Create object with fake `null` prototype: use iframe Object with cleared prototype
var createDict = function () {
// Thrash, waste and sodomy: IE GC bug
var iframe = __webpack_require__(33)('iframe');
var i = enumBugKeys.length;
var lt = '<';
var gt = '>';
var iframeDocument;
iframe.style.display = 'none';
__webpack_require__(66).appendChild(iframe);
iframe.src = 'javascript:'; // eslint-disable-line no-script-url
// createDict = iframe.contentWindow.Object;
// html.removeChild(iframe);
iframeDocument = iframe.contentWindow.document;
iframeDocument.open();
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
iframeDocument.close();
createDict = iframeDocument.F;
while (i--) delete createDict[PROTOTYPE][enumBugKeys[i]];
return createDict();
};
module.exports = Object.create || function create(O, Properties) {
var result;
if (O !== null) {
Empty[PROTOTYPE] = anObject(O);
result = new Empty();
Empty[PROTOTYPE] = null;
// add "__proto__" for Object.getPrototypeOf polyfill
result[IE_PROTO] = O;
} else result = createDict();
return Properties === undefined ? result : dPs(result, Properties);
};
/***/ }),
/* 21 */
/***/ (function(module, exports) {
exports.f = Object.getOwnPropertySymbols;
/***/ }),
/* 22 */
/***/ (function(module, exports, __webpack_require__) {
var def = __webpack_require__(4).f;
var has = __webpack_require__(3);
var TAG = __webpack_require__(9)('toStringTag');
module.exports = function (it, tag, stat) {
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
};
/***/ }),
/* 23 */
/***/ (function(module, exports, __webpack_require__) {
var shared = __webpack_require__(24)('keys');
var uid = __webpack_require__(16);
module.exports = function (key) {
return shared[key] || (shared[key] = uid(key));
};
/***/ }),
/* 24 */
/***/ (function(module, exports, __webpack_require__) {
var core = __webpack_require__(0);
var global = __webpack_require__(1);
var SHARED = '__core-js_shared__';
var store = global[SHARED] || (global[SHARED] = {});
(module.exports = function (key, value) {
return store[key] || (store[key] = value !== undefined ? value : {});
})('versions', []).push({
version: core.version,
mode: __webpack_require__(12) ? 'pure' : 'global',
copyright: '© 2018 Denis Pushkarev (zloirock.ru)'
});
/***/ }),
/* 25 */
/***/ (function(module, exports) {
// 7.1.4 ToInteger
var ceil = Math.ceil;
var floor = Math.floor;
module.exports = function (it) {
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
};
/***/ }),
/* 26 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.1 ToPrimitive(input [, PreferredType])
var isObject = __webpack_require__(7);
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
// and the second argument - flag - preferred type is a string
module.exports = function (it, S) {
if (!isObject(it)) return it;
var fn, val;
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
throw TypeError("Can't convert object to primitive value");
};
/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {
var global = __webpack_require__(1);
var core = __webpack_require__(0);
var LIBRARY = __webpack_require__(12);
var wksExt = __webpack_require__(28);
var defineProperty = __webpack_require__(4).f;
module.exports = function (name) {
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {});
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) });
};
/***/ }),
/* 28 */
/***/ (function(module, exports, __webpack_require__) {
exports.f = __webpack_require__(9);
/***/ }),
/* 29 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return DIRECTION_NONE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return DIRECTION_LEFT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return DIRECTION_RIGHT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return DIRECTION_UP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return DIRECTION_DOWN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return DIRECTION_HORIZONTAL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return DIRECTION_VERTICAL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return DIRECTION_ALL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return PRESS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return SWIPE; });
/* tslint:disable:no-bitwise */
// http://hammerjs.github.io/api/#directions
var DIRECTION_NONE = 1; // 00001
var DIRECTION_LEFT = 2; // 00010
var DIRECTION_RIGHT = 4; // 00100
var DIRECTION_UP = 8; // 01000
var DIRECTION_DOWN = 16; // 10000
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT; // 00110 6
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN; // 11000 24
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL; // 11110 30
// http://hammerjs.github.io/recognizer-press/
var PRESS = {
time: 251
};
// http://hammerjs.github.io/recognizer-swipe/
var SWIPE = {
threshold: 10,
velocity: 0.3
};
/***/ }),
/* 30 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var _iterator = __webpack_require__(50);
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = __webpack_require__(49);
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
/***/ }),
/* 31 */
/***/ (function(module, exports) {
var toString = {}.toString;
module.exports = function (it) {
return toString.call(it).slice(8, -1);
};
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
// optional / simple context binding
var aFunction = __webpack_require__(62);
module.exports = function (fn, that, length) {
aFunction(fn);
if (that === undefined) return fn;
switch (length) {
case 1: return function (a) {
return fn.call(that, a);
};
case 2: return function (a, b) {
return fn.call(that, a, b);
};
case 3: return function (a, b, c) {
return fn.call(that, a, b, c);
};
}
return function (/* ...args */) {
return fn.apply(that, arguments);
};
};
/***/ }),
/* 33 */
/***/ (function(module, exports, __webpack_require__) {
var isObject = __webpack_require__(7);
var document = __webpack_require__(1).document;
// typeof document.createElement is 'object' in old IE
var is = isObject(document) && isObject(document.createElement);
module.exports = function (it) {
return is ? document.createElement(it) : {};
};
/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = !__webpack_require__(2) && !__webpack_require__(11)(function () {
return Object.defineProperty(__webpack_require__(33)('div'), 'a', { get: function () { return 7; } }).a != 7;
});
/***/ }),
/* 35 */
/***/ (function(module, exports, __webpack_require__) {
// fallback for non-array-like ES3 and non-enumerable old V8 strings
var cof = __webpack_require__(31);
// eslint-disable-next-line no-prototype-builtins
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) {
return cof(it) == 'String' ? it.split('') : Object(it);
};
/***/ }),
/* 36 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var LIBRARY = __webpack_require__(12);
var $export = __webpack_require__(5);
var redefine = __webpack_require__(40);
var hide = __webpack_require__(6);
var Iterators = __webpack_require__(19);
var $iterCreate = __webpack_require__(68);
var setToStringTag = __webpack_require__(22);
var getPrototypeOf = __webpack_require__(74);
var ITERATOR = __webpack_require__(9)('iterator');
var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
var FF_ITERATOR = '@@iterator';
var KEYS = 'keys';
var VALUES = 'values';
var returnThis = function () { return this; };
module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) {
$iterCreate(Constructor, NAME, next);
var getMethod = function (kind) {
if (!BUGGY && kind in proto) return proto[kind];
switch (kind) {
case KEYS: return function keys() { return new Constructor(this, kind); };
case VALUES: return function values() { return new Constructor(this, kind); };
} return function entries() { return new Constructor(this, kind); };
};
var TAG = NAME + ' Iterator';
var DEF_VALUES = DEFAULT == VALUES;
var VALUES_BUG = false;
var proto = Base.prototype;
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT];
var $default = $native || getMethod(DEFAULT);
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined;
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native;
var methods, key, IteratorPrototype;
// Fix native
if ($anyNative) {
IteratorPrototype = getPrototypeOf($anyNative.call(new Base()));
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) {
// Set @@toStringTag to native iterators
setToStringTag(IteratorPrototype, TAG, true);
// fix for some old engines
if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis);
}
}
// fix Array#{values, @@iterator}.name in V8 / FF
if (DEF_VALUES && $native && $native.name !== VALUES) {
VALUES_BUG = true;
$default = function values() { return $native.call(this); };
}
// Define iterator
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) {
hide(proto, ITERATOR, $default);
}
// Plug for library
Iterators[NAME] = $default;
Iterators[TAG] = returnThis;
if (DEFAULT) {
methods = {
values: DEF_VALUES ? $default : getMethod(VALUES),
keys: IS_SET ? $default : getMethod(KEYS),
entries: $entries
};
if (FORCED) for (key in methods) {
if (!(key in proto)) redefine(proto, key, methods[key]);
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
}
return methods;
};
/***/ }),
/* 37 */
/***/ (function(module, exports, __webpack_require__) {
var pIE = __webpack_require__(14);
var createDesc = __webpack_require__(15);
var toIObject = __webpack_require__(8);
var toPrimitive = __webpack_require__(26);
var has = __webpack_require__(3);
var IE8_DOM_DEFINE = __webpack_require__(34);
var gOPD = Object.getOwnPropertyDescriptor;
exports.f = __webpack_require__(2) ? gOPD : function getOwnPropertyDescriptor(O, P) {
O = toIObject(O);
P = toPrimitive(P, true);
if (IE8_DOM_DEFINE) try {
return gOPD(O, P);
} catch (e) { /* empty */ }
if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]);
};
/***/ }),
/* 38 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
var $keys = __webpack_require__(39);
var hiddenKeys = __webpack_require__(18).concat('length', 'prototype');
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return $keys(O, hiddenKeys);
};
/***/ }),
/* 39 */
/***/ (function(module, exports, __webpack_require__) {
var has = __webpack_require__(3);
var toIObject = __webpack_require__(8);
var arrayIndexOf = __webpack_require__(64)(false);
var IE_PROTO = __webpack_require__(23)('IE_PROTO');
module.exports = function (object, names) {
var O = toIObject(object);
var i = 0;
var result = [];
var key;
for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key);
// Don't enum bug & hidden keys
while (names.length > i) if (has(O, key = names[i++])) {
~arrayIndexOf(result, key) || result.push(key);
}
return result;
};
/***/ }),
/* 40 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(6);
/***/ }),
/* 41 */
/***/ (function(module, exports, __webpack_require__) {
// 7.1.13 ToObject(argument)
var defined = __webpack_require__(17);
module.exports = function (it) {
return Object(defined(it));
};
/***/ }),
/* 42 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_index_tsx__ = __webpack_require__(43);
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_index_tsx__["a"]; });
/***/ }),
/* 43 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(53);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__ = __webpack_require__(51);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__ = __webpack_require__(52);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn__ = __webpack_require__(55);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits__ = __webpack_require__(54);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react__ = __webpack_require__(90);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_react__);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util__ = __webpack_require__(44);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__config__ = __webpack_require__(29);
/* tslint:disable:no-console */
;
;
var directionMap = {
all: __WEBPACK_IMPORTED_MODULE_7__config__["a" /* DIRECTION_ALL */],
vertical: __WEBPACK_IMPORTED_MODULE_7__config__["b" /* DIRECTION_VERTICAL */],
horizontal: __WEBPACK_IMPORTED_MODULE_7__config__["c" /* DIRECTION_HORIZONTAL */]
};
var Gesture = function (_Component) {
__WEBPACK_IMPORTED_MODULE_4_babel_runtime_helpers_inherits___default()(Gesture, _Component);
function Gesture(props) {
__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_classCallCheck___default()(this, Gesture);
var _this = __WEBPACK_IMPORTED_MODULE_3_babel_runtime_helpers_possibleConstructorReturn___default()(this, (Gesture.__proto__ || Object.getPrototypeOf(Gesture)).call(this, props));
_this.state = {};
_this.triggerEvent = function (name) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var cb = _this.props[name];
if (typeof cb === 'function') {
// always give user gesture object as first params first
cb.apply(undefined, [_this.getGestureState()].concat(args));
}
};
_this.triggerCombineEvent = function (mainEventName, eventStatus) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
args[_key2 - 2] = arguments[_key2];
}
_this.triggerEvent.apply(_this, [mainEventName].concat(args));
_this.triggerSubEvent.apply(_this, [mainEventName, eventStatus].concat(args));
};
_this.triggerSubEvent = function (mainEventName, eventStatus) {
for (var _len3 = arguments.length, args = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
args[_key3 - 2] = arguments[_key3];
}
if (eventStatus) {
var subEventName = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["a" /* getEventName */])(mainEventName, eventStatus);
_this.triggerEvent.apply(_this, [subEventName].concat(args));
}
};
_this.triggerPinchEvent = function (mainEventName, eventStatus) {
for (var _len4 = arguments.length, args = Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
args[_key4 - 2] = arguments[_key4];
}
var scale = _this.gesture.scale;
if (eventStatus === 'move' && typeof scale === 'number') {
if (scale > 1) {
_this.triggerEvent('onPinchOut');
}
if (scale < 1) {
_this.triggerEvent('onPinchIn');
}
}
_this.triggerCombineEvent.apply(_this, [mainEventName, eventStatus].concat(args));
};
_this.initPressTimer = function () {
_this.cleanPressTimer();
_this.pressTimer = setTimeout(function () {
_this.setGestureState({
press: true
});
_this.triggerEvent('onPress');
}, __WEBPACK_IMPORTED_MODULE_7__config__["d" /* PRESS */].time);
};
_this.cleanPressTimer = function () {
/* tslint:disable:no-unused-expression */
_this.pressTimer && clearTimeout(_this.pressTimer);
};
_this.setGestureState = function (params) {
if (!_this.gesture) {
_this.gesture = {};
}
// cache the previous touches
if (_this.gesture.touches) {
_this.gesture.preTouches = _this.gesture.touches;
}
_this.gesture = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, _this.gesture, params);
};
_this.getGestureState = function () {
if (!_this.gesture) {
return _this.gesture;
} else {
// shallow copy
return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, _this.gesture);
}
};
_this.cleanGestureState = function () {
delete _this.gesture;
};
_this.getTouches = function (e) {
return Array.prototype.slice.call(e.touches).map(function (item) {
return {
x: item.screenX,
y: item.screenY
};
});
};
_this.triggerUserCb = function (status, e) {
var cbName = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["a" /* getEventName */])('onTouch', status);
if (cbName in _this.props) {
_this.props[cbName](e);
}
};
_this._handleTouchStart = function (e) {
_this.triggerUserCb('start', e);
_this.event = e;
if (e.touches.length > 1) {
e.preventDefault();
}
_this.initGestureStatus(e);
_this.initPressTimer();
_this.checkIfMultiTouchStart();
};
_this.initGestureStatus = function (e) {
_this.cleanGestureState();
// store the gesture start state
var startTouches = _this.getTouches(e);
var startTime = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["b" /* now */])();
var startMutliFingerStatus = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["c" /* calcMutliFingerStatus */])(startTouches);
_this.setGestureState({
startTime: startTime,
startTouches: startTouches,
startMutliFingerStatus: startMutliFingerStatus,
/* copy for next time touch move cala convenient*/
time: startTime,
touches: startTouches,
mutliFingerStatus: startMutliFingerStatus,
srcEvent: _this.event
});
};
_this.checkIfMultiTouchStart = function () {
var _this$props = _this.props,
enablePinch = _this$props.enablePinch,
enableRotate = _this$props.enableRotate;
var touches = _this.gesture.touches;
if (touches.length > 1 && (enablePinch || enableRotate)) {
if (enablePinch) {
var startMutliFingerStatus = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["c" /* calcMutliFingerStatus */])(touches);
_this.setGestureState({
startMutliFingerStatus: startMutliFingerStatus,
/* init pinch status */
pinch: true,
scale: 1
});
_this.triggerCombineEvent('onPinch', 'start');
}
if (enableRotate) {
_this.setGestureState({
/* init rotate status */
rotate: true,
rotation: 0
});
_this.triggerCombineEvent('onRotate', 'start');
}
}
};
_this._handleTouchMove = function (e) {
_this.triggerUserCb('move', e);
_this.event = e;
if (!_this.gesture) {
// sometimes weird happen: touchstart -> touchmove..touchmove.. --> touchend --> touchmove --> touchend
// so we need to skip the unnormal event cycle after touchend
return;
}
// not a long press
_this.cleanPressTimer();
_this.updateGestureStatus(e);
_this.checkIfSingleTouchMove();
_this.checkIfMultiTouchMove();
};
_this.checkIfMultiTouchMove = function () {
var _this$gesture = _this.gesture,
pinch = _this$gesture.pinch,
rotate = _this$gesture.rotate,
touches = _this$gesture.touches,
startMutliFingerStatus = _this$gesture.startMutliFingerStatus,
mutliFingerStatus = _this$gesture.mutliFingerStatus;
if (!pinch && !rotate) {
return;
}
if (touches.length < 2) {
_this.setGestureState({
pinch: false,
rotate: false
});
// Todo: 2 finger -> 1 finger, wait to test this situation
pinch && _this.triggerCombineEvent('onPinch', 'cancel');
rotate && _this.triggerCombineEvent('onRotate', 'cancel');
return;
}
if (pinch) {
var scale = mutliFingerStatus.z / startMutliFingerStatus.z;
_this.setGestureState({
scale: scale
});
_this.triggerPinchEvent('onPinch', 'move');
}
if (rotate) {
var rotation = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["d" /* calcRotation */])(startMutliFingerStatus, mutliFingerStatus);
_this.setGestureState({
rotation: rotation
});
_this.triggerCombineEvent('onRotate', 'move');
}
};
_this.allowGesture = function () {
return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["e" /* shouldTriggerDirection */])(_this.gesture.direction, _this.directionSetting);
};
_this.checkIfSingleTouchMove = function () {
var _this$gesture2 = _this.gesture,
pan = _this$gesture2.pan,
touches = _this$gesture2.touches,
moveStatus = _this$gesture2.moveStatus,
preTouches = _this$gesture2.preTouches,
_this$gesture2$availa = _this$gesture2.availablePan,
availablePan = _this$gesture2$availa === undefined ? true : _this$gesture2$availa;
if (touches.length > 1) {
_this.setGestureState({
pan: false
});
// Todo: 1 finger -> 2 finger, wait to test this situation
pan && _this.triggerCombineEvent('onPan', 'cancel');
return;
}
// add avilablePan condition to fix the case in scrolling, which will cause unavailable pan move.
if (moveStatus && availablePan) {
var direction = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["f" /* getMovingDirection */])(preTouches[0], touches[0]);
_this.setGestureState({ direction: direction });
var eventName = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["g" /* getDirectionEventName */])(direction);
if (!_this.allowGesture()) {
// if the first move is unavailable, then judge all of remaining touch movings are also invalid.
if (!pan) {
_this.setGestureState({ availablePan: false });
}
return;
}
if (!pan) {
_this.triggerCombineEvent('onPan', 'start');
_this.setGestureState({
pan: true,
availablePan: true
});
} else {
_this.triggerCombineEvent('onPan', eventName);
_this.triggerSubEvent('onPan', 'move');
}
}
};
_this.checkIfMultiTouchEnd = function (status) {
var _this$gesture3 = _this.gesture,
pinch = _this$gesture3.pinch,
rotate = _this$gesture3.rotate;
if (pinch) {
_this.triggerCombineEvent('onPinch', status);
}
if (rotate) {
_this.triggerCombineEvent('onRotate', status);
}
};
_this.updateGestureStatus = function (e) {
var time = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["b" /* now */])();
_this.setGestureState({
time: time
});
if (!e.touches || !e.touches.length) {
return;
}
var _this$gesture4 = _this.gesture,
startTime = _this$gesture4.startTime,
startTouches = _this$gesture4.startTouches,
pinch = _this$gesture4.pinch,
rotate = _this$gesture4.rotate;
var touches = _this.getTouches(e);
var moveStatus = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["h" /* calcMoveStatus */])(startTouches, touches, time - startTime);
var mutliFingerStatus = void 0;
if (pinch || rotate) {
mutliFingerStatus = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["c" /* calcMutliFingerStatus */])(touches);
}
_this.setGestureState({
/* update status snapshot */
touches: touches,
mutliFingerStatus: mutliFingerStatus,
/* update duration status */
moveStatus: moveStatus
});
};
_this._handleTouchEnd = function (e) {
_this.triggerUserCb('end', e);
_this.event = e;
if (!_this.gesture) {
return;
}
_this.cleanPressTimer();
_this.updateGestureStatus(e);
_this.doSingleTouchEnd('end');
_this.checkIfMultiTouchEnd('end');
};
_this._handleTouchCancel = function (e) {
_this.triggerUserCb('cancel', e);
_this.event = e;
// Todo: wait to test cancel case
if (!_this.gesture) {
return;
}
_this.cleanPressTimer();
_this.updateGestureStatus(e);
_this.doSingleTouchEnd('cancel');
_this.checkIfMultiTouchEnd('cancel');
};
_this.triggerAllowEvent = function (type, status) {
if (_this.allowGesture()) {
_this.triggerCombineEvent(type, status);
} else {
_this.triggerSubEvent(type, status);
}
};
_this.doSingleTouchEnd = function (status) {
var _this$gesture5 = _this.gesture,
moveStatus = _this$gesture5.moveStatus,
pinch = _this$gesture5.pinch,
rotate = _this$gesture5.rotate,
press = _this$gesture5.press,
pan = _this$gesture5.pan,
direction = _this$gesture5.direction;
if (pinch || rotate) {
return;
}
if (moveStatus) {
var z = moveStatus.z,
velocity = moveStatus.velocity;
var swipe = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["i" /* shouldTriggerSwipe */])(z, velocity);
_this.setGestureState({
swipe: swipe
});
if (pan) {
// pan need end, it's a process
// sometimes, start with pan left, but end with pan right....
_this.triggerAllowEvent('onPan', status);
}
if (swipe) {
var directionEvName = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__util__["g" /* getDirectionEventName */])(direction);
// swipe just need a direction, it's a endpoint
_this.triggerAllowEvent('onSwipe', directionEvName);
return;
}
}
if (press) {
_this.triggerEvent('onPressUp');
return;
}
_this.triggerEvent('onTap');
};
_this.getTouchAction = function () {
var _this$props2 = _this.props,
enablePinch = _this$props2.enablePinch,
enableRotate = _this$props2.enableRotate;
var directionSetting = _this.directionSetting;
if (enablePinch || enableRotate || directionSetting === __WEBPACK_IMPORTED_MODULE_7__config__["a" /* DIRECTION_ALL */]) {
return 'pan-x pan-y';
}
if (directionSetting === __WEBPACK_IMPORTED_MODULE_7__config__["b" /* DIRECTION_VERTICAL */]) {
return 'pan-x';
}
if (directionSetting === __WEBPACK_IMPORTED_MODULE_7__config__["c" /* DIRECTION_HORIZONTAL */]) {
return 'pan-y';
}
return 'auto';
};
_this.directionSetting = directionMap[props.direction];
return _this;
}
__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_createClass___default()(Gesture, [{
key: 'componentWillUnmount',
value: function componentWillUnmount() {
this.cleanPressTimer();
}
}, {
key: 'render',
value: function render() {
var children = this.props.children;
var child = __WEBPACK_IMPORTED_MODULE_5_react___default.a.Children.only(children);
var touchAction = this.getTouchAction();
var events = {
onTouchStart: this._handleTouchStart,
onTouchMove: this._handleTouchMove,
onTouchCancel: this._handleTouchCancel,
onTouchEnd: this._handleTouchEnd
};
return __WEBPACK_IMPORTED_MODULE_5_react___default.a.cloneElement(child, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, events, { style: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({ touchAction: touchAction }, child.props.style || {}) }));
}
}]);
return Gesture;
}(__WEBPACK_IMPORTED_MODULE_5_react__["Component"]);
/* harmony default export */ __webpack_exports__["a"] = (Gesture);
Gesture.defaultProps = {
enableRotate: false,
enablePinch: false,
direction: 'all'
};
/***/ }),
/* 44 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (immutable) */ __webpack_exports__["b"] = now;
/* harmony export (immutable) */ __webpack_exports__["c"] = calcMutliFingerStatus;
/* harmony export (immutable) */ __webpack_exports__["h"] = calcMoveStatus;
/* harmony export (immutable) */ __webpack_exports__["d"] = calcRotation;
/* harmony export (immutable) */ __webpack_exports__["a"] = getEventName;
/* harmony export (immutable) */ __webpack_exports__["i"] = shouldTriggerSwipe;
/* harmony export (immutable) */ __webpack_exports__["e"] = shouldTriggerDirection;
/* unused harmony export getDirection */
/* harmony export (immutable) */ __webpack_exports__["f"] = getMovingDirection;
/* harmony export (immutable) */ __webpack_exports__["g"] = getDirectionEventName;
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__config__ = __webpack_require__(29);
/* tslint:disable:no-bitwise */
function _calcTriangleDistance(x, y) {
return Math.sqrt(x * x + y * y);
}
function _calcAngle(x, y) {
var radian = Math.atan2(y, x);
return 180 / (Math.PI / radian);
}
function now() {
return Date.now();
}
function calcMutliFingerStatus(touches) {
if (touches.length < 2) {
return;
}
var _touches$ = touches[0],
x1 = _touches$.x,
y1 = _touches$.y;
var _touches$2 = touches[1],
x2 = _touches$2.x,
y2 = _touches$2.y;
var deltaX = x2 - x1;
var deltaY = y2 - y1;
return {
x: deltaX,
y: deltaY,
z: _calcTriangleDistance(deltaX, deltaY),
angle: _calcAngle(deltaX, deltaY)
};
}
function calcMoveStatus(startTouches, touches, time) {
var _startTouches$ = startTouches[0],
x1 = _startTouches$.x,
y1 = _startTouches$.y;
var _touches$3 = touches[0],
x2 = _touches$3.x,
y2 = _touches$3.y;
var deltaX = x2 - x1;
var deltaY = y2 - y1;
var deltaZ = _calcTriangleDistance(deltaX, deltaY);
return {
x: deltaX,
y: deltaY,
z: deltaZ,
time: time,
velocity: deltaZ / time,
angle: _calcAngle(deltaX, deltaY)
};
}
function calcRotation(startMutliFingerStatus, mutliFingerStatus) {
var startAngle = startMutliFingerStatus.angle;
var angle = mutliFingerStatus.angle;
return angle - startAngle;
}
function getEventName(prefix, status) {
return prefix + status[0].toUpperCase() + status.slice(1);
}
function shouldTriggerSwipe(delta, velocity) {
return Math.abs(delta) >= __WEBPACK_IMPORTED_MODULE_0__config__["e" /* SWIPE */].threshold && Math.abs(velocity) > __WEBPACK_IMPORTED_MODULE_0__config__["e" /* SWIPE */].velocity;
}
function shouldTriggerDirection(direction, directionSetting) {
if (directionSetting & direction) {
return true;
}
return false;
}
/**
* @private
* get the direction between two points
* Note: will change next version
* @param {Number} x
* @param {Number} y
* @return {Number} direction
*/
function getDirection(x, y) {
if (x === y) {
return __WEBPACK_IMPORTED_MODULE_0__config__["f" /* DIRECTION_NONE */];
}
if (Math.abs(x) >= Math.abs(y)) {
return x < 0 ? __WEBPACK_IMPORTED_MODULE_0__config__["g" /* DIRECTION_LEFT */] : __WEBPACK_IMPORTED_MODULE_0__config__["h" /* DIRECTION_RIGHT */];
}
return y < 0 ? __WEBPACK_IMPORTED_MODULE_0__config__["i" /* DIRECTION_UP */] : __WEBPACK_IMPORTED_MODULE_0__config__["j" /* DIRECTION_DOWN */];
}
/**
* @private
* get the direction between tow points when touch moving
* Note: will change next version
* @param {Object} point1 coordinate point, include x & y attributes
* @param {Object} point2 coordinate point, include x & y attributes
* @return {Number} direction
*/
function getMovingDirection(point1, point2) {
var x1 = point1.x,
y1 = point1.y;
var x2 = point2.x,
y2 = point2.y;
var deltaX = x2 - x1;
var deltaY = y2 - y1;
if (deltaX === 0 && deltaY === 0) {
return __WEBPACK_IMPORTED_MODULE_0__config__["f" /* DIRECTION_NONE */];
}
if (Math.abs(deltaX) >= Math.abs(deltaY)) {
return deltaX < 0 ? __WEBPACK_IMPORTED_MODULE_0__config__["g" /* DIRECTION_LEFT */] : __WEBPACK_IMPORTED_MODULE_0__config__["h" /* DIRECTION_RIGHT */];
}
return deltaY < 0 ? __WEBPACK_IMPORTED_MODULE_0__config__["i" /* DIRECTION_UP */] : __WEBPACK_IMPORTED_MODULE_0__config__["j" /* DIRECTION_DOWN */];
}
function getDirectionEventName(direction) {
var name = void 0;
switch (direction) {
case __WEBPACK_IMPORTED_MODULE_0__config__["f" /* DIRECTION_NONE */]:
break;
case __WEBPACK_IMPORTED_MODULE_0__config__["g" /* DIRECTION_LEFT */]:
name = 'left';
break;
case __WEBPACK_IMPORTED_MODULE_0__config__["h" /* DIRECTION_RIGHT */]:
name = 'right';
break;
case __WEBPACK_IMPORTED_MODULE_0__config__["i" /* DIRECTION_UP */