Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

any-touch

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

any-touch - npm Package Compare versions

Comparing version 0.7.8 to 0.7.9

377

dist/any-touch.umd.js

@@ -8,14 +8,14 @@ (function (global, factory) {

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -61,5 +61,5 @@ /* global Reflect, Promise */

function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
return {
if (o && typeof o.length === "number") return {
next: function () {

@@ -70,2 +70,3 @@ if (o && i >= o.length) o = void 0;

};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}

@@ -175,2 +176,3 @@

var IS_WX = !!window.wx;
var CLIENT_X = 'clientX';

@@ -197,3 +199,2 @@ var CLIENT_Y = 'clientY';

var MOUSE_DOWN = MOUSE + DIRECTION_DOWN;
var SUPPORT_TOUCH = window.wx || "on" + TOUCH_START in window;
var STATUS_POSSIBLE = 'p';

@@ -211,113 +212,29 @@ var STATUS_START = INPUT_START;

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, el) {
var targets = [];
var points = [];
Array.from(event.touches).forEach(function (_a) {
var clientX = _a.clientX, clientY = _a.clientY, target = _a.target;
if (el === null || el === void 0 ? void 0 : el.contains(target)) {
targets.push(target);
points.push({ 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;
_this.target = null;
_this.isPressed = false;
return _this;
}
default_1.prototype.load = function (event) {
var clientX = event.clientX, clientY = event.clientY, type = event.type, button = event.button, target = event.target;
var points = [{ clientX: clientX, clientY: clientY, target: target }];
var inputType;
if (MOUSE_DOWN === type && 0 === button) {
this.target = target;
this.isPressed = true;
inputType = INPUT_START;
}
else if (this.isPressed) {
if (MOUSE_MOVE === type) {
inputType = INPUT_MOVE;
}
else if (MOUSE_UP === type) {
points = [];
inputType = INPUT_END;
this.isPressed = false;
}
}
var changedPoints = this.prevPoints || [{ clientX: clientX, clientY: clientY, target: target }];
this.prevPoints = [{ clientX: clientX, clientY: clientY, target: target }];
if (void 0 !== inputType) {
return {
inputType: inputType,
changedPoints: changedPoints,
points: points,
target: this.target,
targets: [this.target],
nativeEvent: event
};
}
};
return default_1;
}(default_1$1));
var default_1$4 = (function () {
function default_1(el) {
var Input = SUPPORT_TOUCH ? default_1$2 : default_1$3;
this.adapter = new Input();
this.id = 0;
this.el = el;
}
default_1.prototype.transform = function (event) {
this.prevInput = this.activeInput;
var baseInputWithoutId = this.adapter.load(event, this.el);
if (void 0 !== baseInputWithoutId) {
var id = Number.MAX_SAFE_INTEGER > this.id ? ++this.id : 1;
var baseInput = __assign(__assign({}, baseInputWithoutId), { id: id });
var pureInput = extendInput(baseInput);
this.activeInput = pureInput;
function inputCreator () {
var id = 0;
var prevInput;
var activeInput;
var startInput;
var startMultiInput;
return function (basicsInput) {
prevInput = activeInput;
if (void 0 !== basicsInput) {
id = Number.MAX_SAFE_INTEGER > id ? ++id : 1;
var pureInput = extendInput(basicsInput, id);
activeInput = pureInput;
var isStart = pureInput.isStart, pointLength = pureInput.pointLength;
if (isStart) {
this.startInput = pureInput;
this.prevInput = void 0;
startInput = pureInput;
prevInput = void 0;
if (1 < pointLength) {
this.startMultiInput = pureInput;
startMultiInput = pureInput;
}
else {
this.startMultiInput = void 0;
startMultiInput = void 0;
}
}
return __assign(__assign({}, pureInput), { prevInput: this.prevInput, startMultiInput: this.startMultiInput, startInput: this.startInput });
return __assign(__assign({}, pureInput), { prevInput: prevInput, startMultiInput: startMultiInput, startInput: startInput });
}
};
return default_1;
}());
}
function getCenter(points) {

@@ -338,11 +255,13 @@ var length = points.length;

}
function extendInput(inputBase) {
var inputType = inputBase.inputType, points = inputBase.points, changedPoints = inputBase.changedPoints, nativeEvent = inputBase.nativeEvent;
function extendInput(basicsInput, id) {
var stage = basicsInput.stage, points = basicsInput.points, changedPoints = basicsInput.changedPoints, nativeEvent = basicsInput.nativeEvent;
var pointLength = points.length;
var isStart = INPUT_START === inputType;
var isEnd = (INPUT_END === inputType && 0 === pointLength) || INPUT_CANCEL === inputType;
var timestamp = performance.now();
var isStart = INPUT_START === stage;
var isEnd = (INPUT_END === stage && 0 === pointLength) || INPUT_CANCEL === stage;
var timestamp = Date.now();
var _a = getCenter(points) || getCenter(changedPoints), x = _a.x, y = _a.y;
var currentTarget = nativeEvent.currentTarget;
return __assign(__assign({}, inputBase), { x: x, y: y,
return Object.assign(basicsInput, {
id: id,
x: x, y: y,
timestamp: timestamp,

@@ -356,5 +275,72 @@ isStart: isStart, isEnd: isEnd,

return { x: x - Math.round(rect.left), y: y - Math.round(rect.top) };
} });
}
});
}
function mouse () {
var prevPoints;
var isPressed = false;
var _target = null;
var createInput = inputCreator();
return function (event) {
var clientX = event.clientX, clientY = event.clientY, type = event.type, button = event.button, target = event.target;
var points = [{ clientX: clientX, clientY: clientY, target: target }];
var stage;
if (MOUSE_DOWN === type && 0 === button) {
_target = target;
isPressed = true;
stage = INPUT_START;
}
else if (isPressed) {
if (MOUSE_MOVE === type) {
stage = INPUT_MOVE;
}
else if (MOUSE_UP === type) {
points = [];
stage = INPUT_END;
isPressed = false;
}
}
var changedPoints = prevPoints || [{ clientX: clientX, clientY: clientY, target: target }];
prevPoints = [{ clientX: clientX, clientY: clientY, target: target }];
if (void 0 !== stage) {
return createInput({
stage: stage,
changedPoints: changedPoints,
points: points,
target: _target,
targets: [_target],
nativeEvent: event
});
}
};
}
function touch (el) {
var createInput = inputCreator();
return function (event) {
var targets = [];
var points = [];
Array.from(event.touches).forEach(function (_a) {
var clientX = _a.clientX, clientY = _a.clientY, target = _a.target;
if (el === null || el === void 0 ? void 0 : el.contains(target)) {
targets.push(target);
points.push({ 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 createInput({
stage: event.type.replace('touch', ''),
changedPoints: changedPoints,
points: points,
nativeEvent: event,
target: event.target,
targets: targets
});
};
}
function dispatchDomEvent (el, payload, eventInit) {

@@ -399,24 +385,22 @@ var target = payload.target, currentTarget = payload.currentTarget, type = payload.type, data = __rest(payload, ["target", "currentTarget", "type"]);

var TOUCH_EVENT_NAMES = [TOUCH_START, TOUCH_MOVE, TOUCH_END, TOUCH_CANCEL];
function bindElement (el, callback, options, device) {
if (SUPPORT_TOUCH || 'Touch' === device) {
TOUCH_EVENT_NAMES.forEach(function (eventName) {
el.addEventListener(eventName, callback, options);
var TOUCH_EVENTS = [TOUCH_START, TOUCH_MOVE, TOUCH_END, TOUCH_CANCEL];
function bindElement (el, catchEvent, options) {
TOUCH_EVENTS.forEach(function (eventName) {
el.addEventListener(eventName, catchEvent, options);
});
if (!IS_WX) {
el.addEventListener(MOUSE_DOWN, catchEvent, options);
window.addEventListener(MOUSE_MOVE, catchEvent, options);
window.addEventListener(MOUSE_UP, catchEvent, options);
}
return function () {
TOUCH_EVENTS.forEach(function (eventName) {
el.removeEventListener(eventName, catchEvent);
});
return function () {
TOUCH_EVENT_NAMES.forEach(function (eventName) {
el.removeEventListener(eventName, callback);
});
};
}
else {
el.addEventListener(MOUSE_DOWN, callback, options);
window.addEventListener(MOUSE_MOVE, callback, options);
window.addEventListener(MOUSE_UP, callback, options);
return function () {
el.removeEventListener(MOUSE_DOWN, callback);
window.removeEventListener(MOUSE_MOVE, callback);
window.removeEventListener(MOUSE_UP, callback);
};
}
if (!IS_WX) {
el.removeEventListener(MOUSE_DOWN, catchEvent, options);
window.removeEventListener(MOUSE_MOVE, catchEvent, options);
window.removeEventListener(MOUSE_UP, catchEvent, options);
}
};
}

@@ -487,2 +471,3 @@

function AnyTouch(el, options) {
var _a;
var _this = _super.call(this) || this;

@@ -493,6 +478,16 @@ _this.recognizerMap = {};

_this.el = el;
_this.input = new default_1$4(el);
_this.options = __assign(__assign({}, DEFAULT_OPTIONS), options);
_this.recognizerMap = AnyTouch.recognizerMap;
_this.recognizers = AnyTouch.recognizers;
var createInputFromTouch = touch(_this.el);
var createInputFromMouse = IS_WX ? function () { } : mouse();
_this.inputCreatorMap = (_a = {},
_a[TOUCH_START] = createInputFromTouch,
_a[TOUCH_MOVE] = createInputFromTouch,
_a[TOUCH_END] = createInputFromTouch,
_a[TOUCH_CANCEL] = createInputFromTouch,
_a[MOUSE_DOWN] = createInputFromMouse,
_a[MOUSE_MOVE] = createInputFromMouse,
_a[MOUSE_UP] = createInputFromMouse,
_a);
if (void 0 !== el) {

@@ -510,4 +505,4 @@ el.style.webkitTapHighlightColor = 'rgba(0,0,0,0)';

}
catch (_a) { }
_this.on('unbind', bindElement(el, _this.catchEvent.bind(_this), !_this.options.isPreventDefault && supportsPassive_1 ? { passive: true } : false, _this.options.device));
catch (_b) { }
_this.on('unbind', bindElement(el, _this.catchEvent.bind(_this), !_this.options.isPreventDefault && supportsPassive_1 ? { passive: true } : false));
}

@@ -528,6 +523,6 @@ return _this;

}
var input = this.input.transform(event);
var input = this.inputCreatorMap[event.type](event);
if (void 0 !== input) {
var AT_TOUCH = "at:" + TOUCH;
var AT_TOUCH_WITH_STATUS = AT_TOUCH + input.inputType;
var AT_TOUCH_WITH_STATUS = AT_TOUCH + input.stage;
this.emit(AT_TOUCH, input);

@@ -593,3 +588,3 @@ this.emit(AT_TOUCH_WITH_STATUS, input);

};
AnyTouch.version = '0.7.7';
AnyTouch.version = '0.7.8';
AnyTouch.recognizers = [];

@@ -612,3 +607,3 @@ AnyTouch.recognizerMap = {};

function flow(isVaild, activeStatus, inputType) {
function flow(isVaild, activeStatus, stage) {
var _a, _b, _c, _d, _e, _f, _g;

@@ -646,3 +641,3 @@ var STATE_MAP = {

if (void 0 !== STATE_MAP[Number(isVaild)][activeStatus]) {
return STATE_MAP[Number(isVaild)][activeStatus][inputType] || activeStatus;
return STATE_MAP[Number(isVaild)][activeStatus][stage] || activeStatus;
}

@@ -656,4 +651,4 @@ else {

resetStatus(recognizer);
var inputType = input.inputType;
recognizer.status = flow(isVaild, recognizer.status, inputType);
var stage = input.stage;
recognizer.status = flow(isVaild, recognizer.status, stage);
var computed = recognizer.computed;

@@ -671,3 +666,3 @@ recognizer.isRecognized = [STATUS_START, STATUS_MOVE].includes(recognizer.status);

var default_1$5 = (function () {
var default_1$1 = (function () {
function default_1(options) {

@@ -800,4 +795,4 @@ this.disabled = false;

return function (input) {
var inputType = input.inputType, startInput = input.startInput;
if (INPUT_START === inputType) {
var stage = input.stage, startInput = input.startInput;
if (INPUT_START === stage) {
displacementX = 0;

@@ -810,3 +805,3 @@ displacementY = 0;

}
else if (INPUT_MOVE === inputType) {
else if (INPUT_MOVE === stage) {
displacementX = Math.round(input.points[0][CLIENT_X] - startInput.points[0][CLIENT_X]);

@@ -829,4 +824,4 @@ displacementY = Math.round(input.points[0][CLIENT_Y] - startInput.points[0][CLIENT_Y]);

return function (input) {
var inputType = input.inputType;
if (INPUT_START === inputType) {
var stage = input.stage;
if (INPUT_START === stage) {
maxPointLength = input.pointLength;

@@ -855,6 +850,6 @@ }

if (void 0 !== input) {
var inputType = input.inputType;
var stage = input.stage;
_lastValidInput = _lastValidInput || input.startInput;
var deltaTime = input.timestamp - _lastValidInput.timestamp;
if (INPUT_MOVE === inputType && COMPUTE_INTERVAL < deltaTime) {
if (INPUT_MOVE === stage && COMPUTE_INTERVAL < deltaTime) {
var deltaX = input.x - _lastValidInput.x;

@@ -909,3 +904,3 @@ var deltaY = input.y - _lastValidInput.y;

};
var default_1$6 = (function (_super) {
var default_1$2 = (function (_super) {
__extends(default_1, _super);

@@ -941,5 +936,5 @@ function default_1(options) {

default_1.prototype.recognize = function (input, emit) {
var inputType = input.inputType, x = input.x, y = input.y;
var stage = input.stage, x = input.x, y = input.y;
this.computed = this.compute([computeMaxLength, computeDistance], input);
if (INPUT_END !== inputType)
if (INPUT_END !== stage)
return;

@@ -994,3 +989,3 @@ this.status = STATUS_POSSIBLE;

return default_1;
}(default_1$5));
}(default_1$1));

@@ -1002,3 +997,3 @@ var DEFAULT_OPTIONS$2 = {

};
var default_1$7 = (function (_super) {
var default_1$3 = (function (_super) {
__extends(default_1, _super);

@@ -1022,3 +1017,3 @@ function default_1(options) {

return default_1;
}(default_1$5));
}(default_1$1));

@@ -1031,3 +1026,3 @@ var DEFAULT_OPTIONS$3 = {

};
var default_1$8 = (function (_super) {
var default_1$4 = (function (_super) {
__extends(default_1, _super);

@@ -1038,4 +1033,4 @@ function default_1(options) {

default_1.prototype.test = function (input) {
var inputType = input.inputType;
if (INPUT_END !== inputType)
var stage = input.stage;
if (INPUT_END !== stage)
return false;

@@ -1055,3 +1050,3 @@ var _a = this.computed, velocityX = _a.velocityX, velocityY = _a.velocityY, maxPointLength = _a.maxPointLength, distance = _a.distance;

return default_1;
}(default_1$5));
}(default_1$1));

@@ -1064,3 +1059,3 @@ var DEFAULT_OPTIONS$4 = {

};
var default_1$9 = (function (_super) {
var default_1$5 = (function (_super) {
__extends(default_1, _super);

@@ -1072,4 +1067,4 @@ function default_1(options) {

var _this = this;
var inputType = input.inputType, startInput = input.startInput, pointLength = input.pointLength;
if (INPUT_START === inputType && this.isValidPointLength(pointLength)) {
var stage = input.stage, startInput = input.startInput, pointLength = input.pointLength;
if (INPUT_START === stage && this.isValidPointLength(pointLength)) {
resetStatus(this);

@@ -1082,3 +1077,3 @@ this.cancel();

}
else if (INPUT_END === inputType && STATUS_RECOGNIZED === this.status) {
else if (INPUT_END === stage && STATUS_RECOGNIZED === this.status) {
emit("" + this.options.name + DIRECTION_UP, this.computed);

@@ -1089,3 +1084,3 @@ }

if (!this.test(input) ||
(this.options.minPressTime > deltaTime && [INPUT_END, INPUT_CANCEL].includes(inputType))) {
(this.options.minPressTime > deltaTime && [INPUT_END, INPUT_CANCEL].includes(stage))) {
this.cancel();

@@ -1105,3 +1100,3 @@ this.status = STATUS_FAILED;

return default_1;
}(default_1$5));
}(default_1$1));

@@ -1113,3 +1108,3 @@ var DEFAULT_OPTIONS$5 = {

};
var default_1$a = (function (_super) {
var default_1$6 = (function (_super) {
__extends(default_1, _super);

@@ -1134,3 +1129,3 @@ function default_1(options) {

return default_1;
}(default_1$5));
}(default_1$1));

@@ -1142,3 +1137,3 @@ var DEFAULT_OPTIONS$6 = {

};
var default_1$b = (function (_super) {
var default_1$7 = (function (_super) {
__extends(default_1, _super);

@@ -1161,16 +1156,16 @@ function default_1(options) {

return default_1;
}(default_1$5));
}(default_1$1));
AnyTouch.use(default_1$2);
AnyTouch.use(default_1$3);
AnyTouch.use(default_1$4);
AnyTouch.use(default_1$5);
AnyTouch.use(default_1$6);
AnyTouch.use(default_1$7);
AnyTouch.use(default_1$8);
AnyTouch.use(default_1$9);
AnyTouch.use(default_1$a);
AnyTouch.use(default_1$b);
AnyTouch.Tap = default_1$6;
AnyTouch.Pan = default_1$7;
AnyTouch.Swipe = default_1$8;
AnyTouch.Press = default_1$9;
AnyTouch.Pinch = default_1$a;
AnyTouch.Rotate = default_1$b;
AnyTouch.Tap = default_1$2;
AnyTouch.Pan = default_1$3;
AnyTouch.Swipe = default_1$4;
AnyTouch.Press = default_1$5;
AnyTouch.Pinch = default_1$6;
AnyTouch.Rotate = default_1$7;
AnyTouch.STATUS_POSSIBLE = STATUS_POSSIBLE;

@@ -1177,0 +1172,0 @@ AnyTouch.STATUS_START = STATUS_START;

@@ -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}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,s=(void 0===n?{}:n).target,a=Array.isArray(t)?t:[t];try{for(var u=i(a),c=u.next();!c.done;c=u.next()){var p=c.value;void 0===this.listenersMap[p]&&(this.listenersMap[p]=[]),void 0!==s&&(e.target=s),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 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}(),s=Object.prototype.toString;var a="cancel",u="end",c="touch"+u,p="touch"+a,h=window.wx||"ontouchstart"in window,l="start",v="move",f=u,d="r",m="f",y=a;function g(t){return Math.round(100*t)/100}var T=function(){},M=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.load=function(t,e){var n=[],i=[];Array.from(t.touches).forEach((function(t){var o=t.clientX,r=t.clientY,s=t.target;(null==e?void 0:e.contains(s))&&(n.push(s),i.push({clientX:o,clientY:r,target:s}))}));var o=Array.from(t.changedTouches).map((function(t){return{clientX:t.clientX,clientY:t.clientY,target:t.target}}));return{inputType:t.type.replace("touch",""),changedPoints:o,points:i,nativeEvent:t,target:t.target,targets:n}},n}(T),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,target:s}];"mousedown"===o&&0===r?(this.target=s,this.isPressed=!0,e="start"):this.isPressed&&("mousemove"===o?e="move":"mouseup"===o&&(a=[],e=u,this.isPressed=!1));var c=this.prevPoints||[{clientX:n,clientY:i,target:s}];if(this.prevPoints=[{clientX:n,clientY:i,target:s}],void 0!==e)return{inputType:e,changedPoints:c,points:a,target:this.target,targets:[this.target],nativeEvent:t}},n}(T),b=function(){function t(t){var e=h?M:x;this.adapter=new e,this.id=0,this.el=t}return t.prototype.transform=function(t){this.prevInput=this.activeInput;var e=this.adapter.load(t,this.el);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,c="start"===e,p=u===e&&0===s||a===e,h=performance.now(),l=E(i)||E(o),v=l.x,f=l.y,d=r.currentTarget;return n(n({},t),{x:v,y:f,timestamp:h,isStart:c,isEnd:p,pointLength:s,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)}}})}(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 E(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=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 P(t,e){if(!e.isPreventDefault)return!1;var n,i=!0;if(null!==t.target){var o=e.preventDefaultExclude;if(n=o,"[object RegExp]"===s.call(n)){if("tagName"in t.target){var r=t.target.tagName;i=!o.test(r)}}else(function(t){return"[object Function]"===s.call(t)})(o)&&(i=!o(t))}return i}var L=["touchstart","touchmove",c,p];function z(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 _(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){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&&(w(o,e,t.options.domEvents),w(o,n(n({},e),{_type:e.type,type:"at:after"}),t.options.domEvents))}var S={domEvents:{bubbles:!0,cancelable:!0},isPreventDefault:!0,preventDefaultExclude:/^(?:INPUT|TEXTAREA|BUTTON|SELECT)$/},O=function(t){function o(e,i){var r=t.call(this)||this;if(r.recognizerMap={},r.recognizers=[],r.cacheComputedFunctionGroup=Object.create(null),r.el=e,r.input=new b(e),r.options=n(n({},S),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,i){return h||"Touch"===i?(L.forEach((function(i){t.addEventListener(i,e,n)})),function(){L.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},r.options.device))}return r}return e(o,t),o.prototype.use=function(t,e){z(this,t,e)},o.prototype.removeUse=function(t){_(this,t)},o.prototype.catchEvent=function(t){var e,o,r=this;P(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=Object.create(null),h=function(t){if(t.disabled)return"continue";t.computedGroup=p,t.computeFunctionMap=l.cacheComputedFunctionGroup,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,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.7",o.recognizers=[],o.recognizerMap={},o.use=function(t,e){z(o,t,e)},o.removeUse=function(t){_(o,t)},o}(r);function D(t){-1!==[f,y,d,m].indexOf(t.status)&&(t.status="p")}function X(t,e,n){var i=t.test(e);D(t);var o=e.inputType;t.status=function(t,e,n){var i,o,r,s,c,p,h,d={1:(i={},i.p=(o={},o.move=l,o),i[l]=(r={},r.move=v,r[u]=f,r[a]=y,r),i[v]=(s={},s.move=v,s[u]=f,s[a]=y,s),i),0:(c={},c[l]=(p={},p.move=y,p[u]=f,p[a]=y,p),c[v]=(h={},h.start=m,h.move=y,h[u]=f,h[a]=y,h),c)};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 s=t.name,c=t.status,p=t.isRecognized;return p&&n(s,r),(p||[f,y].includes(t.status))&&n(s+c,r),i}var A=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 s=i(t),a=s.next();!a.done;a=s.next()){var u=a.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{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}return r},t}(),V=function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},Y=function(t){return t/Math.PI*180},C=function(t,e){var n=function(t,e){var n=V(t)*V(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),Y(n)},F=function(t,e){return t===e?"none":Math.abs(t)>Math.abs(e)?0<t?"right":"left":0<e?"down":"up"};function j(){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(Y(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(s){var a=s.inputType,u=s.startInput;return"start"===a?(t=0,e=0,n=0,i=0,o=0,r="none"):"move"===a&&(t=Math.round(s.points[0].clientX-u.points[0].clientX),e=Math.round(s.points[0].clientY-u.points[0].clientY),n=Math.abs(t),i=Math.abs(e),o=Math.round(V({x:n,y:i})),r=F(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.inputType&&(t=e.pointLength),{maxPointLength:t}}}function U(){var t,e,n=0,i=0,o=0,r=0;return function(s){if(void 0!==s){var a=s.inputType;e=e||s.startInput;var u=s.timestamp-e.timestamp;if("move"===a&&16<u){var c=s.x-e.x,p=s.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=F(c,p)||t,e=s}}return{velocityX:n,velocityY:i,speedX:o,speedY:r,direction:t}}}function G(t){return{x:t.points[1].clientX-t.points[0].clientX,y:t.points[1].clientY-t.points[0].clientY}}function k(){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:G(n),prevV:G(e),activeV:G(t)}}}j._id="ComputeDeltaXY",N._id="computeDistance",R._id="computeMaxLength",U._id="ComputeVAndDir",k._id="ComputeVectorForMutli";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.tapCount=0,i}return e(i,t),i.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var e=V({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([R,N],t),u===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,s=o.distance;return r===this.options.pointLength&&0===n&&this.options.maxDistance>=s&&this.options.maxPressTime>i},i}(A),q={name:"pan",threshold:10,pointLength:1},Z=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.distance;return(this.isRecognized||this.options.threshold<=n)&&this.isValidPointLength(e)},i.prototype.recognize=function(t,e){this.computed=this.compute([U,N,j],t),void 0!==this.computed.direction&&X(this,t,e)&&e(this.options.name+this.computed.direction,this.computed)},i}(A),$={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(u!==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([R,U,N],t),this.test(t)&&(e(this.options.name,this.computed),e(this.options.name+this.computed.direction,this.computed))},i}(A),K={name:"press",pointLength:1,maxDistance: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))D(this),this.cancel(),this._timeoutId=setTimeout((function(){n.status=d,e(n.options.name,t)}),this.options.minPressTime);else if(u===i&&d===this.status)e(this.options.name+"up",this.computed);else if(d!==this.status){var s=t.timestamp-o.timestamp;(!this.test(t)||this.options.minPressTime>s&&[u,a].includes(i))&&(this.cancel(),this.status=m)}},i.prototype.test=function(t){this.computed=this.compute([N],t);var e=this.computed.distance;return this.options.maxDistance>e},i.prototype.cancel=function(){clearTimeout(this._timeoutId)},i}(A),W={name:"pinch",threshold:0,pointLength:2},tt=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([k],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=g(V(s)/V(r)),{scale:g(V(s)/V(o)),deltaScale:a}))),X(this,t,e)},i}(A),et={name:"rotate",threshold:0,pointLength:2},nt=function(t){function i(e){return t.call(this,n(n({},et),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([k],t);"activeV"in u&&(this.computed=n(n({},this.computed),(o=(i=u).startV,r=i.prevV,s=i.activeV,a=Math.round(C(s,r)),{angle:Math.round(C(s,o)),deltaAngle:a}))),X(this,t,e)},i}(A);return O.use(B),O.use(Z),O.use(J),O.use(Q),O.use(tt),O.use(nt),O.Tap=B,O.Pan=Z,O.Swipe=J,O.Press=Q,O.Pinch=tt,O.Rotate=nt,O.STATUS_POSSIBLE="p",O.STATUS_START=l,O.STATUS_MOVE=v,O.STATUS_END=f,O.STATUS_CANCELLED=y,O.STATUS_FAILED=m,O.STATUS_RECOGNIZED=d,O}));
!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,_}));

@@ -1,1 +0,1 @@

"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;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var S=e(require("@any-touch/core")),T=e(require("@any-touch/tap")),u=e(require("@any-touch/pan")),r=e(require("@any-touch/swipe")),t=e(require("@any-touch/press")),a=e(require("@any-touch/pinch")),A=e(require("@any-touch/rotate")),o=require("@any-touch/shared");S.use(T),S.use(u),S.use(r),S.use(t),S.use(a),S.use(A),S.Tap=T,S.Pan=u,S.Swipe=r,S.Press=t,S.Pinch=a,S.Rotate=A,S.STATUS_POSSIBLE=o.STATUS_POSSIBLE,S.STATUS_START=o.STATUS_START,S.STATUS_MOVE=o.STATUS_MOVE,S.STATUS_END=o.STATUS_END,S.STATUS_CANCELLED=o.STATUS_CANCELLED,S.STATUS_FAILED=o.STATUS_FAILED,S.STATUS_RECOGNIZED=o.STATUS_RECOGNIZED,exports.default=S;
{
"name": "any-touch",
"version": "0.7.8",
"version": "0.7.9",
"description": "一个小巧的手势库",

@@ -25,10 +25,10 @@ "unpkg": "dist/any-touch.umd.min.js",

"dependencies": {
"@any-touch/core": "^0.7.8",
"@any-touch/pan": "^0.7.8",
"@any-touch/pinch": "^0.7.8",
"@any-touch/press": "^0.7.8",
"@any-touch/rotate": "^0.7.8",
"@any-touch/swipe": "^0.7.8",
"@any-touch/tap": "^0.7.8",
"any-event": "^0.7.8",
"@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",
"tslib": "^1.9.3"

@@ -42,3 +42,3 @@ },

"sideEffects": false,
"gitHead": "14f864223c9a4df212561b9a53e93a5f89217b15"
"gitHead": "4d795d9ac1c0cf597db9bc070284f3de7578e5fd"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc