any-touch
Advanced tools
Comparing version 0.7.9 to 0.8.0
@@ -92,13 +92,4 @@ (function (global, factory) { | ||
} | ||
default_1.prototype.target = function (el) { | ||
var _this = this; | ||
return { | ||
on: function (eventName, listener) { | ||
_this.on(eventName, listener, { target: el }); | ||
} | ||
}; | ||
}; | ||
default_1.prototype.on = function (eventName, listener, _a) { | ||
var e_1, _b; | ||
var target = (_a === void 0 ? {} : _a).target; | ||
default_1.prototype.on = function (eventName, listener, beforeEmit) { | ||
var e_1, _a; | ||
var eventNames = Array.isArray(eventName) ? eventName : [eventName]; | ||
@@ -111,5 +102,3 @@ try { | ||
} | ||
if (void 0 !== target) { | ||
listener.target = target; | ||
} | ||
listener.beforeEmit = beforeEmit; | ||
this.listenersMap[name].push(listener); | ||
@@ -121,22 +110,10 @@ } | ||
try { | ||
if (eventNames_1_1 && !eventNames_1_1.done && (_b = eventNames_1.return)) _b.call(eventNames_1); | ||
if (eventNames_1_1 && !eventNames_1_1.done && (_a = eventNames_1.return)) _a.call(eventNames_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return this; | ||
}; | ||
default_1.prototype.off = function (eventName, listener) { | ||
var listeners = this.listenersMap[eventName]; | ||
if (void 0 !== listeners) { | ||
if (void 0 === listener) { | ||
delete this.listenersMap[eventName]; | ||
} | ||
else { | ||
var index = listeners.findIndex(function (fn) { return fn === listener; }); | ||
listeners.splice(index, 1); | ||
} | ||
} | ||
}; | ||
default_1.prototype.emit = function (eventName, payload, beforeHook) { | ||
default_1.prototype.emit = function (eventName, payload) { | ||
var e_2, _a; | ||
if (beforeHook === void 0) { beforeHook = function () { return true; }; } | ||
var listeners = this.listenersMap[eventName]; | ||
@@ -147,6 +124,8 @@ if (void 0 !== listeners && 0 < listeners.length) { | ||
var listener = listeners_1_1.value; | ||
var target = listener.target; | ||
if (beforeHook({ target: target })) { | ||
if (void 0 === listener.beforeEmit) { | ||
listener(payload); | ||
} | ||
else if (void 0 !== payload && listener.beforeEmit(payload)) { | ||
listener(payload); | ||
} | ||
} | ||
@@ -163,2 +142,14 @@ } | ||
}; | ||
default_1.prototype.off = function (eventName, listener) { | ||
var listeners = this.listenersMap[eventName]; | ||
if (void 0 !== listeners) { | ||
if (void 0 === listener) { | ||
delete this.listenersMap[eventName]; | ||
} | ||
else { | ||
var index = listeners.findIndex(function (fn) { return fn === listener; }); | ||
listeners.splice(index, 1); | ||
} | ||
} | ||
}; | ||
default_1.prototype.destroy = function () { | ||
@@ -404,24 +395,41 @@ this.listenersMap = {}; | ||
function use(instanceOrClass, Recognizer, options) { | ||
var name = options === null || options === void 0 ? void 0 : options.name; | ||
if (void 0 !== name && void 0 !== instanceOrClass.recognizerMap[name]) | ||
function use(atOrAT, Recognizer, recognizerOptions) { | ||
var e_1, _a; | ||
var name = recognizerOptions === null || recognizerOptions === void 0 ? void 0 : recognizerOptions.name; | ||
if (void 0 !== name && void 0 !== atOrAT.recognizerMap[name]) | ||
return; | ||
var instance = new Recognizer(options); | ||
instanceOrClass.recognizerMap[instance.name] = instance; | ||
instance.recognizerMap = instanceOrClass.recognizerMap; | ||
instanceOrClass.recognizers.push(instanceOrClass.recognizerMap[instance.name]); | ||
var recognizer = new Recognizer(recognizerOptions); | ||
try { | ||
for (var _b = __values(recognizer.computeFunctions), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var createComputeFunction = _c.value; | ||
var _id = createComputeFunction._id; | ||
if (void 0 === atOrAT.computeFunctionMap[_id]) { | ||
atOrAT.computeFunctionMap[_id] = 'version' in atOrAT ? createComputeFunction : createComputeFunction(); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
atOrAT.recognizerMap[recognizer.name] = recognizer; | ||
recognizer.recognizerMap = atOrAT.recognizerMap; | ||
atOrAT.recognizers.push(atOrAT.recognizerMap[recognizer.name]); | ||
} | ||
function removeUse(instanceOrClass, recognizerName) { | ||
var e_1, _a; | ||
function removeUse(atOrAT, recognizerName) { | ||
var e_2, _a; | ||
if (void 0 === recognizerName) { | ||
instanceOrClass.recognizers = []; | ||
instanceOrClass.recognizerMap = {}; | ||
atOrAT.recognizers = []; | ||
atOrAT.recognizerMap = {}; | ||
} | ||
else { | ||
try { | ||
for (var _b = __values(instanceOrClass.recognizers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
for (var _b = __values(atOrAT.recognizers.entries()), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var _d = __read(_c.value, 2), index = _d[0], recognizer = _d[1]; | ||
if (recognizerName === recognizer.options.name) { | ||
instanceOrClass.recognizers.splice(index, 1); | ||
delete instanceOrClass.recognizerMap[recognizerName]; | ||
atOrAT.recognizers.splice(index, 1); | ||
delete atOrAT.recognizerMap[recognizerName]; | ||
break; | ||
@@ -431,3 +439,3 @@ } | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
catch (e_2_1) { e_2 = { error: e_2_1 }; } | ||
finally { | ||
@@ -437,3 +445,3 @@ try { | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
finally { if (e_2) throw e_2.error; } | ||
} | ||
@@ -444,11 +452,5 @@ } | ||
var AT_AFTER = 'at:after'; | ||
function emit2(at, payload) { | ||
var type = payload.type, target = payload.target, targets = payload.targets; | ||
at.emit(type, payload, function (data) { | ||
if (void 0 !== (data === null || data === void 0 ? void 0 : data.target)) { | ||
var currentTarget_1 = data.target; | ||
return targets.every(function (target) { return currentTarget_1.contains(target); }); | ||
} | ||
return true; | ||
}); | ||
function emit2 (at, payload) { | ||
var type = payload.type, target = payload.target; | ||
at.emit(type, payload); | ||
at.emit(AT_AFTER, payload); | ||
@@ -473,2 +475,3 @@ if (!!at.options.domEvents | ||
var _this = _super.call(this) || this; | ||
_this.computeFunctionMap = {}; | ||
_this.recognizerMap = {}; | ||
@@ -479,6 +482,9 @@ _this.recognizers = []; | ||
_this.options = __assign(__assign({}, DEFAULT_OPTIONS), options); | ||
for (var k in AnyTouch.computeFunctionMap) { | ||
_this.computeFunctionMap[k] = AnyTouch.computeFunctionMap[k](); | ||
} | ||
_this.recognizerMap = AnyTouch.recognizerMap; | ||
_this.recognizers = AnyTouch.recognizers; | ||
var createInputFromTouch = touch(_this.el); | ||
var createInputFromMouse = IS_WX ? function () { } : mouse(); | ||
var createInputFromMouse = mouse(); | ||
_this.inputCreatorMap = (_a = {}, | ||
@@ -510,8 +516,14 @@ _a[TOUCH_START] = createInputFromTouch, | ||
} | ||
AnyTouch.prototype.use = function (Recognizer, options) { | ||
use(this, Recognizer, options); | ||
AnyTouch.prototype.target = function (el) { | ||
var _this = this; | ||
return { | ||
on: function (eventName, listener) { | ||
_this.on(eventName, listener, function (event) { | ||
var targets = event.targets; | ||
return event.target === el && | ||
targets.every(function (target) { return el.contains(target); }); | ||
}); | ||
} | ||
}; | ||
}; | ||
AnyTouch.prototype.removeUse = function (name) { | ||
removeUse(this, name); | ||
}; | ||
AnyTouch.prototype.catchEvent = function (event) { | ||
@@ -525,6 +537,6 @@ var e_1, _a; | ||
if (void 0 !== input) { | ||
var AT_TOUCH = "at:" + TOUCH; | ||
var AT_TOUCH_WITH_STATUS = AT_TOUCH + input.stage; | ||
this.emit(AT_TOUCH, input); | ||
this.emit(AT_TOUCH_WITH_STATUS, input); | ||
var AT = "at"; | ||
var AT_WITH_STATUS = AT + ':' + input.stage; | ||
this.emit(AT, input); | ||
this.emit(AT_WITH_STATUS, input); | ||
var domEvents = this.options.domEvents; | ||
@@ -534,15 +546,17 @@ if (false !== domEvents) { | ||
if (null !== target) { | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT_TOUCH }), domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT_TOUCH_WITH_STATUS }), domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT }), domEvents); | ||
dispatchDomEvent(target, __assign(__assign({}, input), { type: AT_WITH_STATUS }), domEvents); | ||
} | ||
} | ||
var cacheComputedGroup = Object.create(null); | ||
var computed_1 = input; | ||
for (var k in this.computeFunctionMap) { | ||
var f = this.computeFunctionMap[k]; | ||
Object.assign(computed_1, f(computed_1)); | ||
} | ||
var _loop_1 = function (recognizer) { | ||
if (recognizer.disabled) | ||
return "continue"; | ||
recognizer.computedGroup = cacheComputedGroup; | ||
recognizer.computeFunctionMap = this_1.cacheComputedFunctionGroup; | ||
recognizer.recognize(input, function (type, ev) { | ||
var payload = __assign(__assign(__assign({}, input), ev), { type: type, baseType: recognizer.name }); | ||
Object.freeze(payload); | ||
recognizer.recognize(computed_1, function (type) { | ||
var payload = __assign(__assign({}, computed_1), { type: type, baseType: recognizer.name }); | ||
Object === null || Object === void 0 ? void 0 : Object.freeze(payload); | ||
if (void 0 === _this.beforeEachHook) { | ||
@@ -557,6 +571,3 @@ emit2(_this, payload); | ||
}); | ||
cacheComputedGroup = recognizer.computedGroup; | ||
this_1.cacheComputedFunctionGroup = recognizer.computeFunctionMap; | ||
}; | ||
var this_1 = this; | ||
try { | ||
@@ -577,2 +588,8 @@ for (var _b = __values(this.recognizers), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
}; | ||
AnyTouch.prototype.use = function (Recognizer, options) { | ||
use(this, Recognizer, options); | ||
}; | ||
AnyTouch.prototype.removeUse = function (name) { | ||
removeUse(this, name); | ||
}; | ||
AnyTouch.prototype.beforeEach = function (hook) { | ||
@@ -591,5 +608,6 @@ this.beforeEachHook = hook; | ||
}; | ||
AnyTouch.version = '0.7.8'; | ||
AnyTouch.version = '0.7.9'; | ||
AnyTouch.recognizers = []; | ||
AnyTouch.recognizerMap = {}; | ||
AnyTouch.computeFunctionMap = {}; | ||
AnyTouch.use = function (Recognizer, options) { | ||
@@ -610,3 +628,3 @@ use(AnyTouch, Recognizer, options); | ||
function flow(isVaild, activeStatus, stage) { | ||
function flow(isVaild, lastStatus, stage) { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
@@ -617,2 +635,4 @@ var STATE_MAP = { | ||
_b[INPUT_MOVE] = STATUS_START, | ||
_b[INPUT_END] = STATUS_FAILED, | ||
_b[INPUT_CANCEL] = STATUS_FAILED, | ||
_b), | ||
@@ -632,4 +652,4 @@ _a[STATUS_START] = (_c = {}, | ||
_e[STATUS_START] = (_f = {}, | ||
_f[INPUT_MOVE] = STATUS_CANCELLED, | ||
_f[INPUT_END] = STATUS_END, | ||
_f[INPUT_MOVE] = STATUS_FAILED, | ||
_f[INPUT_END] = STATUS_FAILED, | ||
_f[INPUT_CANCEL] = STATUS_CANCELLED, | ||
@@ -639,4 +659,4 @@ _f), | ||
_g[INPUT_START] = STATUS_FAILED, | ||
_g[INPUT_MOVE] = STATUS_CANCELLED, | ||
_g[INPUT_END] = STATUS_END, | ||
_g[INPUT_MOVE] = STATUS_FAILED, | ||
_g[INPUT_END] = STATUS_FAILED, | ||
_g[INPUT_CANCEL] = STATUS_CANCELLED, | ||
@@ -646,22 +666,17 @@ _g), | ||
}; | ||
if (void 0 !== STATE_MAP[Number(isVaild)][activeStatus]) { | ||
return STATE_MAP[Number(isVaild)][activeStatus][stage] || activeStatus; | ||
} | ||
else { | ||
return activeStatus; | ||
} | ||
var stageToStatusMap = STATE_MAP[Number(isVaild)][lastStatus]; | ||
return void 0 !== stageToStatusMap && stageToStatusMap[stage] || lastStatus; | ||
} | ||
function recognizeForPressMoveLike (recognizer, input, emit) { | ||
var isVaild = recognizer.test(input); | ||
function recognizeForPressMoveLike (recognizer, computed, emit) { | ||
var isVaild = recognizer.test(computed); | ||
resetStatus(recognizer); | ||
var stage = input.stage; | ||
var stage = computed.stage; | ||
recognizer.status = flow(isVaild, recognizer.status, stage); | ||
var computed = recognizer.computed; | ||
recognizer.isRecognized = [STATUS_START, STATUS_MOVE].includes(recognizer.status); | ||
var name = recognizer.name, status = recognizer.status, isRecognized = recognizer.isRecognized; | ||
if (isRecognized) { | ||
emit(name, computed); | ||
emit(name); | ||
} | ||
if (isRecognized || [STATUS_END, STATUS_CANCELLED].includes(recognizer.status)) { | ||
emit(name + status, computed); | ||
emit(name + status); | ||
} | ||
@@ -674,8 +689,6 @@ return isVaild; | ||
this.disabled = false; | ||
this.isRecognized = false; | ||
this.status = STATUS_POSSIBLE; | ||
this.isRecognized = false; | ||
this.recognizerMap = {}; | ||
this.computedGroup = {}; | ||
this.computed = {}; | ||
this.computeFunctionMap = {}; | ||
this.computeFunctions = []; | ||
this.options = options; | ||
@@ -691,30 +704,4 @@ this.name = this.options.name; | ||
default_1.prototype.isValidPointLength = function (pointLength) { | ||
return 0 === this.options.pointLength || this.options.pointLength === pointLength; | ||
return this.options.pointLength === pointLength; | ||
}; | ||
default_1.prototype.compute = function (Cs, input) { | ||
var e_1, _a; | ||
var computed = Object.create(null); | ||
try { | ||
for (var Cs_1 = __values(Cs), Cs_1_1 = Cs_1.next(); !Cs_1_1.done; Cs_1_1 = Cs_1.next()) { | ||
var C = Cs_1_1.value; | ||
var _id = C._id; | ||
var _b = this, computedGroup = _b.computedGroup, computeFunctionMap = _b.computeFunctionMap; | ||
if (void 0 === computeFunctionMap[_id]) { | ||
computeFunctionMap[_id] = C(); | ||
} | ||
computedGroup[_id] = computedGroup[_id] || computeFunctionMap[_id](input); | ||
for (var key in computedGroup[_id]) { | ||
computed[key] = computedGroup[_id][key]; | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (Cs_1_1 && !Cs_1_1.done && (_a = Cs_1.return)) _a.call(Cs_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return computed; | ||
}; | ||
return default_1; | ||
@@ -767,9 +754,36 @@ }()); | ||
function computeAngle (_a) { | ||
var startV = _a.startV, prevV = _a.prevV, activeV = _a.activeV; | ||
var deltaAngle = Math.round(getAngle(activeV, prevV)); | ||
var angle = Math.round(getAngle(activeV, startV)); | ||
return { angle: angle, deltaAngle: deltaAngle }; | ||
function computeVector(input) { | ||
return { | ||
x: input.points[1][CLIENT_X] - input.points[0][CLIENT_X], | ||
y: input.points[1][CLIENT_Y] - input.points[0][CLIENT_Y] | ||
}; | ||
} | ||
function _computeVectorForMutli (input) { | ||
var prevInput = input.prevInput, startMultiInput = input.startMultiInput; | ||
if (void 0 !== startMultiInput && | ||
void 0 !== prevInput && | ||
input.id !== startMultiInput.id && | ||
1 < prevInput.pointLength && | ||
1 < input.pointLength) { | ||
return { | ||
startV: computeVector(startMultiInput), | ||
prevV: computeVector(prevInput), | ||
activeV: computeVector(input) | ||
}; | ||
} | ||
} | ||
function ComputeAngle() { | ||
return function (input) { | ||
var _vs = (input === null || input === void 0 ? void 0 : input._vs) || _computeVectorForMutli(input); | ||
if (void 0 !== _vs && _vs.activeV) { | ||
var prevV = _vs.prevV, startV = _vs.startV, activeV = _vs.activeV; | ||
var deltaAngle = Math.round(getAngle(activeV, prevV)); | ||
var angle = Math.round(getAngle(activeV, startV)); | ||
return { angle: angle, deltaAngle: deltaAngle, _vs: _vs }; | ||
} | ||
}; | ||
} | ||
ComputeAngle._id = "a"; | ||
function ComputeDeltaXY() { | ||
@@ -792,5 +806,5 @@ return function (input) { | ||
} | ||
ComputeDeltaXY._id = "ComputeDeltaXY"; | ||
ComputeDeltaXY._id = "b"; | ||
function computeDistance() { | ||
function ComputeDistance() { | ||
var displacementX = 0; | ||
@@ -825,5 +839,5 @@ var displacementY = 0; | ||
} | ||
computeDistance._id = "computeDistance"; | ||
ComputeDistance._id = "c"; | ||
function computeMaxLength() { | ||
function ComputeMaxLength() { | ||
var maxPointLength = 0; | ||
@@ -838,10 +852,16 @@ return function (input) { | ||
} | ||
computeMaxLength._id = "computeMaxLength"; | ||
ComputeMaxLength._id = "d"; | ||
function computeScale(_a) { | ||
var startV = _a.startV, prevV = _a.prevV, activeV = _a.activeV; | ||
var deltaScale = round2(getVLength(activeV) / getVLength(prevV)); | ||
var scale = round2(getVLength(activeV) / getVLength(startV)); | ||
return { scale: scale, deltaScale: deltaScale }; | ||
function ComputeScale() { | ||
return function (input) { | ||
var _vs = (input === null || input === void 0 ? void 0 : input._vs) || _computeVectorForMutli(input); | ||
if (void 0 !== _vs && _vs.activeV) { | ||
var prevV = _vs.prevV, startV = _vs.startV, activeV = _vs.activeV; | ||
var deltaScale = round2(getVLength(activeV) / getVLength(prevV)); | ||
var scale = round2(getVLength(activeV) / getVLength(startV)); | ||
return { scale: scale, deltaScale: deltaScale, _vs: _vs }; | ||
} | ||
}; | ||
} | ||
ComputeScale._id = "e"; | ||
@@ -867,3 +887,3 @@ function ComputeVAndDir() { | ||
velocityY = Math.abs(speedY); | ||
direction = getDirection(deltaX, deltaY) || (direction); | ||
direction = getDirection(deltaX, deltaY) || direction; | ||
_lastValidInput = input; | ||
@@ -875,29 +895,4 @@ } | ||
} | ||
ComputeVAndDir._id = "ComputeVAndDir"; | ||
ComputeVAndDir._id = "f"; | ||
function computeVector(input) { | ||
return { | ||
x: input.points[1][CLIENT_X] - input.points[0][CLIENT_X], | ||
y: input.points[1][CLIENT_Y] - input.points[0][CLIENT_Y] | ||
}; | ||
} | ||
function ComputeVectorForMutli() { | ||
return function (input) { | ||
var prevInput = input.prevInput, startMultiInput = input.startMultiInput; | ||
if (void 0 !== startMultiInput && | ||
void 0 !== prevInput && | ||
input.id !== startMultiInput.id && | ||
1 < prevInput.pointLength && | ||
1 < input.pointLength) { | ||
return { | ||
startV: computeVector(startMultiInput), | ||
prevV: computeVector(prevInput), | ||
activeV: computeVector(input) | ||
}; | ||
} | ||
}; | ||
} | ||
ComputeVectorForMutli._id = "ComputeVectorForMutli"; | ||
var DEFAULT_OPTIONS$1 = { | ||
@@ -916,2 +911,3 @@ name: 'tap', | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$1), options)) || this; | ||
_this.computeFunctions = [ComputeDistance, ComputeMaxLength]; | ||
_this.tapCount = 0; | ||
@@ -943,9 +939,8 @@ return _this; | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
var stage = input.stage, x = input.x, y = input.y; | ||
this.computed = this.compute([computeMaxLength, computeDistance], input); | ||
default_1.prototype.recognize = function (computed, emit) { | ||
var stage = computed.stage, x = computed.x, y = computed.y; | ||
if (INPUT_END !== stage) | ||
return; | ||
this.status = STATUS_POSSIBLE; | ||
if (this.test(input)) { | ||
if (this.test(computed)) { | ||
this.cancelCountDownToFail(); | ||
@@ -960,3 +955,3 @@ if (this._isValidDistanceFromPrevTap({ x: x, y: y }) && this._isValidInterval()) { | ||
this.status = STATUS_RECOGNIZED; | ||
emit(this.options.name, __assign(__assign({}, this.computed), { tapCount: this.tapCount })); | ||
emit(this.options.name, __assign(__assign({}, computed), { tapCount: this.tapCount })); | ||
this.reset(); | ||
@@ -988,6 +983,6 @@ } | ||
}; | ||
default_1.prototype.test = function (input) { | ||
var startInput = input.startInput, pointLength = input.pointLength; | ||
var deltaTime = input.timestamp - startInput.timestamp; | ||
var _a = this.computed, maxPointLength = _a.maxPointLength, distance = _a.distance; | ||
default_1.prototype.test = function (computed) { | ||
var startInput = computed.startInput, pointLength = computed.pointLength; | ||
var deltaTime = computed.timestamp - startInput.timestamp; | ||
var maxPointLength = computed.maxPointLength, distance = computed.distance; | ||
return maxPointLength === this.options.pointLength && | ||
@@ -1009,15 +1004,15 @@ 0 === pointLength && | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$2), options)) || this; | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$2), options)) || this; | ||
_this.computeFunctions = [ComputeVAndDir, ComputeDistance, ComputeDeltaXY]; | ||
return _this; | ||
} | ||
default_1.prototype.test = function (input) { | ||
var pointLength = input.pointLength; | ||
var distance = this.computed.distance; | ||
default_1.prototype.test = function (computed) { | ||
var pointLength = computed.pointLength, distance = computed.distance; | ||
return ((this.isRecognized || this.options.threshold <= distance) && | ||
this.isValidPointLength(pointLength)); | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
this.computed = this.compute([ComputeVAndDir, computeDistance, ComputeDeltaXY], input); | ||
var isRecognized = void 0 !== this.computed.direction && recognizeForPressMoveLike(this, input, emit); | ||
default_1.prototype.recognize = function (computed, emit) { | ||
var isRecognized = void 0 !== computed.direction && recognizeForPressMoveLike(this, computed, emit); | ||
if (isRecognized) { | ||
emit(this.options.name + this.computed.direction, this.computed); | ||
emit(this.options.name + computed.direction); | ||
} | ||
@@ -1037,9 +1032,10 @@ }; | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$3), options)) || this; | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$3), options)) || this; | ||
_this.computeFunctions = [ComputeDistance, ComputeVAndDir, ComputeMaxLength]; | ||
return _this; | ||
} | ||
default_1.prototype.test = function (input) { | ||
var stage = input.stage; | ||
if (INPUT_END !== stage) | ||
default_1.prototype.test = function (computed) { | ||
if (INPUT_END !== computed.stage) | ||
return false; | ||
var _a = this.computed, velocityX = _a.velocityX, velocityY = _a.velocityY, maxPointLength = _a.maxPointLength, distance = _a.distance; | ||
var velocityX = computed.velocityX, velocityY = computed.velocityY, maxPointLength = computed.maxPointLength, distance = computed.distance; | ||
return this.options.pointLength === maxPointLength && | ||
@@ -1049,7 +1045,6 @@ this.options.threshold < distance && | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
this.computed = this.compute([computeMaxLength, ComputeVAndDir, computeDistance], input); | ||
if (this.test(input)) { | ||
emit(this.options.name, this.computed); | ||
emit(this.options.name + this.computed.direction, this.computed); | ||
default_1.prototype.recognize = function (computed, emit) { | ||
if (this.test(computed)) { | ||
emit(this.options.name); | ||
emit(this.options.name + computed.direction); | ||
} | ||
@@ -1069,7 +1064,9 @@ }; | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$4), options)) || this; | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$4), options)) || this; | ||
_this.computeFunctions = [ComputeDistance]; | ||
return _this; | ||
} | ||
default_1.prototype.recognize = function (input, emit) { | ||
default_1.prototype.recognize = function (computed, emit) { | ||
var _this = this; | ||
var stage = input.stage, startInput = input.startInput, pointLength = input.pointLength; | ||
var stage = computed.stage, startInput = computed.startInput, pointLength = computed.pointLength; | ||
if (INPUT_START === stage && this.isValidPointLength(pointLength)) { | ||
@@ -1080,11 +1077,11 @@ resetStatus(this); | ||
_this.status = STATUS_RECOGNIZED; | ||
emit(_this.options.name, input); | ||
emit(_this.options.name); | ||
}, this.options.minPressTime); | ||
} | ||
else if (INPUT_END === stage && STATUS_RECOGNIZED === this.status) { | ||
emit("" + this.options.name + DIRECTION_UP, this.computed); | ||
emit("" + this.options.name + DIRECTION_UP); | ||
} | ||
else if (STATUS_RECOGNIZED !== this.status) { | ||
var deltaTime = input.timestamp - startInput.timestamp; | ||
if (!this.test(input) || | ||
var deltaTime = computed.timestamp - startInput.timestamp; | ||
if (!this.test(computed) || | ||
(this.options.minPressTime > deltaTime && [INPUT_END, INPUT_CANCEL].includes(stage))) { | ||
@@ -1096,5 +1093,4 @@ this.cancel(); | ||
}; | ||
default_1.prototype.test = function (input) { | ||
this.computed = this.compute([computeDistance], input); | ||
var distance = this.computed.distance; | ||
default_1.prototype.test = function (computed) { | ||
var distance = computed.distance; | ||
return this.options.maxDistance > distance; | ||
@@ -1116,7 +1112,8 @@ }; | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$5), options)) || this; | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$5), options)) || this; | ||
_this.computeFunctions = [ComputeScale]; | ||
return _this; | ||
} | ||
default_1.prototype.test = function (input) { | ||
var pointLength = input.pointLength; | ||
var scale = this.computed.scale; | ||
default_1.prototype.test = function (computed) { | ||
var pointLength = computed.pointLength, scale = computed.scale; | ||
return this.isValidPointLength(pointLength) | ||
@@ -1126,8 +1123,4 @@ && void 0 !== scale | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
var computed = this.compute([ComputeVectorForMutli], input); | ||
if ("activeV" in computed) { | ||
this.computed = __assign(__assign({}, this.computed), computeScale(computed)); | ||
} | ||
recognizeForPressMoveLike(this, input, emit); | ||
default_1.prototype.recognize = function (computed, emit) { | ||
recognizeForPressMoveLike(this, computed, emit); | ||
}; | ||
@@ -1145,15 +1138,12 @@ return default_1; | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$6), options)) || this; | ||
var _this = _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS$6), options)) || this; | ||
_this.computeFunctions = [ComputeAngle]; | ||
return _this; | ||
} | ||
default_1.prototype.test = function (input) { | ||
var pointLength = input.pointLength; | ||
var angle = this.computed.angle; | ||
default_1.prototype.test = function (computed) { | ||
var pointLength = computed.pointLength, angle = computed.angle; | ||
return this.isValidPointLength(pointLength) && (this.options.threshold < Math.abs(angle) || this.isRecognized); | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
var computed = this.compute([ComputeVectorForMutli], input); | ||
if ("activeV" in computed) { | ||
this.computed = __assign(__assign({}, this.computed), computeAngle(computed)); | ||
} | ||
recognizeForPressMoveLike(this, input, emit); | ||
default_1.prototype.recognize = function (computed, emit) { | ||
recognizeForPressMoveLike(this, computed, emit); | ||
}; | ||
@@ -1160,0 +1150,0 @@ return default_1; |
@@ -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&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)a.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 a}var r=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 o,r,a=(void 0===n?{}:n).target,s=Array.isArray(t)?t:[t];try{for(var u=i(s),c=u.next();!c.done;c=u.next()){var p=c.value;void 0===this.listenersMap[p]&&(this.listenersMap[p]=[]),void 0!==a&&(e.target=a),this.listenersMap[p].push(e)}}catch(t){o={error:t}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(o)throw o.error}}},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 a=this.listenersMap[t];if(void 0!==a&&0<a.length)try{for(var s=i(a),u=s.next();!u.done;u=s.next()){var c=u.value;n({target:c.target})&&c(e)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}},t.prototype.destroy=function(){this.listenersMap={}},t}(),a=Object.prototype.toString;var s=!!window.wx,u="cancel",c="end",p="touch"+c,h="touch"+u,l="start",v="move",f=c,d="r",m="f",y=u;function g(t){return Math.round(100*t)/100}function T(){var t,e,i,o,r=0;return function(a){if(t=e,void 0!==a){var s=function(t,e){var n=t.stage,i=t.points,o=t.changedPoints,r=t.nativeEvent,a=i.length,s="start"===n,p=c===n&&0===a||u===n,h=Date.now(),l=M(i)||M(o),v=l.x,f=l.y,d=r.currentTarget;return Object.assign(t,{id:e,x:v,y:f,timestamp:h,isStart:s,isEnd:p,pointLength:a,currentTarget:d,getOffset:function(t){void 0===t&&(t=d);var e=t.getBoundingClientRect();return{x:v-Math.round(e.left),y:f-Math.round(e.top)}}})}(a,r=Number.MAX_SAFE_INTEGER>r?++r:1);e=s;var p=s.isStart,h=s.pointLength;return p&&(i=s,t=void 0,o=1<h?s:void 0),n(n({},s),{prevInput:t,startMultiInput:o,startInput:i})}}}function M(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 b(t,e,n){e.target,e.currentTarget;var i,o=e.type,r=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 document.createEvent?(i=document.createEvent("HTMLEvents")).initEvent(o,null==n?void 0:n.bubbles,null==n?void 0:n.cancelable):i=new Event(o,n),Object.assign(i,r,{match:function(){return e.targets.every((function(t){return i.currentTarget.contains(t)}))}}),t.dispatchEvent(i)}function x(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 E=["touchstart","touchmove",p,h];function w(t,e,n){var i=null==n?void 0:n.name;if(void 0===i||void 0===t.recognizerMap[i]){var o=new e(n);t.recognizerMap[o.name]=o,o.recognizerMap=t.recognizerMap,t.recognizers.push(t.recognizerMap[o.name])}}function L(t,e){var n,r;if(void 0===e)t.recognizers=[],t.recognizerMap={};else try{for(var a=i(t.recognizers.entries()),s=a.next();!s.done;s=a.next()){var u=o(s.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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function P(t,e){var i=e.type,o=e.target,r=e.targets;t.emit(i,e,(function(t){if(void 0!==(null==t?void 0:t.target)){var e=t.target;return r.every((function(t){return e.contains(t)}))}return!0})),t.emit("at:after",e),t.options.domEvents&&void 0!==t.el&&null!==o&&(b(o,e,t.options.domEvents),b(o,n(n({},e),{_type:e.type,type:"at:after"}),t.options.domEvents))}var z={domEvents:{bubbles:!0,cancelable:!0},isPreventDefault:!0,preventDefaultExclude:/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/},_=function(t){function o(e,i){var r,a=t.call(this)||this;a.recognizerMap={},a.recognizers=[],a.cacheComputedFunctionGroup=Object.create(null),a.el=e,a.options=n(n({},z),i),a.recognizerMap=o.recognizerMap,a.recognizers=o.recognizers;var u,l,v,f,d=function(t){var e=T();return function(n){var i=[],o=[];Array.from(n.touches).forEach((function(e){var n=e.clientX,r=e.clientY,a=e.target;(null==t?void 0:t.contains(a))&&(i.push(a),o.push({clientX:n,clientY:r,target:a}))}));var r=Array.from(n.changedTouches).map((function(t){return{clientX:t.clientX,clientY:t.clientY,target:t.target}}));return e({stage:n.type.replace("touch",""),changedPoints:r,points:o,nativeEvent:n,target:n.target,targets:i})}}(a.el),m=s?function(){}:(l=!1,v=null,f=T(),function(t){var e,n=t.clientX,i=t.clientY,o=t.type,r=t.button,a=t.target,s=[{clientX:n,clientY:i,target:a}];"mousedown"===o&&0===r?(v=a,l=!0,e="start"):l&&("mousemove"===o?e="move":"mouseup"===o&&(s=[],e=c,l=!1));var p=u||[{clientX:n,clientY:i,target:a}];if(u=[{clientX:n,clientY:i,target:a}],void 0!==e)return f({stage:e,changedPoints:p,points:s,target:v,targets:[v],nativeEvent:t})});if(a.inputCreatorMap=((r={}).touchstart=d,r.touchmove=d,r[p]=d,r[h]=d,r.mousedown=m,r.mousemove=m,r.mouseup=m,r),void 0!==e){e.style.webkitTapHighlightColor="rgba(0,0,0,0)";var y=!1;try{var g={};Object.defineProperty(g,"passive",{get:function(){y=!0}}),window.addEventListener("_",(function(){}),g)}catch(t){}a.on("unbind",function(t,e,n){return E.forEach((function(i){t.addEventListener(i,e,n)})),s||(t.addEventListener("mousedown",e,n),window.addEventListener("mousemove",e,n),window.addEventListener("mouseup",e,n)),function(){E.forEach((function(n){t.removeEventListener(n,e)})),s||(t.removeEventListener("mousedown",e,n),window.removeEventListener("mousemove",e,n),window.removeEventListener("mouseup",e,n))}}(e,a.catchEvent.bind(a),!(a.options.isPreventDefault||!y)&&{passive:!0}))}return a}return e(o,t),o.prototype.use=function(t,e){w(this,t,e)},o.prototype.removeUse=function(t){L(this,t)},o.prototype.catchEvent=function(t){var e,o,r=this;x(t,this.options)&&t.preventDefault();var a=this.inputCreatorMap[t.type](t);if(void 0!==a){var s="at:touch"+a.stage;this.emit("at:touch",a),this.emit(s,a);var u=this.options.domEvents;if(!1!==u){var c=t.target;null!==c&&(b(c,n(n({},a),{type:"at:touch"}),u),b(c,n(n({},a),{type:s}),u))}var p=Object.create(null),h=function(t){if(t.disabled)return"continue";t.computedGroup=p,t.computeFunctionMap=l.cacheComputedFunctionGroup,t.recognize(a,(function(e,i){var o=n(n(n({},a),i),{type:e,baseType:t.name});Object.freeze(o),void 0===r.beforeEachHook?P(r,o):r.beforeEachHook(t,(function(){P(r,o)}))})),p=t.computedGroup,l.cacheComputedFunctionGroup=t.computeFunctionMap},l=this;try{for(var v=i(this.recognizers),f=v.next();!f.done;f=v.next()){h(f.value)}}catch(t){e={error:t}}finally{try{f&&!f.done&&(o=v.return)&&o.call(v)}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="0.7.8",o.recognizers=[],o.recognizerMap={},o.use=function(t,e){w(o,t,e)},o.removeUse=function(t){L(o,t)},o}(r);function O(t){-1!==[f,y,d,m].indexOf(t.status)&&(t.status="p")}function S(t,e,n){var i=t.test(e);O(t);var o=e.stage;t.status=function(t,e,n){var i,o,r,a,s,p,h,d={1:(i={},i.p=(o={},o.move=l,o),i[l]=(r={},r.move=v,r[c]=f,r[u]=y,r),i[v]=(a={},a.move=v,a[c]=f,a[u]=y,a),i),0:(s={},s[l]=(p={},p.move=y,p[c]=f,p[u]=y,p),s[v]=(h={},h.start=m,h.move=y,h[c]=f,h[u]=y,h),s)};return void 0!==d[Number(t)][e]&&d[Number(t)][e][n]||e}(i,t.status,o);var r=t.computed;t.isRecognized=[l,v].includes(t.status);var a=t.name,s=t.status,p=t.isRecognized;return p&&n(a,r),(p||[f,y].includes(t.status))&&n(a+s,r),i}var D=function(){function t(t){this.disabled=!1,this.status="p",this.isRecognized=!1,this.recognizerMap={},this.computedGroup={},this.computed={},this.computeFunctionMap={},this.options=t,this.name=this.options.name}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,e){var n,o,r=Object.create(null);try{for(var a=i(t),s=a.next();!s.done;s=a.next()){var u=s.value,c=u._id,p=this.computedGroup,h=this.computeFunctionMap;for(var l in void 0===h[c]&&(h[c]=u()),p[c]=p[c]||h[c](e),p[c])r[l]=p[c][l]}}catch(t){n={error:t}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return r},t}(),X=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},A=function(t){return t/Math.PI*180},C=function(t,e){var n=function(t,e){var n=X(t)*X(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)},V=function(t,e){return t===e?"none":Math.abs(t)>Math.abs(e)?0<t?"right":"left":0<e?"down":"up"};function I(){return 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}}}function Y(){var t=0,e=0,n=0,i=0,o=0,r="none";return function(a){var s=a.stage,u=a.startInput;return"start"===s?(t=0,e=0,n=0,i=0,o=0,r="none"):"move"===s&&(t=Math.round(a.points[0].clientX-u.points[0].clientX),e=Math.round(a.points[0].clientY-u.points[0].clientY),n=Math.abs(t),i=Math.abs(e),o=Math.round(X({x:n,y:i})),r=V(t,e)),{displacementX:t,displacementY:e,distanceX:n,distanceY:i,distance:o,overallDirection:r}}}function F(){var t=0;return function(e){return"start"===e.stage&&(t=e.pointLength),{maxPointLength:t}}}function j(){var t,e,n=0,i=0,o=0,r=0;return function(a){if(void 0!==a){var s=a.stage;e=e||a.startInput;var u=a.timestamp-e.timestamp;if("move"===s&&16<u){var c=a.x-e.x,p=a.y-e.y;o=Math.round(c/u*100)/100,r=Math.round(p/u*100)/100,n=Math.abs(o),i=Math.abs(r),t=V(c,p)||t,e=a}}return{velocityX:n,velocityY:i,speedX:o,speedY:r,direction:t}}}function N(t){return{x:t.points[1].clientX-t.points[0].clientX,y:t.points[1].clientY-t.points[0].clientY}}function R(){return function(t){var e=t.prevInput,n=t.startMultiInput;if(void 0!==n&&void 0!==e&&t.id!==n.id&&1<e.pointLength&&1<t.pointLength)return{startV:N(n),prevV:N(e),activeV:N(t)}}}I._id="ComputeDeltaXY",Y._id="computeDistance",F._id="computeMaxLength",j._id="ComputeVAndDir",R._id="ComputeVectorForMutli";var U={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},G=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=X({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.stage,o=t.x,r=t.y;this.computed=this.compute([F,Y],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=d,e(this.options.name,n(n({},this.computed),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=m))},i.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=m,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.pointLength,i=t.timestamp-e.timestamp,o=this.computed,r=o.maxPointLength,a=o.distance;return r===this.options.pointLength&&0===n&&this.options.maxDistance>=a&&this.options.maxPressTime>i},i}(D),k={name:"pan",threshold:10,pointLength:1},H=function(t){function i(e){return t.call(this,n(n({},k),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){this.computed=this.compute([j,Y,I],t),void 0!==this.computed.direction&&S(this,t,e)&&e(this.options.name+this.computed.direction,this.computed)},i}(D),B={name:"swipe",threshold:10,velocity:.3,pointLength:1},q=function(t){function i(e){return t.call(this,n(n({},B),e))||this}return e(i,t),i.prototype.test=function(t){var e=t.stage;if(c!==e)return!1;var n=this.computed,i=n.velocityX,o=n.velocityY,r=n.maxPointLength,a=n.distance;return this.options.pointLength===r&&this.options.threshold<a&&this.options.velocity<Math.max(i,o)},i.prototype.recognize=function(t,e){this.computed=this.compute([F,j,Y],t),this.test(t)&&(e(this.options.name,this.computed),e(this.options.name+this.computed.direction,this.computed))},i}(D),Z={name:"press",pointLength:1,maxDistance:9,minPressTime:251},$=function(t){function i(e){return t.call(this,n(n({},Z),e))||this}return e(i,t),i.prototype.recognize=function(t,e){var n=this,i=t.stage,o=t.startInput,r=t.pointLength;if("start"===i&&this.isValidPointLength(r))O(this),this.cancel(),this._timeoutId=setTimeout((function(){n.status=d,e(n.options.name,t)}),this.options.minPressTime);else if(c===i&&d===this.status)e(this.options.name+"up",this.computed);else if(d!==this.status){var a=t.timestamp-o.timestamp;(!this.test(t)||this.options.minPressTime>a&&[c,u].includes(i))&&(this.cancel(),this.status=m)}},i.prototype.test=function(t){this.computed=this.compute([Y],t);var e=this.computed.distance;return this.options.maxDistance>e},i.prototype.cancel=function(){clearTimeout(this._timeoutId)},i}(D),J={name:"pinch",threshold:0,pointLength:2},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.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,a,s,u=this.compute([R],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,a=i.activeV,s=g(X(a)/X(r)),{scale:g(X(a)/X(o)),deltaScale:s}))),S(this,t,e)},i}(D),Q={name:"rotate",threshold:0,pointLength:2},W=function(t){function i(e){return t.call(this,n(n({},Q),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,a,s,u=this.compute([R],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,a=i.activeV,s=Math.round(C(a,r)),{angle:Math.round(C(a,o)),deltaAngle:s}))),S(this,t,e)},i}(D);return _.use(G),_.use(H),_.use(q),_.use($),_.use(K),_.use(W),_.Tap=G,_.Pan=H,_.Swipe=q,_.Press=$,_.Pinch=K,_.Rotate=W,_.STATUS_POSSIBLE="p",_.STATUS_START=l,_.STATUS_MOVE=v,_.STATUS_END=f,_.STATUS_CANCELLED=y,_.STATUS_FAILED=m,_.STATUS_RECOGNIZED=d,_})); | ||
!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&&Symbol.iterator,n=e&&t[e],i=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=r.next()).done;)a.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 a}var r=function(){function t(){this.listenersMap={}}return t.prototype.on=function(t,e,n){var o,r,a=Array.isArray(t)?t:[t];try{for(var s=i(a),u=s.next();!u.done;u=s.next()){var c=u.value;void 0===this.listenersMap[c]&&(this.listenersMap[c]=[]),e.beforeEmit=n,this.listenersMap[c].push(e)}}catch(t){o={error:t}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return this},t.prototype.emit=function(t,e){var n,o,r=this.listenersMap[t];if(void 0!==r&&0<r.length)try{for(var a=i(r),s=a.next();!s.done;s=a.next()){var u=s.value;(void 0===u.beforeEmit||void 0!==e&&u.beforeEmit(e))&&u(e)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}},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.destroy=function(){this.listenersMap={}},t}(),a=Object.prototype.toString;var s=!!window.wx,u="cancel",c="end",p="touch"+c,h="touch"+u,v="start",l="move",f=c,d="r",m="f",y=u;function g(t){return Math.round(100*t)/100}function T(){var t,e,i,o,r=0;return function(a){if(t=e,void 0!==a){var s=function(t,e){var n=t.stage,i=t.points,o=t.changedPoints,r=t.nativeEvent,a=i.length,s="start"===n,p=c===n&&0===a||u===n,h=Date.now(),v=M(i)||M(o),l=v.x,f=v.y,d=r.currentTarget;return Object.assign(t,{id:e,x:l,y:f,timestamp:h,isStart:s,isEnd:p,pointLength:a,currentTarget:d,getOffset:function(t){void 0===t&&(t=d);var e=t.getBoundingClientRect();return{x:l-Math.round(e.left),y:f-Math.round(e.top)}}})}(a,r=Number.MAX_SAFE_INTEGER>r?++r:1);e=s;var p=s.isStart,h=s.pointLength;return p&&(i=s,t=void 0,o=1<h?s:void 0),n(n({},s),{prevInput:t,startMultiInput:o,startInput:i})}}}function M(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 b(t,e,n){e.target,e.currentTarget;var i,o=e.type,r=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 document.createEvent?(i=document.createEvent("HTMLEvents")).initEvent(o,null==n?void 0:n.bubbles,null==n?void 0:n.cancelable):i=new Event(o,n),Object.assign(i,r,{match:function(){return e.targets.every((function(t){return i.currentTarget.contains(t)}))}}),t.dispatchEvent(i)}function x(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 E=["touchstart","touchmove",p,h];function w(t,e,n){var o,r,a=null==n?void 0:n.name;if(void 0===a||void 0===t.recognizerMap[a]){var s=new e(n);try{for(var u=i(s.computeFunctions),c=u.next();!c.done;c=u.next()){var p=c.value,h=p._id;void 0===t.computeFunctionMap[h]&&(t.computeFunctionMap[h]="version"in t?p:p())}}catch(t){o={error:t}}finally{try{c&&!c.done&&(r=u.return)&&r.call(u)}finally{if(o)throw o.error}}t.recognizerMap[s.name]=s,s.recognizerMap=t.recognizerMap,t.recognizers.push(t.recognizerMap[s.name])}}function L(t,e){var n,r;if(void 0===e)t.recognizers=[],t.recognizerMap={};else try{for(var a=i(t.recognizers.entries()),s=a.next();!s.done;s=a.next()){var u=o(s.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{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}function P(t,e){var i=e.type,o=e.target;t.emit(i,e),t.emit("at:after",e),t.options.domEvents&&void 0!==t.el&&null!==o&&(b(o,e,t.options.domEvents),b(o,n(n({},e),{_type:e.type,type:"at:after"}),t.options.domEvents))}var _={domEvents:{bubbles:!0,cancelable:!0},isPreventDefault:!0,preventDefaultExclude:/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/},z=function(t){function o(e,i){var r,a=t.call(this)||this;for(var u in a.computeFunctionMap={},a.recognizerMap={},a.recognizers=[],a.cacheComputedFunctionGroup=Object.create(null),a.el=e,a.options=n(n({},_),i),o.computeFunctionMap)a.computeFunctionMap[u]=o.computeFunctionMap[u]();a.recognizerMap=o.recognizerMap,a.recognizers=o.recognizers;var v,l,f,d,m=function(t){var e=T();return function(n){var i=[],o=[];Array.from(n.touches).forEach((function(e){var n=e.clientX,r=e.clientY,a=e.target;(null==t?void 0:t.contains(a))&&(i.push(a),o.push({clientX:n,clientY:r,target:a}))}));var r=Array.from(n.changedTouches).map((function(t){return{clientX:t.clientX,clientY:t.clientY,target:t.target}}));return e({stage:n.type.replace("touch",""),changedPoints:r,points:o,nativeEvent:n,target:n.target,targets:i})}}(a.el),y=(l=!1,f=null,d=T(),function(t){var e,n=t.clientX,i=t.clientY,o=t.type,r=t.button,a=t.target,s=[{clientX:n,clientY:i,target:a}];"mousedown"===o&&0===r?(f=a,l=!0,e="start"):l&&("mousemove"===o?e="move":"mouseup"===o&&(s=[],e=c,l=!1));var u=v||[{clientX:n,clientY:i,target:a}];if(v=[{clientX:n,clientY:i,target:a}],void 0!==e)return d({stage:e,changedPoints:u,points:s,target:f,targets:[f],nativeEvent:t})});if(a.inputCreatorMap=((r={}).touchstart=m,r.touchmove=m,r[p]=m,r[h]=m,r.mousedown=y,r.mousemove=y,r.mouseup=y,r),void 0!==e){e.style.webkitTapHighlightColor="rgba(0,0,0,0)";var g=!1;try{var M={};Object.defineProperty(M,"passive",{get:function(){g=!0}}),window.addEventListener("_",(function(){}),M)}catch(t){}a.on("unbind",function(t,e,n){return E.forEach((function(i){t.addEventListener(i,e,n)})),s||(t.addEventListener("mousedown",e,n),window.addEventListener("mousemove",e,n),window.addEventListener("mouseup",e,n)),function(){E.forEach((function(n){t.removeEventListener(n,e)})),s||(t.removeEventListener("mousedown",e,n),window.removeEventListener("mousemove",e,n),window.removeEventListener("mouseup",e,n))}}(e,a.catchEvent.bind(a),!(a.options.isPreventDefault||!g)&&{passive:!0}))}return a}return e(o,t),o.prototype.target=function(t){var e=this;return{on:function(n,i){e.on(n,i,(function(e){var n=e.targets;return e.target===t&&n.every((function(e){return t.contains(e)}))}))}}},o.prototype.catchEvent=function(t){var e,o,r=this;x(t,this.options)&&t.preventDefault();var a=this.inputCreatorMap[t.type](t);if(void 0!==a){var s="at:"+a.stage;this.emit("at",a),this.emit(s,a);var u=this.options.domEvents;if(!1!==u){var c=t.target;null!==c&&(b(c,n(n({},a),{type:"at"}),u),b(c,n(n({},a),{type:s}),u))}var p=a;for(var h in this.computeFunctionMap){var v=this.computeFunctionMap[h];Object.assign(p,v(p))}var l=function(t){if(t.disabled)return"continue";t.recognize(p,(function(e){var i=n(n({},p),{type:e,baseType:t.name});null==Object||Object.freeze(i),void 0===r.beforeEachHook?P(r,i):r.beforeEachHook(t,(function(){P(r,i)}))}))};try{for(var f=i(this.recognizers),d=f.next();!d.done;d=f.next()){l(d.value)}}catch(t){e={error:t}}finally{try{d&&!d.done&&(o=f.return)&&o.call(f)}finally{if(e)throw e.error}}}},o.prototype.use=function(t,e){w(this,t,e)},o.prototype.removeUse=function(t){L(this,t)},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="0.7.9",o.recognizers=[],o.recognizerMap={},o.computeFunctionMap={},o.use=function(t,e){w(o,t,e)},o.removeUse=function(t){L(o,t)},o}(r);function F(t){-1!==[f,y,d,m].indexOf(t.status)&&(t.status="p")}function O(t,e,n){var i=t.test(e);F(t);var o=e.stage;t.status=function(t,e,n){var i,o,r,a,s,p,h,d={1:(i={},i.p=(o={},o.move=v,o[c]=m,o[u]=m,o),i[v]=(r={},r.move=l,r[c]=f,r[u]=y,r),i[l]=(a={},a.move=l,a[c]=f,a[u]=y,a),i),0:(s={},s[v]=(p={},p.move=m,p[c]=m,p[u]=y,p),s[l]=(h={},h.start=m,h.move=m,h[c]=m,h[u]=y,h),s)}[Number(t)][e];return void 0!==d&&d[n]||e}(i,t.status,o),t.isRecognized=[v,l].includes(t.status);var r=t.name,a=t.status,s=t.isRecognized;return s&&n(r),(s||[f,y].includes(t.status))&&n(r+a),i}var S=function(){function t(t){this.disabled=!1,this.isRecognized=!1,this.status="p",this.recognizerMap={},this.computeFunctions=[],this.options=t,this.name=this.options.name}return t.prototype.set=function(t){return void 0!==t&&(this.options=n(n({},this.options),t)),this},t.prototype.isValidPointLength=function(t){return this.options.pointLength===t},t}(),D=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},X=function(t){return t/Math.PI*180},A=function(t,e){var n=function(t,e){var n=D(t)*D(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),X(n)},I=function(t,e){return t===e?"none":Math.abs(t)>Math.abs(e)?0<t?"right":"left":0<e?"down":"up"};function V(t){return{x:t.points[1].clientX-t.points[0].clientX,y:t.points[1].clientY-t.points[0].clientY}}function Y(t){var e=t.prevInput,n=t.startMultiInput;if(void 0!==n&&void 0!==e&&t.id!==n.id&&1<e.pointLength&&1<t.pointLength)return{startV:V(n),prevV:V(e),activeV:V(t)}}function j(){return function(t){var e=(null==t?void 0:t._vs)||Y(t);if(void 0!==e&&e.activeV){var n=e.prevV,i=e.startV,o=e.activeV,r=Math.round(A(o,n));return{angle:Math.round(A(o,i)),deltaAngle:r,_vs:e}}}}function C(){return 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(X(Math.acos(Math.abs(n)/r)))}return{deltaX:n,deltaY:i,deltaXYAngle:o}}}function N(){var t=0,e=0,n=0,i=0,o=0,r="none";return function(a){var s=a.stage,u=a.startInput;return"start"===s?(t=0,e=0,n=0,i=0,o=0,r="none"):"move"===s&&(t=Math.round(a.points[0].clientX-u.points[0].clientX),e=Math.round(a.points[0].clientY-u.points[0].clientY),n=Math.abs(t),i=Math.abs(e),o=Math.round(D({x:n,y:i})),r=I(t,e)),{displacementX:t,displacementY:e,distanceX:n,distanceY:i,distance:o,overallDirection:r}}}function R(){var t=0;return function(e){return"start"===e.stage&&(t=e.pointLength),{maxPointLength:t}}}function U(){return function(t){var e=(null==t?void 0:t._vs)||Y(t);if(void 0!==e&&e.activeV){var n=e.prevV,i=e.startV,o=e.activeV,r=g(D(o)/D(n));return{scale:g(D(o)/D(i)),deltaScale:r,_vs:e}}}}function k(){var t,e,n=0,i=0,o=0,r=0;return function(a){if(void 0!==a){var s=a.stage;e=e||a.startInput;var u=a.timestamp-e.timestamp;if("move"===s&&16<u){var c=a.x-e.x,p=a.y-e.y;o=Math.round(c/u*100)/100,r=Math.round(p/u*100)/100,n=Math.abs(o),i=Math.abs(r),t=I(c,p)||t,e=a}}return{velocityX:n,velocityY:i,speedX:o,speedY:r,direction:t}}}j._id="a",C._id="b",N._id="c",R._id="d",U._id="e",k._id="f";var H={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},B=function(t){function i(e){var i=t.call(this,n(n({},H),e))||this;return i.computeFunctions=[N,R],i.tapCount=0,i}return e(i,t),i.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var e=D({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.stage,o=t.x,r=t.y;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=d,e(this.options.name,n(n({},t),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=m))},i.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=m,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.pointLength,i=t.timestamp-e.timestamp,o=t.maxPointLength,r=t.distance;return o===this.options.pointLength&&0===n&&this.options.maxDistance>=r&&this.options.maxPressTime>i},i}(S),G={name:"pan",threshold:10,pointLength:1},q=function(t){function i(e){var i=t.call(this,n(n({},G),e))||this;return i.computeFunctions=[k,N,C],i}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=t.distance;return(this.isRecognized||this.options.threshold<=n)&&this.isValidPointLength(e)},i.prototype.recognize=function(t,e){void 0!==t.direction&&O(this,t,e)&&e(this.options.name+t.direction)},i}(S),Z={name:"swipe",threshold:10,velocity:.3,pointLength:1},$=function(t){function i(e){var i=t.call(this,n(n({},Z),e))||this;return i.computeFunctions=[N,k,R],i}return e(i,t),i.prototype.test=function(t){if(c!==t.stage)return!1;var e=t.velocityX,n=t.velocityY,i=t.maxPointLength,o=t.distance;return this.options.pointLength===i&&this.options.threshold<o&&this.options.velocity<Math.max(e,n)},i.prototype.recognize=function(t,e){this.test(t)&&(e(this.options.name),e(this.options.name+t.direction))},i}(S),J={name:"press",pointLength:1,maxDistance:9,minPressTime:251},K=function(t){function i(e){var i=t.call(this,n(n({},J),e))||this;return i.computeFunctions=[N],i}return e(i,t),i.prototype.recognize=function(t,e){var n=this,i=t.stage,o=t.startInput,r=t.pointLength;if("start"===i&&this.isValidPointLength(r))F(this),this.cancel(),this._timeoutId=setTimeout((function(){n.status=d,e(n.options.name)}),this.options.minPressTime);else if(c===i&&d===this.status)e(this.options.name+"up");else if(d!==this.status){var a=t.timestamp-o.timestamp;(!this.test(t)||this.options.minPressTime>a&&[c,u].includes(i))&&(this.cancel(),this.status=m)}},i.prototype.test=function(t){var e=t.distance;return this.options.maxDistance>e},i.prototype.cancel=function(){clearTimeout(this._timeoutId)},i}(S),Q={name:"pinch",threshold:0,pointLength:2},W=function(t){function i(e){var i=t.call(this,n(n({},Q),e))||this;return i.computeFunctions=[U],i}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=t.scale;return this.isValidPointLength(e)&&void 0!==n&&(this.options.threshold<Math.abs(n-1)||this.isRecognized)},i.prototype.recognize=function(t,e){O(this,t,e)},i}(S),tt={name:"rotate",threshold:0,pointLength:2},et=function(t){function i(e){var i=t.call(this,n(n({},tt),e))||this;return i.computeFunctions=[j],i}return e(i,t),i.prototype.test=function(t){var e=t.pointLength,n=t.angle;return this.isValidPointLength(e)&&(this.options.threshold<Math.abs(n)||this.isRecognized)},i.prototype.recognize=function(t,e){O(this,t,e)},i}(S);return z.use(B),z.use(q),z.use($),z.use(K),z.use(W),z.use(et),z.Tap=B,z.Pan=q,z.Swipe=$,z.Press=K,z.Pinch=W,z.Rotate=et,z.STATUS_POSSIBLE="p",z.STATUS_START=v,z.STATUS_MOVE=l,z.STATUS_END=f,z.STATUS_CANCELLED=y,z.STATUS_FAILED=m,z.STATUS_RECOGNIZED=d,z})); |
{ | ||
"name": "any-touch", | ||
"version": "0.7.9", | ||
"version": "0.8.0", | ||
"description": "一个小巧的手势库", | ||
@@ -25,10 +25,10 @@ "unpkg": "dist/any-touch.umd.min.js", | ||
"dependencies": { | ||
"@any-touch/core": "^0.7.9", | ||
"@any-touch/pan": "^0.7.9", | ||
"@any-touch/pinch": "^0.7.9", | ||
"@any-touch/press": "^0.7.9", | ||
"@any-touch/rotate": "^0.7.9", | ||
"@any-touch/swipe": "^0.7.9", | ||
"@any-touch/tap": "^0.7.9", | ||
"any-event": "^0.7.9", | ||
"@any-touch/core": "^0.8.0", | ||
"@any-touch/pan": "^0.8.0", | ||
"@any-touch/pinch": "^0.8.0", | ||
"@any-touch/press": "^0.8.0", | ||
"@any-touch/rotate": "^0.8.0", | ||
"@any-touch/swipe": "^0.8.0", | ||
"@any-touch/tap": "^0.8.0", | ||
"any-event": "^0.8.0", | ||
"tslib": "^1.9.3" | ||
@@ -42,3 +42,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "4d795d9ac1c0cf597db9bc070284f3de7578e5fd" | ||
"gitHead": "2bc02cd25dc78562a2b61c95e2d481ac718e805e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67103
1181
+ Added@any-touch/compute@0.8.0(transitive)
+ Added@any-touch/core@0.8.0(transitive)
+ Added@any-touch/pan@0.8.0(transitive)
+ Added@any-touch/pinch@0.8.0(transitive)
+ Added@any-touch/press@0.8.0(transitive)
+ Added@any-touch/recognizer@0.8.0(transitive)
+ Added@any-touch/rotate@0.8.0(transitive)
+ Added@any-touch/shared@0.8.0(transitive)
+ Added@any-touch/swipe@0.8.0(transitive)
+ Added@any-touch/tap@0.8.0(transitive)
+ Added@any-touch/vector@0.8.0(transitive)
+ Addedany-event@0.8.0(transitive)
- Removed@any-touch/compute@0.7.9(transitive)
- Removed@any-touch/core@0.7.9(transitive)
- Removed@any-touch/pan@0.7.9(transitive)
- Removed@any-touch/pinch@0.7.9(transitive)
- Removed@any-touch/press@0.7.9(transitive)
- Removed@any-touch/recognizer@0.7.9(transitive)
- Removed@any-touch/rotate@0.7.9(transitive)
- Removed@any-touch/shared@0.7.9(transitive)
- Removed@any-touch/swipe@0.7.9(transitive)
- Removed@any-touch/tap@0.7.9(transitive)
- Removed@any-touch/vector@0.7.9(transitive)
- Removedany-event@0.7.9(transitive)
Updated@any-touch/core@^0.8.0
Updated@any-touch/pan@^0.8.0
Updated@any-touch/pinch@^0.8.0
Updated@any-touch/press@^0.8.0
Updated@any-touch/rotate@^0.8.0
Updated@any-touch/swipe@^0.8.0
Updated@any-touch/tap@^0.8.0
Updatedany-event@^0.8.0