any-touch
Advanced tools
Comparing version 0.6.0-beta.30 to 0.6.0
@@ -93,33 +93,29 @@ (function (global, factory) { | ||
var AnyEvent = (function () { | ||
function AnyEvent() { | ||
this.callbackMap = {}; | ||
this.targets = []; | ||
var default_1 = (function () { | ||
function default_1() { | ||
this.listenersMap = {}; | ||
} | ||
AnyEvent.prototype.target = function (el) { | ||
var _a; | ||
default_1.prototype.target = function (el) { | ||
var _this = this; | ||
var targets = Array.isArray(el) ? Array.from(el) : [el]; | ||
(_a = this.targets).push.apply(_a, __spread(targets)); | ||
return { | ||
on: function (eventName, listener) { | ||
_this.on(eventName, listener, { targets: targets }); | ||
_this.on(eventName, listener, { target: el }); | ||
} | ||
}; | ||
}; | ||
AnyEvent.prototype.on = function (eventName, listener, _a) { | ||
var targets = (_a === void 0 ? {} : _a).targets; | ||
if (void 0 === this.callbackMap[eventName]) { | ||
this.callbackMap[eventName] = []; | ||
default_1.prototype.on = function (eventName, listener, _a) { | ||
var target = (_a === void 0 ? {} : _a).target; | ||
if (void 0 === this.listenersMap[eventName]) { | ||
this.listenersMap[eventName] = []; | ||
} | ||
if (void 0 !== targets) { | ||
listener.targets = targets; | ||
if (void 0 !== target) { | ||
listener.target = target; | ||
} | ||
this.callbackMap[eventName].push(listener); | ||
this.listenersMap[eventName].push(listener); | ||
}; | ||
AnyEvent.prototype.off = function (eventName, listener) { | ||
var listeners = this.callbackMap[eventName]; | ||
default_1.prototype.off = function (eventName, listener) { | ||
var listeners = this.listenersMap[eventName]; | ||
if (void 0 !== listeners) { | ||
if (void 0 === listener) { | ||
delete this.callbackMap[eventName]; | ||
delete this.listenersMap[eventName]; | ||
} | ||
@@ -132,6 +128,6 @@ else { | ||
}; | ||
AnyEvent.prototype.emit = function (eventName, payload) { | ||
default_1.prototype.emit = function (eventName, payload, beforeHook) { | ||
var e_1, _a; | ||
var listeners = this.callbackMap[eventName]; | ||
var target = (payload || {}).target; | ||
if (beforeHook === void 0) { beforeHook = function () { return true; }; } | ||
var listeners = this.listenersMap[eventName]; | ||
if (void 0 !== listeners && 0 < listeners.length) { | ||
@@ -141,11 +137,6 @@ try { | ||
var listener = listeners_1_1.value; | ||
var targets = listener.targets; | ||
if (void 0 !== target | ||
&& void 0 !== targets | ||
&& findRealTargetEl(targets, target)) { | ||
var target = listener.target; | ||
if (beforeHook({ target: target })) { | ||
listener(payload); | ||
} | ||
else if (void 0 === targets) { | ||
listener(payload); | ||
} | ||
} | ||
@@ -160,68 +151,10 @@ } | ||
} | ||
return true; | ||
} | ||
else { | ||
return false; | ||
} | ||
}; | ||
AnyEvent.prototype.destroy = function () { | ||
this.callbackMap = {}; | ||
default_1.prototype.destroy = function () { | ||
this.listenersMap = {}; | ||
}; | ||
return AnyEvent; | ||
}()); | ||
function findRealTargetEl(targetEls, target) { | ||
var e_2, _a; | ||
var realTarget; | ||
if (void 0 !== targetEls) { | ||
try { | ||
for (var targetEls_1 = __values(targetEls), targetEls_1_1 = targetEls_1.next(); !targetEls_1_1.done; targetEls_1_1 = targetEls_1.next()) { | ||
var targetEl = targetEls_1_1.value; | ||
if (targetEl.contains(target)) { | ||
realTarget = targetEl; | ||
break; | ||
} | ||
} | ||
} | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
try { | ||
if (targetEls_1_1 && !targetEls_1_1.done && (_a = targetEls_1.return)) _a.call(targetEls_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
} | ||
return realTarget; | ||
} | ||
var default_1 = (function () { | ||
function default_1() { | ||
} | ||
return default_1; | ||
}()); | ||
var default_1$1 = (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
default_1.prototype.load = function (event) { | ||
var points = Array.from(event.touches).map(function (_a) { | ||
var clientX = _a.clientX, clientY = _a.clientY; | ||
return ({ clientX: clientX, clientY: clientY }); | ||
}); | ||
var changedPoints = Array.from(event.changedTouches).map(function (_a) { | ||
var clientX = _a.clientX, clientY = _a.clientY; | ||
return ({ clientX: clientX, clientY: clientY }); | ||
}); | ||
return { | ||
inputType: event.type.replace('touch', ''), | ||
changedPoints: changedPoints, | ||
points: points, | ||
nativeEvent: event, | ||
target: event.target | ||
}; | ||
}; | ||
return default_1; | ||
}(default_1)); | ||
var ObjectToString = Object.prototype.toString; | ||
@@ -235,3 +168,5 @@ function isRegExp(input) { | ||
var SUPPORT_TOUCH = 'ontouchstart' in window; | ||
var CLIENT_X = 'clientX'; | ||
var CLIENT_Y = 'clientY'; | ||
var COMPUTE_INTERVAL = 16; | ||
var INPUT_START = 'start'; | ||
@@ -241,19 +176,2 @@ var INPUT_MOVE = 'move'; | ||
var INPUT_END = 'end'; | ||
var TOUCH_START = 'touchstart'; | ||
var TOUCH_MOVE = 'touchmove'; | ||
var TOUCH_END = 'touchend'; | ||
var TOUCH_CANCEL = 'touchcancel'; | ||
var MOUSE_UP = 'mouseup'; | ||
var MOUSE_MOVE = 'mousemove'; | ||
var MOUSE_DOWN = 'mousedown'; | ||
var CLIENT_X = 'clientX'; | ||
var CLIENT_Y = 'clientY'; | ||
var COMPUTE_INTERVAL = 16; | ||
var STATUS_POSSIBLE = 'possible'; | ||
var STATUS_START = 'start'; | ||
var STATUS_MOVE = 'move'; | ||
var STATUS_END = 'end'; | ||
var STATUS_CANCELLED = 'cancel'; | ||
var STATUS_FAILED = 'failed'; | ||
var STATUS_RECOGNIZED = 'recognized'; | ||
var DIRECTION_LEFT = 'left'; | ||
@@ -264,2 +182,19 @@ var DIRECTION_RIGHT = 'right'; | ||
var NONE = 'none'; | ||
var TOUCH = 'touch'; | ||
var MOUSE = 'mouse'; | ||
var TOUCH_START = TOUCH + INPUT_START; | ||
var TOUCH_MOVE = TOUCH + INPUT_MOVE; | ||
var TOUCH_END = TOUCH + INPUT_END; | ||
var TOUCH_CANCEL = TOUCH + INPUT_CANCEL; | ||
var MOUSE_UP = MOUSE + DIRECTION_UP; | ||
var MOUSE_MOVE = MOUSE + INPUT_MOVE; | ||
var MOUSE_DOWN = MOUSE + DIRECTION_DOWN; | ||
var SUPPORT_TOUCH = "on" + TOUCH_START in window; | ||
var STATUS_POSSIBLE = 'p'; | ||
var STATUS_START = INPUT_START; | ||
var STATUS_MOVE = INPUT_MOVE; | ||
var STATUS_END = INPUT_END; | ||
var STATUS_RECOGNIZED = 'r'; | ||
var STATUS_FAILED = 'f'; | ||
var STATUS_CANCELLED = INPUT_CANCEL; | ||
@@ -270,5 +205,39 @@ function round2(n) { | ||
var default_1$1 = (function () { | ||
function default_1() { | ||
} | ||
return default_1; | ||
}()); | ||
var default_1$2 = (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
default_1.prototype.load = function (event) { | ||
var targets = []; | ||
var points = Array.from(event.touches).map(function (_a) { | ||
var clientX = _a.clientX, clientY = _a.clientY, target = _a.target; | ||
targets.push(target); | ||
return { clientX: clientX, clientY: clientY, target: target }; | ||
}); | ||
var changedPoints = Array.from(event.changedTouches).map(function (_a) { | ||
var clientX = _a.clientX, clientY = _a.clientY, target = _a.target; | ||
return ({ clientX: clientX, clientY: clientY, target: target }); | ||
}); | ||
return { | ||
inputType: event.type.replace('touch', ''), | ||
changedPoints: changedPoints, | ||
points: points, | ||
nativeEvent: event, | ||
target: event.target, | ||
targets: targets | ||
}; | ||
}; | ||
return default_1; | ||
}(default_1$1)); | ||
var default_1$3 = (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1() { | ||
var _this = _super.call(this) || this; | ||
@@ -281,3 +250,3 @@ _this.target = null; | ||
var clientX = event.clientX, clientY = event.clientY, type = event.type, button = event.button, target = event.target; | ||
var points = [{ clientX: clientX, clientY: clientY }]; | ||
var points = [{ clientX: clientX, clientY: clientY, target: target }]; | ||
var inputType; | ||
@@ -299,4 +268,4 @@ if (MOUSE_DOWN === type && 0 === button) { | ||
} | ||
var changedPoints = this.prevPoints || [{ clientX: clientX, clientY: clientY }]; | ||
this.prevPoints = [{ clientX: clientX, clientY: clientY }]; | ||
var changedPoints = this.prevPoints || [{ clientX: clientX, clientY: clientY, target: target }]; | ||
this.prevPoints = [{ clientX: clientX, clientY: clientY, target: target }]; | ||
if (void 0 !== inputType) { | ||
@@ -308,2 +277,3 @@ return { | ||
target: this.target, | ||
targets: [this.target], | ||
nativeEvent: event | ||
@@ -314,7 +284,7 @@ }; | ||
return default_1; | ||
}(default_1)); | ||
}(default_1$1)); | ||
var default_1$3 = (function () { | ||
var default_1$4 = (function () { | ||
function default_1() { | ||
var Input = SUPPORT_TOUCH ? default_1$1 : default_1$2; | ||
var Input = SUPPORT_TOUCH ? default_1$2 : default_1$3; | ||
this.adapter = new Input(); | ||
@@ -367,18 +337,35 @@ this.id = 0; | ||
var isEnd = (INPUT_END === inputType && 0 === pointLength) || INPUT_CANCEL === inputType; | ||
var timestamp = Date.now(); | ||
var timestamp = performance.now(); | ||
var _a = getCenter(points) || getCenter(changedPoints), x = _a.x, y = _a.y; | ||
var currentTarget = nativeEvent.currentTarget; | ||
return __assign(__assign({}, inputBase), { preventDefault: function () { return nativeEvent.preventDefault(); }, x: x, y: y, | ||
return __assign(__assign({}, inputBase), { x: x, y: y, | ||
timestamp: timestamp, | ||
isStart: isStart, isEnd: isEnd, | ||
pointLength: pointLength, | ||
currentTarget: currentTarget }); | ||
currentTarget: currentTarget, | ||
getOffset: function (el) { | ||
if (el === void 0) { el = currentTarget; } | ||
var rect = el.getBoundingClientRect(); | ||
return { x: x - Math.round(rect.left), y: y - Math.round(rect.top) }; | ||
} }); | ||
} | ||
function dispatchDomEvent (el, payload, eventInit) { | ||
if (!Event) | ||
return; | ||
var _a, _b; | ||
var target = payload.target, currentTarget = payload.currentTarget, type = payload.type, data = __rest(payload, ["target", "currentTarget", "type"]); | ||
var event = new Event(type, eventInit); | ||
Object.assign(event, data); | ||
var event; | ||
if (void 0 !== Event) { | ||
event = new Event(type, eventInit); | ||
} | ||
else { | ||
event = document.createEvent('HTMLEvents'); | ||
event.initEvent(type, (_a = eventInit) === null || _a === void 0 ? void 0 : _a.bubbles, (_b = eventInit) === null || _b === void 0 ? void 0 : _b.cancelable); | ||
} | ||
Object.assign(event, data, { | ||
match: function () { | ||
return payload.targets.every(function (target) { | ||
return event.currentTarget.contains(target); | ||
}); | ||
} | ||
}); | ||
return el.dispatchEvent(event); | ||
@@ -410,3 +397,3 @@ } | ||
TOUCH_EVENT_NAMES.forEach(function (eventName) { | ||
el.addEventListener(eventName, callback); | ||
el.addEventListener(eventName, callback, options); | ||
}); | ||
@@ -420,9 +407,9 @@ return function () { | ||
else { | ||
el.addEventListener('mousedown', callback); | ||
window.addEventListener('mousemove', callback); | ||
window.addEventListener('mouseup', callback); | ||
el.addEventListener(MOUSE_DOWN, callback, options); | ||
window.addEventListener(MOUSE_MOVE, callback, options); | ||
window.addEventListener(MOUSE_UP, callback, options); | ||
return function () { | ||
el.removeEventListener('mousedown', callback); | ||
window.removeEventListener('mousemove', callback); | ||
window.removeEventListener('mouseup', callback); | ||
el.removeEventListener(MOUSE_DOWN, callback); | ||
window.removeEventListener(MOUSE_MOVE, callback); | ||
window.removeEventListener(MOUSE_UP, callback); | ||
}; | ||
@@ -469,2 +456,22 @@ } | ||
function emit2(at, payload) { | ||
var type = payload.type, target = payload.target, targets = payload.targets; | ||
at.emit(type, payload, function (data) { | ||
var _a; | ||
if (void 0 !== ((_a = data) === null || _a === void 0 ? void 0 : _a.target)) { | ||
var currentTarget_1 = data.target; | ||
return targets.every(function (target) { return currentTarget_1.contains(target); }); | ||
} | ||
return true; | ||
}); | ||
var AT_AFTER = 'at:after'; | ||
at.emit(AT_AFTER, payload); | ||
if (!!at.options.domEvents | ||
&& void 0 !== at.el | ||
&& null !== target) { | ||
dispatchDomEvent(target, payload, at.options.domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, payload), { type: AT_AFTER }), at.options.domEvents); | ||
} | ||
} | ||
var DEFAULT_OPTIONS = { | ||
@@ -482,8 +489,20 @@ domEvents: { bubbles: true, cancelable: true }, | ||
_this.el = el; | ||
_this.input = new default_1$3(); | ||
_this.input = new default_1$4(); | ||
_this.options = __assign(__assign({}, DEFAULT_OPTIONS), options); | ||
_this.recognizerMap = AnyTouch.recognizerMap; | ||
_this.recognizers = AnyTouch.recognizers; | ||
if (void 0 !== _this.el) { | ||
_this._unbindEl = bindElement(_this.el, _this.catchEvent.bind(_this)); | ||
if (void 0 !== el) { | ||
el.style.webkitTapHighlightColor = 'rgba(0,0,0,0)'; | ||
var supportsPassive_1 = false; | ||
try { | ||
var opts = {}; | ||
Object.defineProperty(opts, 'passive', ({ | ||
get: function () { | ||
supportsPassive_1 = true; | ||
} | ||
})); | ||
window.addEventListener('_', function () { return void 0; }, opts); | ||
} | ||
catch (_a) { } | ||
_this.on('unbind', bindElement(el, _this.catchEvent.bind(_this), !_this.options.isPreventDefault && supportsPassive_1 ? { passive: true } : false)); | ||
} | ||
@@ -506,9 +525,12 @@ return _this; | ||
if (void 0 !== input) { | ||
this.emit('at:touch', input); | ||
this.emit("at:touch" + input.inputType, input); | ||
if (false !== this.options.domEvents) { | ||
var AT_TOUCH = "at:" + TOUCH; | ||
var AT_TOUCH_WITH_STATUS = AT_TOUCH + input.inputType; | ||
this.emit(AT_TOUCH, input); | ||
this.emit(AT_TOUCH_WITH_STATUS, input); | ||
var domEvents = this.options.domEvents; | ||
if (false !== domEvents) { | ||
var target = event.target; | ||
if (null !== target) { | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: 'at:touch' }), this.options.domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: "at:touch" + input.inputType }), this.options.domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT_TOUCH }), domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT_TOUCH_WITH_STATUS }), domEvents); | ||
} | ||
@@ -524,8 +546,9 @@ } | ||
var payload = __assign(__assign(__assign({}, input), ev), { type: type, baseType: recognizer.name }); | ||
Object.freeze(payload); | ||
if (void 0 === _this.beforeEachHook) { | ||
_this.emit2(payload); | ||
emit2(_this, payload); | ||
} | ||
else { | ||
_this.beforeEachHook(recognizer, function () { | ||
_this.emit2(payload); | ||
emit2(_this, payload); | ||
}); | ||
@@ -554,13 +577,2 @@ } | ||
}; | ||
AnyTouch.prototype.emit2 = function (payload) { | ||
var type = payload.type, target = payload.target; | ||
this.emit('at:after', payload); | ||
this.emit(type, payload); | ||
if (false !== this.options.domEvents | ||
&& void 0 !== this.el | ||
&& void 0 !== target) { | ||
dispatchDomEvent(target, payload, this.options.domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, payload), { type: 'at:after' }), this.options.domEvents); | ||
} | ||
}; | ||
AnyTouch.prototype.get = function (name) { | ||
@@ -572,10 +584,7 @@ return this.recognizerMap[name]; | ||
}; | ||
AnyTouch.prototype._unbindEl = function () { }; | ||
AnyTouch.prototype.destroy = function () { | ||
if (this.el) { | ||
this._unbindEl(); | ||
} | ||
this.callbackMap = {}; | ||
this.emit('unbind'); | ||
this.listenersMap = {}; | ||
}; | ||
AnyTouch.version = '0.6.0-beta.29'; | ||
AnyTouch.version = '1.0.1'; | ||
AnyTouch.recognizers = []; | ||
@@ -590,3 +599,3 @@ AnyTouch.recognizerMap = {}; | ||
return AnyTouch; | ||
}(AnyEvent)); | ||
}(default_1)); | ||
@@ -624,2 +633,3 @@ function resetStatus (recognizer) { | ||
_e[STATUS_MOVE] = (_g = {}, | ||
_g[INPUT_START] = STATUS_FAILED, | ||
_g[INPUT_MOVE] = STATUS_CANCELLED, | ||
@@ -644,8 +654,8 @@ _g[INPUT_END] = STATUS_END, | ||
var computed = recognizer.computed; | ||
recognizer.isRecognized = -1 < [STATUS_START, STATUS_MOVE, STATUS_END, STATUS_CANCELLED, STATUS_RECOGNIZED].indexOf(recognizer.status); | ||
recognizer.isRecognized = [STATUS_START, STATUS_MOVE].includes(recognizer.status); | ||
var name = recognizer.name, status = recognizer.status, isRecognized = recognizer.isRecognized; | ||
if (isRecognized) { | ||
if (INPUT_END !== inputType) { | ||
emit(name, computed); | ||
} | ||
emit(name, computed); | ||
} | ||
if (isRecognized || [STATUS_END, STATUS_CANCELLED].includes(recognizer.status)) { | ||
emit(name + status, computed); | ||
@@ -656,3 +666,3 @@ } | ||
var default_1$4 = (function () { | ||
var default_1$5 = (function () { | ||
function default_1(options) { | ||
@@ -761,3 +771,3 @@ this.options = options; | ||
var default_1$5 = (function () { | ||
var default_1$6 = (function () { | ||
function default_1() { | ||
@@ -784,3 +794,3 @@ } | ||
var default_1$6 = (function () { | ||
var default_1$7 = (function () { | ||
function default_1() { | ||
@@ -821,3 +831,3 @@ this.displacementX = 0; | ||
var default_1$7 = (function () { | ||
var default_1$8 = (function () { | ||
function default_1() { | ||
@@ -844,3 +854,3 @@ this.maxPointLength = 0; | ||
var default_1$8 = (function () { | ||
var default_1$9 = (function () { | ||
function default_1() { | ||
@@ -882,3 +892,3 @@ this.velocityX = 0; | ||
var default_1$9 = (function () { | ||
var default_1$a = (function () { | ||
function default_1() { | ||
@@ -912,3 +922,3 @@ } | ||
}; | ||
var default_1$a = (function (_super) { | ||
var default_1$b = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -932,3 +942,3 @@ function default_1(options) { | ||
default_1.prototype._isValidInterval = function () { | ||
var now = Date.now(); | ||
var now = performance.now(); | ||
if (void 0 === this.prevTapTime) { | ||
@@ -946,3 +956,3 @@ this.prevTapTime = now; | ||
var inputType = input.inputType, x = input.x, y = input.y; | ||
this.computed = this.compute([default_1$7, default_1$6], input); | ||
this.computed = this.compute([default_1$8, default_1$7], input); | ||
if (INPUT_END !== inputType) | ||
@@ -997,3 +1007,3 @@ return; | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
@@ -1005,3 +1015,3 @@ var DEFAULT_OPTIONS$2 = { | ||
}; | ||
var default_1$b = (function (_super) { | ||
var default_1$c = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -1012,3 +1022,3 @@ function default_1(options) { | ||
default_1.prototype.test = function (input) { | ||
var inputType = input.inputType, pointLength = input.pointLength; | ||
var pointLength = input.pointLength; | ||
var distance = this.computed.distance; | ||
@@ -1019,13 +1029,11 @@ return ((this.isRecognized || this.options.threshold < distance) && | ||
default_1.prototype.recognize = function (input, emit) { | ||
this.computed = this.compute([default_1$8, default_1$6, default_1$5], input); | ||
this.computed = this.compute([default_1$9, default_1$7, default_1$6], input); | ||
var isRecognized = recognizeForPressMoveLike(this, input, emit); | ||
if (isRecognized) { | ||
var inputType = input.inputType; | ||
if (INPUT_END !== inputType) { | ||
emit(this.options.name + this.computed.direction, this.computed); | ||
} | ||
emit(this.options.name + this.computed.direction, this.computed); | ||
} | ||
}; | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
@@ -1038,3 +1046,3 @@ var DEFAULT_OPTIONS$3 = { | ||
}; | ||
var default_1$c = (function (_super) { | ||
var default_1$d = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -1054,3 +1062,3 @@ function default_1(options) { | ||
default_1.prototype.recognize = function (input, emit) { | ||
this.computed = this.compute([default_1$7, default_1$8, default_1$6], input); | ||
this.computed = this.compute([default_1$8, default_1$9, default_1$7], input); | ||
if (this.test(input)) { | ||
@@ -1062,3 +1070,3 @@ emit(this.options.name, this.computed); | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
@@ -1068,6 +1076,6 @@ var DEFAULT_OPTIONS$4 = { | ||
pointLength: 1, | ||
positionTolerance: 9, | ||
maxDistance: 9, | ||
minPressTime: 251, | ||
}; | ||
var default_1$d = (function (_super) { | ||
var default_1$e = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -1102,5 +1110,5 @@ function default_1(options) { | ||
var pointLength = input.pointLength; | ||
this.computed = this.compute([default_1$6], input); | ||
this.computed = this.compute([default_1$7], input); | ||
var distance = this.computed.distance; | ||
return this.options.positionTolerance > distance; | ||
return this.options.maxDistance > distance; | ||
}; | ||
@@ -1111,3 +1119,3 @@ default_1.prototype.cancel = function () { | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
@@ -1119,3 +1127,3 @@ var DEFAULT_OPTIONS$5 = { | ||
}; | ||
var default_1$e = (function (_super) { | ||
var default_1$f = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -1128,6 +1136,8 @@ function default_1(options) { | ||
var scale = this.computed.scale; | ||
return this.isValidPointLength(pointLength) && void 0 !== scale && (this.options.threshold < Math.abs(scale - 1) || this.isRecognized); | ||
return this.isValidPointLength(pointLength) | ||
&& void 0 !== scale | ||
&& (this.options.threshold < Math.abs(scale - 1) || this.isRecognized); | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
var computed = this.compute([default_1$9], input); | ||
var computed = this.compute([default_1$a], input); | ||
if ("activeV" in computed) { | ||
@@ -1139,3 +1149,3 @@ this.computed = __assign(__assign({}, this.computed), computeScale(computed)); | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
@@ -1147,3 +1157,3 @@ var DEFAULT_OPTIONS$6 = { | ||
}; | ||
var default_1$f = (function (_super) { | ||
var default_1$g = (function (_super) { | ||
__extends(default_1, _super); | ||
@@ -1159,3 +1169,3 @@ function default_1(options) { | ||
default_1.prototype.recognize = function (input, emit) { | ||
var computed = this.compute([default_1$9], input); | ||
var computed = this.compute([default_1$a], input); | ||
if ("activeV" in computed) { | ||
@@ -1167,5 +1177,4 @@ this.computed = __assign(__assign({}, this.computed), computeAngle(computed)); | ||
return default_1; | ||
}(default_1$4)); | ||
}(default_1$5)); | ||
AnyTouch.use(default_1$a); | ||
AnyTouch.use(default_1$b); | ||
@@ -1176,8 +1185,16 @@ AnyTouch.use(default_1$c); | ||
AnyTouch.use(default_1$f); | ||
AnyTouch.Tap = default_1$a; | ||
AnyTouch.Pan = default_1$b; | ||
AnyTouch.Swipe = default_1$c; | ||
AnyTouch.Press = default_1$d; | ||
AnyTouch.Pinch = default_1$e; | ||
AnyTouch.Rotate = default_1$f; | ||
AnyTouch.use(default_1$g); | ||
AnyTouch.Tap = default_1$b; | ||
AnyTouch.Pan = default_1$c; | ||
AnyTouch.Swipe = default_1$d; | ||
AnyTouch.Press = default_1$e; | ||
AnyTouch.Pinch = default_1$f; | ||
AnyTouch.Rotate = default_1$g; | ||
AnyTouch.STATUS_POSSIBLE = STATUS_POSSIBLE; | ||
AnyTouch.STATUS_START = STATUS_START; | ||
AnyTouch.STATUS_MOVE = STATUS_MOVE; | ||
AnyTouch.STATUS_END = STATUS_END; | ||
AnyTouch.STATUS_CANCELLED = STATUS_CANCELLED; | ||
AnyTouch.STATUS_FAILED = STATUS_FAILED; | ||
AnyTouch.STATUS_RECOGNIZED = STATUS_RECOGNIZED; | ||
@@ -1184,0 +1201,0 @@ return AnyTouch; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).AnyTouch=e()}(this,(function(){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};function e(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function r(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t}var s=function(){function t(){this.callbackMap={},this.targets=[]}return t.prototype.target=function(t){var e,n=this,i=Array.isArray(t)?Array.from(t):[t];return(e=this.targets).push.apply(e,r(i)),{on:function(t,e){n.on(t,e,{targets:i})}}},t.prototype.on=function(t,e,n){var i=(void 0===n?{}:n).targets;void 0===this.callbackMap[t]&&(this.callbackMap[t]=[]),void 0!==i&&(e.targets=i),this.callbackMap[t].push(e)},t.prototype.off=function(t,e){var n=this.callbackMap[t];if(void 0!==n)if(void 0===e)delete this.callbackMap[t];else{var i=n.findIndex((function(t){return t===e}));n.splice(i,1)}},t.prototype.emit=function(t,e){var n,o,r=this.callbackMap[t],s=(e||{}).target;if(void 0!==r&&0<r.length){try{for(var u=i(r),c=u.next();!c.done;c=u.next()){var p=c.value,h=p.targets;void 0!==s&&void 0!==h&&a(h,s)?p(e):void 0===h&&p(e)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(o=u.return)&&o.call(u)}finally{if(n)throw n.error}}return!0}return!1},t.prototype.destroy=function(){this.callbackMap={}},t}();function a(t,e){var n,o,r;if(void 0!==t)try{for(var s=i(t),a=s.next();!a.done;a=s.next()){var u=a.value;if(u.contains(e)){r=u;break}}}catch(t){n={error:t}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return r}var u=function(){},c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.load=function(t){var e=Array.from(t.touches).map((function(t){return{clientX:t.clientX,clientY:t.clientY}})),n=Array.from(t.changedTouches).map((function(t){return{clientX:t.clientX,clientY:t.clientY}}));return{inputType:t.type.replace("touch",""),changedPoints:n,points:e,nativeEvent:t,target:t.target}},n}(u),p=Object.prototype.toString;var h="ontouchstart"in window,l="cancel",d="end",v="start",f="move",m="end",y="cancel",g="failed",T="recognized";function b(t){return Math.round(100*t)/100}var x=function(t){function n(){var e=t.call(this)||this;return e.target=null,e.isPressed=!1,e}return e(n,t),n.prototype.load=function(t){var e,n=t.clientX,i=t.clientY,o=t.type,r=t.button,s=t.target,a=[{clientX:n,clientY:i}];"mousedown"===o&&0===r?(this.target=s,this.isPressed=!0,e="start"):this.isPressed&&("mousemove"===o?e="move":"mouseup"===o&&(a=[],e=d,this.isPressed=!1));var u=this.prevPoints||[{clientX:n,clientY:i}];if(this.prevPoints=[{clientX:n,clientY:i}],void 0!==e)return{inputType:e,changedPoints:u,points:a,target:this.target,nativeEvent:t}},n}(u),M=function(){function t(){var t=h?c:x;this.adapter=new t,this.id=0}return t.prototype.transform=function(t){this.prevInput=this.activeInput;var e=this.adapter.load(t);if(void 0!==e){var i=Number.MAX_SAFE_INTEGER>this.id?++this.id:1,o=function(t){var e=t.inputType,i=t.points,o=t.changedPoints,r=t.nativeEvent,s=i.length,a="start"===e,u=d===e&&0===s||l===e,c=Date.now(),p=P(i)||P(o),h=p.x,v=p.y,f=r.currentTarget;return n(n({},t),{preventDefault:function(){return r.preventDefault()},x:h,y:v,timestamp:c,isStart:a,isEnd:u,pointLength:s,currentTarget:f})}(n(n({},e),{id:i}));this.activeInput=o;var r=o.isStart,s=o.pointLength;return r&&(this.startInput=o,this.prevInput=void 0,this.startMultiInput=1<s?o:void 0),n(n({},o),{prevInput:this.prevInput,startMultiInput:this.startMultiInput,startInput:this.startInput})}},t}();function P(t){var e=t.length;if(0<e){if(1===e){var n=t[0],i=n.clientX,o=n.clientY;return{x:Math.round(i),y:Math.round(o)}}var r=t.reduce((function(t,e){return t.x+=e.clientX,t.y+=e.clientY,t}),{x:0,y:0});return{x:Math.round(r.x/e),y:Math.round(r.y/e)}}}function w(t,e,n){if(Event){e.target,e.currentTarget;var i=e.type,o=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}(e,["target","currentTarget","type"]),r=new Event(i,n);return Object.assign(r,o),t.dispatchEvent(r)}}function E(t,e){if(!e.isPreventDefault)return!1;var n,i=!0;if(null!==t.target){var o=e.preventDefaultExclude;if(n=o,"[object RegExp]"===p.call(n)){if("tagName"in t.target){var r=t.target.tagName;i=!o.test(r)}}else(function(t){return"[object Function]"===p.call(t)})(o)&&(i=!o(t))}return i}var X=["touchstart","touchmove","touchend","touchcancel"];function L(t,e,n){var i,o=null===(i=n)||void 0===i?void 0:i.name;if(void 0===o||void 0===t.recognizerMap[o]){var r=new e(n);t.recognizerMap[r.name]=r,r.recognizerMap=t.recognizerMap,t.recognizers.push(t.recognizerMap[r.name])}}function Y(t,e){var n,r;if(void 0===e)t.recognizers=[],t.recognizerMap={};else try{for(var s=i(t.recognizers.entries()),a=s.next();!a.done;a=s.next()){var u=o(a.value,2),c=u[0];if(e===u[1].options.name){t.recognizers.splice(c,1),delete t.recognizerMap[e];break}}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}var z={domEvents:{bubbles:!0,cancelable:!0},isPreventDefault:!0,preventDefaultExclude:/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/},I=function(t){function o(e,i){var r=t.call(this)||this;return r.recognizerMap={},r.recognizers=[],r.el=e,r.input=new M,r.options=n(n({},z),i),r.recognizerMap=o.recognizerMap,r.recognizers=o.recognizers,void 0!==r.el&&(r._unbindEl=function(t,e,n){return h?(X.forEach((function(n){t.addEventListener(n,e)})),function(){X.forEach((function(n){t.removeEventListener(n,e)}))}):(t.addEventListener("mousedown",e),window.addEventListener("mousemove",e),window.addEventListener("mouseup",e),function(){t.removeEventListener("mousedown",e),window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",e)})}(r.el,r.catchEvent.bind(r))),r}return e(o,t),o.prototype.use=function(t,e){L(this,t,e)},o.prototype.removeUse=function(t){Y(this,t)},o.prototype.catchEvent=function(t){var e,o,r=this;E(t,this.options)&&t.preventDefault();var s=this.input.transform(t);if(void 0!==s){if(this.emit("at:touch",s),this.emit("at:touch"+s.inputType,s),!1!==this.options.domEvents){var a=t.target;null!==a&&(w(a,n(n({},s),{type:"at:touch"}),this.options.domEvents),w(a,n(n({},s),{type:"at:touch"+s.inputType}),this.options.domEvents))}var u={},c=function(t){if(t.disabled)return"continue";t.input=s,t.computedGroup=u,t.recognize(s,(function(e,i){var o=n(n(n({},s),i),{type:e,baseType:t.name});void 0===r.beforeEachHook?r.emit2(o):r.beforeEachHook(t,(function(){r.emit2(o)}))})),u=t.computedGroup};try{for(var p=i(this.recognizers),h=p.next();!h.done;h=p.next()){c(h.value)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(e)throw e.error}}}},o.prototype.beforeEach=function(t){this.beforeEachHook=t},o.prototype.emit2=function(t){var e=t.type,i=t.target;this.emit("at:after",t),this.emit(e,t),!1!==this.options.domEvents&&void 0!==this.el&&void 0!==i&&(w(i,t,this.options.domEvents),w(i,n(n({},t),{type:"at:after"}),this.options.domEvents))},o.prototype.get=function(t){return this.recognizerMap[t]},o.prototype.set=function(t){this.options=n(n({},this.options),t)},o.prototype._unbindEl=function(){},o.prototype.destroy=function(){this.el&&this._unbindEl(),this.callbackMap={}},o.version="0.6.0-beta.29",o.recognizers=[],o.recognizerMap={},o.use=function(t,e){L(o,t,e)},o.removeUse=function(t){Y(o,t)},o}(s);function _(t){-1!==[m,y,T,g].indexOf(t.status)&&(t.status="possible")}function D(t,e,n){var i=t.test(e);_(t);var o=e.inputType;t.status=function(t,e,n){var i,o,r,s,a,u,c,p={1:(i={},i.possible=(o={},o.move=v,o),i[v]=(r={},r.move=f,r[d]=m,r[l]=y,r),i[f]=(s={},s.move=f,s[d]=m,s[l]=y,s),i),0:(a={},a[v]=(u={},u.move=y,u[d]=m,u[l]=y,u),a[f]=(c={},c.move=y,c[d]=m,c[l]=y,c),a)};return void 0!==p[Number(t)][e]&&p[Number(t)][e][n]||e}(i,t.status,o);var r=t.computed;t.isRecognized=-1<[v,f,m,y,T].indexOf(t.status);var s=t.name,a=t.status;return t.isRecognized&&(d!==o&&n(s,r),n(s+a,r)),i}var V=function(){function t(t){this.options=t,this.name=this.options.name,this.disabled=!1,this.status="possible",this.isRecognized=!1,this.computed={},this.computedGroup={},this.usedComputeFunctionMap={},this.recognizerMap={}}return t.prototype.set=function(t){return void 0!==t&&(this.options=n(n({},this.options),t)),this},t.prototype.isValidPointLength=function(t){return 0===this.options.pointLength||this.options.pointLength===t},t.prototype.compute=function(t){for(var e,o,s,a=[],u=1;u<arguments.length;u++)a[u-1]=arguments[u];var c=Object.create(null);try{for(var p=i(t),h=p.next();!h.done;h=p.next()){var l=h.value,d=l._id,v=this,f=v.computedGroup,m=v.usedComputeFunctionMap;void 0===m[d]&&(m[d]=new l),f[d]=f[d]||(s=m[d]).compute.apply(s,r(a)),c=n(n({},c),f[d])}}catch(t){e={error:t}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(e)throw e.error}}return this.computed=c,c},t}(),O=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},C=function(t){return t/Math.PI*180},F=function(t,e){var n=function(t,e){var n=O(t)*O(e);if(0===n)return 0;var i=function(t,e){return t.x*e.x+t.y*e.y}(t,e)/n;return i>1&&(i=1),Math.acos(i)}(t,e);return function(t,e){return t.x*e.y-e.x*t.y}(t,e)>0&&(n*=-1),C(n)},j=function(t,e){return t===e?"none":Math.abs(t)>Math.abs(e)?0<t?"right":"left":0<e?"down":"up"};var k=function(){function t(){}return t.prototype.compute=function(t){var e=t.prevInput,n=0,i=0,o=0;if(void 0!==e&&(n=t.x-e.x,i=t.y-e.y,0!==n||0!==i)){var r=Math.sqrt(Math.pow(n,2)+Math.pow(i,2));o=Math.round(C(Math.acos(Math.abs(n)/r)))}return{deltaX:n,deltaY:i,deltaXYAngle:o}},t._id="ComputeDeltaXY",t}(),A=function(){function t(){this.displacementX=0,this.displacementY=0,this.distanceX=0,this.distanceY=0,this.distance=0,this.overallDirection="none"}return t.prototype.compute=function(t){var e=t.inputType,n=t.startInput;"start"===e?(this.displacementX=0,this.displacementY=0,this.distanceX=0,this.distanceY=0,this.distance=0,this.overallDirection="none"):"move"===e&&(this.displacementX=Math.round(t.points[0].clientX-n.points[0].clientX),this.displacementY=Math.round(t.points[0].clientY-n.points[0].clientY),this.distanceX=Math.abs(this.displacementX),this.distanceY=Math.abs(this.displacementY),this.distance=Math.round(O({x:this.distanceX,y:this.distanceY})),this.overallDirection=j(this.displacementX,this.displacementY));var i=this;return{displacementX:i.displacementX,displacementY:i.displacementY,distanceX:i.distanceX,distanceY:i.distanceY,distance:i.distance,overallDirection:i.overallDirection}},t._id="ComputeDistance",t}(),S=function(){function t(){this.maxPointLength=0}return t.prototype.compute=function(t){return"start"===t.inputType&&(this.maxPointLength=t.pointLength),{maxPointLength:this.maxPointLength}},t._id="ComputeMaxLength",t}();var N=function(){function t(){this.velocityX=0,this.velocityY=0,this.speedX=0,this.speedY=0}return t.prototype.compute=function(t){if(void 0!==t){var e=t.inputType;this._lastValidInput=this._lastValidInput||t.startInput;var n=t.timestamp-this._lastValidInput.timestamp;if("move"===e&&16<n){var i=t.x-this._lastValidInput.x,o=t.y-this._lastValidInput.y;this.speedX=Math.round(i/n*100)/100,this.speedY=Math.round(o/n*100)/100,this.velocityX=Math.abs(this.speedX),this.velocityY=Math.abs(this.speedY),this.direction=j(i,o)||this.direction,this._lastValidInput=t}}var r=this;return{velocityX:r.velocityX,velocityY:r.velocityY,speedX:r.speedX,speedY:r.speedY,direction:r.direction}},t._id="ComputeVAndDir",t}();function R(t){return{x:t.points[1].clientX-t.points[0].clientX,y:t.points[1].clientY-t.points[0].clientY}}var G=function(){function t(){}return t.prototype.compute=function(t){var e=t.prevInput,n=t.startMultiInput;if(void 0!==n&&void 0!==e&&t.id!==n.id&&1<t.pointLength)return{startV:R(n),prevV:R(e),activeV:R(t)}},t._id="ComputeVectorForMutli",t}(),U={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},H=function(t){function i(e){var i=t.call(this,n(n({},U),e))||this;return i.tapCount=0,i}return e(i,t),i.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var e=O({x:t.x-this.prevTapPoint.x,y:t.y-this.prevTapPoint.y});return this.prevTapPoint=t,this.options.maxDistanceFromPrevTap>=e}return this.prevTapPoint=t,!0},i.prototype._isValidInterval=function(){var t=Date.now();if(void 0===this.prevTapTime)return this.prevTapTime=t,!0;var e=t-this.prevTapTime;return this.prevTapTime=t,e<this.options.waitNextTapTime},i.prototype.recognize=function(t,e){var i=t.inputType,o=t.x,r=t.y;this.computed=this.compute([S,A],t),d===i&&(this.status="possible",this.test(t)?(this.cancelCountDownToFail(),this._isValidDistanceFromPrevTap({x:o,y:r})&&this._isValidInterval()?this.tapCount++:this.tapCount=1,0==this.tapCount%this.options.tapTimes?(this.status=T,e(this.options.name,n(n({},this.computed),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=g))},i.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=g,t.reset()}),this.options.waitNextTapTime)},i.prototype.cancelCountDownToFail=function(){clearTimeout(this._countDownToFailTimer)},i.prototype.reset=function(){this.tapCount=0,this.prevTapPoint=void 0,this.prevTapTime=void 0},i.prototype.test=function(t){var e=t.startInput,n=t.timestamp-e.timestamp,i=this.computed,o=i.maxPointLength,r=i.distance;return o===this.options.pointLength&&this.options.maxDistance>=r&&this.options.maxPressTime>n},i}(V),q={name:"pan",threshold:10,pointLength:1},B=function(t){function i(e){return t.call(this,n(n({},q),e))||this}return e(i,t),i.prototype.test=function(t){t.inputType;var e=t.pointLength,n=this.computed.distance;return(this.isRecognized||this.options.threshold<n)&&this.isValidPointLength(e)},i.prototype.recognize=function(t,e){if(this.computed=this.compute([N,A,k],t),D(this,t,e)){var n=t.inputType;d!==n&&e(this.options.name+this.computed.direction,this.computed)}},i}(V),$={name:"swipe",threshold:10,velocity:.3,pointLength:1},J=function(t){function i(e){return t.call(this,n(n({},$),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.inputType;if(d!==e)return!1;var n=this.computed,i=n.velocityX,o=n.velocityY,r=n.maxPointLength,s=n.distance;return this.options.pointLength===r&&this.options.threshold<s&&this.options.velocity<Math.max(i,o)},i.prototype.recognize=function(t,e){this.computed=this.compute([S,N,A],t),this.test(t)&&(e(this.options.name,this.computed),e(this.options.name+this.computed.direction,this.computed))},i}(V),K={name:"press",pointLength:1,positionTolerance:9,minPressTime:251},Q=function(t){function i(e){return t.call(this,n(n({},K),e))||this}return e(i,t),i.prototype.recognize=function(t,e){var n=this,i=t.inputType,o=t.startInput,r=t.pointLength;if("start"===i&&this.isValidPointLength(r))_(this),this.cancel(),this._timeoutId=setTimeout((function(){n.status=T,e(n.options.name,t)}),this.options.minPressTime);else if(d===i&&T===this.status)e(this.options.name+"up",this.computed);else{var s=t.timestamp-o.timestamp;(!this.test(t)||this.options.minPressTime>s&&[d,l].includes(i))&&(this.cancel(),this.status=g)}},i.prototype.test=function(t){t.pointLength;this.computed=this.compute([A],t);var e=this.computed.distance;return this.options.positionTolerance>e},i.prototype.cancel=function(){clearTimeout(this._timeoutId)},i}(V),W={name:"pinch",threshold:0,pointLength:2},Z=function(t){function i(e){return t.call(this,n(n({},W),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=this.computed.scale;return this.isValidPointLength(e)&&void 0!==n&&(this.options.threshold<Math.abs(n-1)||this.isRecognized)},i.prototype.recognize=function(t,e){var i,o,r,s,a,u=this.compute([G],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=b(O(s)/O(r)),{scale:b(O(s)/O(o)),deltaScale:a}))),D(this,t,e)},i}(V),tt={name:"rotate",threshold:0,pointLength:2},et=function(t){function i(e){return t.call(this,n(n({},tt),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=this.computed.angle;return this.isValidPointLength(e)&&(this.options.threshold<Math.abs(n)||this.isRecognized)},i.prototype.recognize=function(t,e){var i,o,r,s,a,u=this.compute([G],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=Math.round(F(s,r)),{angle:Math.round(F(s,o)),deltaAngle:a}))),D(this,t,e)},i}(V);return I.use(H),I.use(B),I.use(J),I.use(Q),I.use(Z),I.use(et),I.Tap=H,I.Pan=B,I.Swipe=J,I.Press=Q,I.Pinch=Z,I.Rotate=et,I})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).AnyTouch=e()}(this,(function(){"use strict";var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};function e(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function i(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function r(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t}var s=function(){function t(){this.listenersMap={}}return t.prototype.target=function(t){var e=this;return{on:function(n,i){e.on(n,i,{target:t})}}},t.prototype.on=function(t,e,n){var i=(void 0===n?{}:n).target;void 0===this.listenersMap[t]&&(this.listenersMap[t]=[]),void 0!==i&&(e.target=i),this.listenersMap[t].push(e)},t.prototype.off=function(t,e){var n=this.listenersMap[t];if(void 0!==n)if(void 0===e)delete this.listenersMap[t];else{var i=n.findIndex((function(t){return t===e}));n.splice(i,1)}},t.prototype.emit=function(t,e,n){var o,r;void 0===n&&(n=function(){return!0});var s=this.listenersMap[t];if(void 0!==s&&0<s.length)try{for(var a=i(s),u=a.next();!u.done;u=a.next()){var c=u.value;n({target:c.target})&&c(e)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}},t.prototype.destroy=function(){this.listenersMap={}},t}(),a=Object.prototype.toString;var u="cancel",c="end",p="touch"+c,h="touch"+u,l="ontouchstart"in window,d="start",v="move",f=c,m="r",y="f",g=u;function T(t){return Math.round(100*t)/100}var M=function(){},x=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.load=function(t){var e=[],n=Array.from(t.touches).map((function(t){var n=t.clientX,i=t.clientY,o=t.target;return e.push(o),{clientX:n,clientY:i,target:o}})),i=Array.from(t.changedTouches).map((function(t){return{clientX:t.clientX,clientY:t.clientY,target:t.target}}));return{inputType:t.type.replace("touch",""),changedPoints:i,points:n,nativeEvent:t,target:t.target,targets:e}},n}(M),b=function(t){function n(){var e=t.call(this)||this;return e.target=null,e.isPressed=!1,e}return e(n,t),n.prototype.load=function(t){var e,n=t.clientX,i=t.clientY,o=t.type,r=t.button,s=t.target,a=[{clientX:n,clientY:i,target:s}];"mousedown"===o&&0===r?(this.target=s,this.isPressed=!0,e="start"):this.isPressed&&("mousemove"===o?e="move":"mouseup"===o&&(a=[],e=c,this.isPressed=!1));var u=this.prevPoints||[{clientX:n,clientY:i,target:s}];if(this.prevPoints=[{clientX:n,clientY:i,target:s}],void 0!==e)return{inputType:e,changedPoints:u,points:a,target:this.target,targets:[this.target],nativeEvent:t}},n}(M),E=function(){function t(){var t=l?x:b;this.adapter=new t,this.id=0}return t.prototype.transform=function(t){this.prevInput=this.activeInput;var e=this.adapter.load(t);if(void 0!==e){var i=Number.MAX_SAFE_INTEGER>this.id?++this.id:1,o=function(t){var e=t.inputType,i=t.points,o=t.changedPoints,r=t.nativeEvent,s=i.length,a="start"===e,p=c===e&&0===s||u===e,h=performance.now(),l=P(i)||P(o),d=l.x,v=l.y,f=r.currentTarget;return n(n({},t),{x:d,y:v,timestamp:h,isStart:a,isEnd:p,pointLength:s,currentTarget:f,getOffset:function(t){void 0===t&&(t=f);var e=t.getBoundingClientRect();return{x:d-Math.round(e.left),y:v-Math.round(e.top)}}})}(n(n({},e),{id:i}));this.activeInput=o;var r=o.isStart,s=o.pointLength;return r&&(this.startInput=o,this.prevInput=void 0,this.startMultiInput=1<s?o:void 0),n(n({},o),{prevInput:this.prevInput,startMultiInput:this.startMultiInput,startInput:this.startInput})}},t}();function P(t){var e=t.length;if(0<e){if(1===e){var n=t[0],i=n.clientX,o=n.clientY;return{x:Math.round(i),y:Math.round(o)}}var r=t.reduce((function(t,e){return t.x+=e.clientX,t.y+=e.clientY,t}),{x:0,y:0});return{x:Math.round(r.x/e),y:Math.round(r.y/e)}}}function w(t,e,n){e.target,e.currentTarget;var i,o,r,s=e.type,a=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(i=Object.getOwnPropertySymbols(t);o<i.length;o++)e.indexOf(i[o])<0&&Object.prototype.propertyIsEnumerable.call(t,i[o])&&(n[i[o]]=t[i[o]])}return n}(e,["target","currentTarget","type"]);return void 0!==Event?r=new Event(s,n):(r=document.createEvent("HTMLEvents")).initEvent(s,null===(i=n)||void 0===i?void 0:i.bubbles,null===(o=n)||void 0===o?void 0:o.cancelable),Object.assign(r,a,{match:function(){return e.targets.every((function(t){return r.currentTarget.contains(t)}))}}),t.dispatchEvent(r)}function L(t,e){if(!e.isPreventDefault)return!1;var n,i=!0;if(null!==t.target){var o=e.preventDefaultExclude;if(n=o,"[object RegExp]"===a.call(n)){if("tagName"in t.target){var r=t.target.tagName;i=!o.test(r)}}else(function(t){return"[object Function]"===a.call(t)})(o)&&(i=!o(t))}return i}var X=["touchstart","touchmove",p,h];function Y(t,e,n){var i,o=null===(i=n)||void 0===i?void 0:i.name;if(void 0===o||void 0===t.recognizerMap[o]){var r=new e(n);t.recognizerMap[r.name]=r,r.recognizerMap=t.recognizerMap,t.recognizers.push(t.recognizerMap[r.name])}}function _(t,e){var n,r;if(void 0===e)t.recognizers=[],t.recognizerMap={};else try{for(var s=i(t.recognizers.entries()),a=s.next();!a.done;a=s.next()){var u=o(a.value,2),c=u[0];if(e===u[1].options.name){t.recognizers.splice(c,1),delete t.recognizerMap[e];break}}}catch(t){n={error:t}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}function I(t,e){var i=e.type,o=e.target,r=e.targets;t.emit(i,e,(function(t){var e;if(void 0!==(null===(e=t)||void 0===e?void 0:e.target)){var n=t.target;return r.every((function(t){return n.contains(t)}))}return!0}));t.emit("at:after",e),t.options.domEvents&&void 0!==t.el&&null!==o&&(w(o,e,t.options.domEvents),w(o,n(n({},e),{type:"at:after"}),t.options.domEvents))}var z={domEvents:{bubbles:!0,cancelable:!0},isPreventDefault:!0,preventDefaultExclude:/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/},D=function(t){function o(e,i){var r=t.call(this)||this;if(r.recognizerMap={},r.recognizers=[],r.el=e,r.input=new E,r.options=n(n({},z),i),r.recognizerMap=o.recognizerMap,r.recognizers=o.recognizers,void 0!==e){e.style.webkitTapHighlightColor="rgba(0,0,0,0)";var s=!1;try{var a={};Object.defineProperty(a,"passive",{get:function(){s=!0}}),window.addEventListener("_",(function(){}),a)}catch(t){}r.on("unbind",function(t,e,n){return l?(X.forEach((function(i){t.addEventListener(i,e,n)})),function(){X.forEach((function(n){t.removeEventListener(n,e)}))}):(t.addEventListener("mousedown",e,n),window.addEventListener("mousemove",e,n),window.addEventListener("mouseup",e,n),function(){t.removeEventListener("mousedown",e),window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",e)})}(e,r.catchEvent.bind(r),!(r.options.isPreventDefault||!s)&&{passive:!0}))}return r}return e(o,t),o.prototype.use=function(t,e){Y(this,t,e)},o.prototype.removeUse=function(t){_(this,t)},o.prototype.catchEvent=function(t){var e,o,r=this;L(t,this.options)&&t.preventDefault();var s=this.input.transform(t);if(void 0!==s){var a="at:touch"+s.inputType;this.emit("at:touch",s),this.emit(a,s);var u=this.options.domEvents;if(!1!==u){var c=t.target;null!==c&&(w(c,n(n({},s),{type:"at:touch"}),u),w(c,n(n({},s),{type:a}),u))}var p={},h=function(t){if(t.disabled)return"continue";t.input=s,t.computedGroup=p,t.recognize(s,(function(e,i){var o=n(n(n({},s),i),{type:e,baseType:t.name});Object.freeze(o),void 0===r.beforeEachHook?I(r,o):r.beforeEachHook(t,(function(){I(r,o)}))})),p=t.computedGroup};try{for(var l=i(this.recognizers),d=l.next();!d.done;d=l.next()){h(d.value)}}catch(t){e={error:t}}finally{try{d&&!d.done&&(o=l.return)&&o.call(l)}finally{if(e)throw e.error}}}},o.prototype.beforeEach=function(t){this.beforeEachHook=t},o.prototype.get=function(t){return this.recognizerMap[t]},o.prototype.set=function(t){this.options=n(n({},this.options),t)},o.prototype.destroy=function(){this.emit("unbind"),this.listenersMap={}},o.version="1.0.1",o.recognizers=[],o.recognizerMap={},o.use=function(t,e){Y(o,t,e)},o.removeUse=function(t){_(o,t)},o}(s);function S(t){-1!==[f,g,m,y].indexOf(t.status)&&(t.status="p")}function V(t,e,n){var i=t.test(e);S(t);var o=e.inputType;t.status=function(t,e,n){var i,o,r,s,a,p,h,l={1:(i={},i.p=(o={},o.move=d,o),i[d]=(r={},r.move=v,r[c]=f,r[u]=g,r),i[v]=(s={},s.move=v,s[c]=f,s[u]=g,s),i),0:(a={},a[d]=(p={},p.move=g,p[c]=f,p[u]=g,p),a[v]=(h={},h.start=y,h.move=g,h[c]=f,h[u]=g,h),a)};return void 0!==l[Number(t)][e]&&l[Number(t)][e][n]||e}(i,t.status,o);var r=t.computed;t.isRecognized=[d,v].includes(t.status);var s=t.name,a=t.status,p=t.isRecognized;return p&&n(s,r),(p||[f,g].includes(t.status))&&n(s+a,r),i}var O=function(){function t(t){this.options=t,this.name=this.options.name,this.disabled=!1,this.status="p",this.isRecognized=!1,this.computed={},this.computedGroup={},this.usedComputeFunctionMap={},this.recognizerMap={}}return t.prototype.set=function(t){return void 0!==t&&(this.options=n(n({},this.options),t)),this},t.prototype.isValidPointLength=function(t){return 0===this.options.pointLength||this.options.pointLength===t},t.prototype.compute=function(t){for(var e,o,s,a=[],u=1;u<arguments.length;u++)a[u-1]=arguments[u];var c=Object.create(null);try{for(var p=i(t),h=p.next();!h.done;h=p.next()){var l=h.value,d=l._id,v=this,f=v.computedGroup,m=v.usedComputeFunctionMap;void 0===m[d]&&(m[d]=new l),f[d]=f[d]||(s=m[d]).compute.apply(s,r(a)),c=n(n({},c),f[d])}}catch(t){e={error:t}}finally{try{h&&!h.done&&(o=p.return)&&o.call(p)}finally{if(e)throw e.error}}return this.computed=c,c},t}(),C=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},A=function(t){return t/Math.PI*180},j=function(t,e){var n=function(t,e){var n=C(t)*C(e);if(0===n)return 0;var i=function(t,e){return t.x*e.x+t.y*e.y}(t,e)/n;return i>1&&(i=1),Math.acos(i)}(t,e);return function(t,e){return t.x*e.y-e.x*t.y}(t,e)>0&&(n*=-1),A(n)},F=function(t,e){return t===e?"none":Math.abs(t)>Math.abs(e)?0<t?"right":"left":0<e?"down":"up"};var N=function(){function t(){}return t.prototype.compute=function(t){var e=t.prevInput,n=0,i=0,o=0;if(void 0!==e&&(n=t.x-e.x,i=t.y-e.y,0!==n||0!==i)){var r=Math.sqrt(Math.pow(n,2)+Math.pow(i,2));o=Math.round(A(Math.acos(Math.abs(n)/r)))}return{deltaX:n,deltaY:i,deltaXYAngle:o}},t._id="ComputeDeltaXY",t}(),R=function(){function t(){this.displacementX=0,this.displacementY=0,this.distanceX=0,this.distanceY=0,this.distance=0,this.overallDirection="none"}return t.prototype.compute=function(t){var e=t.inputType,n=t.startInput;"start"===e?(this.displacementX=0,this.displacementY=0,this.distanceX=0,this.distanceY=0,this.distance=0,this.overallDirection="none"):"move"===e&&(this.displacementX=Math.round(t.points[0].clientX-n.points[0].clientX),this.displacementY=Math.round(t.points[0].clientY-n.points[0].clientY),this.distanceX=Math.abs(this.displacementX),this.distanceY=Math.abs(this.displacementY),this.distance=Math.round(C({x:this.distanceX,y:this.distanceY})),this.overallDirection=F(this.displacementX,this.displacementY));var i=this;return{displacementX:i.displacementX,displacementY:i.displacementY,distanceX:i.distanceX,distanceY:i.distanceY,distance:i.distance,overallDirection:i.overallDirection}},t._id="ComputeDistance",t}(),U=function(){function t(){this.maxPointLength=0}return t.prototype.compute=function(t){return"start"===t.inputType&&(this.maxPointLength=t.pointLength),{maxPointLength:this.maxPointLength}},t._id="ComputeMaxLength",t}();var G=function(){function t(){this.velocityX=0,this.velocityY=0,this.speedX=0,this.speedY=0}return t.prototype.compute=function(t){if(void 0!==t){var e=t.inputType;this._lastValidInput=this._lastValidInput||t.startInput;var n=t.timestamp-this._lastValidInput.timestamp;if("move"===e&&16<n){var i=t.x-this._lastValidInput.x,o=t.y-this._lastValidInput.y;this.speedX=Math.round(i/n*100)/100,this.speedY=Math.round(o/n*100)/100,this.velocityX=Math.abs(this.speedX),this.velocityY=Math.abs(this.speedY),this.direction=F(i,o)||this.direction,this._lastValidInput=t}}var r=this;return{velocityX:r.velocityX,velocityY:r.velocityY,speedX:r.speedX,speedY:r.speedY,direction:r.direction}},t._id="ComputeVAndDir",t}();function k(t){return{x:t.points[1].clientX-t.points[0].clientX,y:t.points[1].clientY-t.points[0].clientY}}var H=function(){function t(){}return t.prototype.compute=function(t){var e=t.prevInput,n=t.startMultiInput;if(void 0!==n&&void 0!==e&&t.id!==n.id&&1<t.pointLength)return{startV:k(n),prevV:k(e),activeV:k(t)}},t._id="ComputeVectorForMutli",t}(),B={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},q=function(t){function i(e){var i=t.call(this,n(n({},B),e))||this;return i.tapCount=0,i}return e(i,t),i.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var e=C({x:t.x-this.prevTapPoint.x,y:t.y-this.prevTapPoint.y});return this.prevTapPoint=t,this.options.maxDistanceFromPrevTap>=e}return this.prevTapPoint=t,!0},i.prototype._isValidInterval=function(){var t=performance.now();if(void 0===this.prevTapTime)return this.prevTapTime=t,!0;var e=t-this.prevTapTime;return this.prevTapTime=t,e<this.options.waitNextTapTime},i.prototype.recognize=function(t,e){var i=t.inputType,o=t.x,r=t.y;this.computed=this.compute([U,R],t),c===i&&(this.status="p",this.test(t)?(this.cancelCountDownToFail(),this._isValidDistanceFromPrevTap({x:o,y:r})&&this._isValidInterval()?this.tapCount++:this.tapCount=1,0==this.tapCount%this.options.tapTimes?(this.status=m,e(this.options.name,n(n({},this.computed),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=y))},i.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=y,t.reset()}),this.options.waitNextTapTime)},i.prototype.cancelCountDownToFail=function(){clearTimeout(this._countDownToFailTimer)},i.prototype.reset=function(){this.tapCount=0,this.prevTapPoint=void 0,this.prevTapTime=void 0},i.prototype.test=function(t){var e=t.startInput,n=t.timestamp-e.timestamp,i=this.computed,o=i.maxPointLength,r=i.distance;return o===this.options.pointLength&&this.options.maxDistance>=r&&this.options.maxPressTime>n},i}(O),Z={name:"pan",threshold:10,pointLength:1},$=function(t){function i(e){return t.call(this,n(n({},Z),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=this.computed.distance;return(this.isRecognized||this.options.threshold<n)&&this.isValidPointLength(e)},i.prototype.recognize=function(t,e){if(this.computed=this.compute([G,R,N],t),V(this,t,e)){t.inputType;e(this.options.name+this.computed.direction,this.computed)}},i}(O),J={name:"swipe",threshold:10,velocity:.3,pointLength:1},K=function(t){function i(e){return t.call(this,n(n({},J),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.inputType;if(c!==e)return!1;var n=this.computed,i=n.velocityX,o=n.velocityY,r=n.maxPointLength,s=n.distance;return this.options.pointLength===r&&this.options.threshold<s&&this.options.velocity<Math.max(i,o)},i.prototype.recognize=function(t,e){this.computed=this.compute([U,G,R],t),this.test(t)&&(e(this.options.name,this.computed),e(this.options.name+this.computed.direction,this.computed))},i}(O),Q={name:"press",pointLength:1,maxDistance:9,minPressTime:251},W=function(t){function i(e){return t.call(this,n(n({},Q),e))||this}return e(i,t),i.prototype.recognize=function(t,e){var n=this,i=t.inputType,o=t.startInput,r=t.pointLength;if("start"===i&&this.isValidPointLength(r))S(this),this.cancel(),this._timeoutId=setTimeout((function(){n.status=m,e(n.options.name,t)}),this.options.minPressTime);else if(c===i&&m===this.status)e(this.options.name+"up",this.computed);else{var s=t.timestamp-o.timestamp;(!this.test(t)||this.options.minPressTime>s&&[c,u].includes(i))&&(this.cancel(),this.status=y)}},i.prototype.test=function(t){t.pointLength;this.computed=this.compute([R],t);var e=this.computed.distance;return this.options.maxDistance>e},i.prototype.cancel=function(){clearTimeout(this._timeoutId)},i}(O),tt={name:"pinch",threshold:0,pointLength:2},et=function(t){function i(e){return t.call(this,n(n({},tt),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=this.computed.scale;return this.isValidPointLength(e)&&void 0!==n&&(this.options.threshold<Math.abs(n-1)||this.isRecognized)},i.prototype.recognize=function(t,e){var i,o,r,s,a,u=this.compute([H],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=T(C(s)/C(r)),{scale:T(C(s)/C(o)),deltaScale:a}))),V(this,t,e)},i}(O),nt={name:"rotate",threshold:0,pointLength:2},it=function(t){function i(e){return t.call(this,n(n({},nt),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=this.computed.angle;return this.isValidPointLength(e)&&(this.options.threshold<Math.abs(n)||this.isRecognized)},i.prototype.recognize=function(t,e){var i,o,r,s,a,u=this.compute([H],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=Math.round(j(s,r)),{angle:Math.round(j(s,o)),deltaAngle:a}))),V(this,t,e)},i}(O);return D.use(q),D.use($),D.use(K),D.use(W),D.use(et),D.use(it),D.Tap=q,D.Pan=$,D.Swipe=K,D.Press=W,D.Pinch=et,D.Rotate=it,D.STATUS_POSSIBLE="p",D.STATUS_START=d,D.STATUS_MOVE=v,D.STATUS_END=f,D.STATUS_CANCELLED=g,D.STATUS_FAILED=y,D.STATUS_RECOGNIZED=m,D})); |
import AnyTouch from '@any-touch/core'; | ||
export default AnyTouch; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
@@ -12,2 +14,3 @@ | ||
var Rotate = _interopDefault(require('@any-touch/rotate')); | ||
var shared = require('@any-touch/shared'); | ||
@@ -26,3 +29,10 @@ AnyTouch.use(Tap); | ||
AnyTouch.Rotate = Rotate; | ||
AnyTouch.STATUS_POSSIBLE = shared.STATUS_POSSIBLE; | ||
AnyTouch.STATUS_START = shared.STATUS_START; | ||
AnyTouch.STATUS_MOVE = shared.STATUS_MOVE; | ||
AnyTouch.STATUS_END = shared.STATUS_END; | ||
AnyTouch.STATUS_CANCELLED = shared.STATUS_CANCELLED; | ||
AnyTouch.STATUS_FAILED = shared.STATUS_FAILED; | ||
AnyTouch.STATUS_RECOGNIZED = shared.STATUS_RECOGNIZED; | ||
module.exports = AnyTouch; | ||
exports.default = AnyTouch; |
@@ -8,2 +8,3 @@ import AnyTouch from '@any-touch/core'; | ||
import Rotate from '@any-touch/rotate'; | ||
import { STATUS_POSSIBLE, STATUS_START, STATUS_MOVE, STATUS_END, STATUS_CANCELLED, STATUS_FAILED, STATUS_RECOGNIZED } from '@any-touch/shared'; | ||
@@ -22,3 +23,10 @@ AnyTouch.use(Tap); | ||
AnyTouch.Rotate = Rotate; | ||
AnyTouch.STATUS_POSSIBLE = STATUS_POSSIBLE; | ||
AnyTouch.STATUS_START = STATUS_START; | ||
AnyTouch.STATUS_MOVE = STATUS_MOVE; | ||
AnyTouch.STATUS_END = STATUS_END; | ||
AnyTouch.STATUS_CANCELLED = STATUS_CANCELLED; | ||
AnyTouch.STATUS_FAILED = STATUS_FAILED; | ||
AnyTouch.STATUS_RECOGNIZED = STATUS_RECOGNIZED; | ||
export default AnyTouch; |
@@ -1,1 +0,1 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var AnyTouch=_interopDefault(require("@any-touch/core")),Tap=_interopDefault(require("@any-touch/tap")),Pan=_interopDefault(require("@any-touch/pan")),Swipe=_interopDefault(require("@any-touch/swipe")),Press=_interopDefault(require("@any-touch/press")),Pinch=_interopDefault(require("@any-touch/pinch")),Rotate=_interopDefault(require("@any-touch/rotate"));AnyTouch.use(Tap),AnyTouch.use(Pan),AnyTouch.use(Swipe),AnyTouch.use(Press),AnyTouch.use(Pinch),AnyTouch.use(Rotate),AnyTouch.Tap=Tap,AnyTouch.Pan=Pan,AnyTouch.Swipe=Swipe,AnyTouch.Press=Press,AnyTouch.Pinch=Pinch,AnyTouch.Rotate=Rotate,module.exports=AnyTouch; | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var AnyTouch=_interopDefault(require("@any-touch/core")),Tap=_interopDefault(require("@any-touch/tap")),Pan=_interopDefault(require("@any-touch/pan")),Swipe=_interopDefault(require("@any-touch/swipe")),Press=_interopDefault(require("@any-touch/press")),Pinch=_interopDefault(require("@any-touch/pinch")),Rotate=_interopDefault(require("@any-touch/rotate")),shared=require("@any-touch/shared");AnyTouch.use(Tap),AnyTouch.use(Pan),AnyTouch.use(Swipe),AnyTouch.use(Press),AnyTouch.use(Pinch),AnyTouch.use(Rotate),AnyTouch.Tap=Tap,AnyTouch.Pan=Pan,AnyTouch.Swipe=Swipe,AnyTouch.Press=Press,AnyTouch.Pinch=Pinch,AnyTouch.Rotate=Rotate,AnyTouch.STATUS_POSSIBLE=shared.STATUS_POSSIBLE,AnyTouch.STATUS_START=shared.STATUS_START,AnyTouch.STATUS_MOVE=shared.STATUS_MOVE,AnyTouch.STATUS_END=shared.STATUS_END,AnyTouch.STATUS_CANCELLED=shared.STATUS_CANCELLED,AnyTouch.STATUS_FAILED=shared.STATUS_FAILED,AnyTouch.STATUS_RECOGNIZED=shared.STATUS_RECOGNIZED,exports.default=AnyTouch; |
{ | ||
"name": "any-touch", | ||
"version": "0.6.0-beta.30", | ||
"version": "0.6.0", | ||
"description": "一个小巧的手势库", | ||
"unpkg": "dist/any-touch.js", | ||
"jsdelivr": "dist/any-touch.js", | ||
"unpkg": "dist/any-touch.umd.min.js", | ||
"jsdelivr": "dist/any-touch.umd.min.js", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"types": "types/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"files": [ | ||
"dist/*", | ||
"types/*" | ||
"../../README.md" | ||
], | ||
@@ -24,11 +24,11 @@ "repository": { | ||
"homepage": "https://github.com/any86/any-touch#readme", | ||
"peerDependencies": { | ||
"@any-touch/core": "^0.6.0-beta.22", | ||
"@any-touch/pan": "^0.6.0-beta.29", | ||
"@any-touch/pinch": "^0.6.0-beta.20", | ||
"@any-touch/press": "^0.6.0-beta.20", | ||
"@any-touch/rotate": "^0.6.0-beta.20", | ||
"@any-touch/swipe": "^0.6.0-beta.29", | ||
"@any-touch/tap": "^0.6.0-beta.20", | ||
"any-event": "^0.6.0-beta.9", | ||
"dependencies": { | ||
"@any-touch/core": "^0.6.0", | ||
"@any-touch/pan": "^0.6.0", | ||
"@any-touch/pinch": "^0.6.0", | ||
"@any-touch/press": "^0.6.0", | ||
"@any-touch/rotate": "^0.6.0", | ||
"@any-touch/swipe": "^0.6.0", | ||
"@any-touch/tap": "^0.6.0", | ||
"any-event": "^0.6.0", | ||
"tslib": "^1.9.3" | ||
@@ -42,3 +42,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "72c35289e4996e7a568625595c8b1fd05728eadb" | ||
"gitHead": "2dd2b1983b6e7cca0c4908d9d44f2036282877d3" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
70551
1238
+ Added@any-touch/core@^0.6.0
+ Added@any-touch/pan@^0.6.0
+ Added@any-touch/pinch@^0.6.0
+ Added@any-touch/press@^0.6.0
+ Added@any-touch/rotate@^0.6.0
+ Added@any-touch/swipe@^0.6.0
+ Added@any-touch/tap@^0.6.0
+ Addedany-event@^0.6.0
+ Addedtslib@^1.9.3