@embedpdf/plugin-zoom 2.0.0-next.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preact/adapter.d.ts +1 -1
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +217 -71
- package/dist/preact/index.js.map +1 -1
- package/dist/preact/viewport.d.ts +1 -0
- package/dist/react/adapter.d.ts +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +217 -71
- package/dist/react/index.js.map +1 -1
- package/dist/react/viewport.d.ts +1 -0
- package/dist/shared/components/index.d.ts +1 -1
- package/dist/shared/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared/hooks/index.d.ts +1 -1
- package/dist/shared/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-preact/components/index.d.ts +1 -1
- package/dist/shared-preact/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared-preact/hooks/index.d.ts +1 -1
- package/dist/shared-preact/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared-preact/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared-preact/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared-preact/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-react/components/index.d.ts +1 -1
- package/dist/shared-react/components/zoom-gesture-wrapper.d.ts +12 -0
- package/dist/shared-react/hooks/index.d.ts +1 -1
- package/dist/shared-react/hooks/use-pinch-zoom.d.ts +3 -1
- package/dist/shared-react/hooks/use-zoom-gesture.d.ts +5 -0
- package/dist/shared-react/utils/pinch-zoom-logic.d.ts +11 -2
- package/dist/shared-react/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-svelte/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/shared-vue/utils/zoom-gesture-logic.d.ts +18 -0
- package/dist/svelte/components/ZoomGestureWrapper.svelte.d.ts +14 -0
- package/dist/svelte/components/index.d.ts +1 -1
- package/dist/svelte/hooks/index.d.ts +1 -1
- package/dist/svelte/hooks/use-pinch-zoom.svelte.d.ts +11 -2
- package/dist/svelte/hooks/use-zoom-gesture.svelte.d.ts +16 -0
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +214 -71
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/index.d.ts +1 -1
- package/dist/vue/components/{pinch-wrapper.vue.d.ts → zoom-gesture-wrapper.vue.d.ts} +8 -1
- package/dist/vue/hooks/index.d.ts +1 -1
- package/dist/vue/hooks/use-zoom-gesture.d.ts +17 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +211 -72
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -12
- package/dist/hammer-DhVzwxwy.cjs +0 -7
- package/dist/hammer-DhVzwxwy.cjs.map +0 -1
- package/dist/hammer-e1aXHboh.js +0 -1810
- package/dist/hammer-e1aXHboh.js.map +0 -1
- package/dist/shared/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-preact/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-react/components/pinch-wrapper.d.ts +0 -8
- package/dist/shared-svelte/utils/pinch-zoom-logic.d.ts +0 -9
- package/dist/shared-vue/utils/pinch-zoom-logic.d.ts +0 -9
- package/dist/svelte/components/PinchWrapper.svelte.d.ts +0 -10
- package/dist/vue/hooks/use-pinch-zoom.d.ts +0 -8
package/dist/hammer-e1aXHboh.js
DELETED
|
@@ -1,1810 +0,0 @@
|
|
|
1
|
-
function getDefaultExportFromCjs(x) {
|
|
2
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
3
|
-
}
|
|
4
|
-
var hammer$2 = { exports: {} };
|
|
5
|
-
/*! Hammer.JS - v2.0.7 - 2016-04-22
|
|
6
|
-
* http://hammerjs.github.io/
|
|
7
|
-
*
|
|
8
|
-
* Copyright (c) 2016 Jorik Tangelder;
|
|
9
|
-
* Licensed under the MIT license */
|
|
10
|
-
var hasRequiredHammer;
|
|
11
|
-
function requireHammer() {
|
|
12
|
-
if (hasRequiredHammer) return hammer$2.exports;
|
|
13
|
-
hasRequiredHammer = 1;
|
|
14
|
-
(function(module) {
|
|
15
|
-
(function(window2, document2, exportName, undefined$1) {
|
|
16
|
-
var VENDOR_PREFIXES = ["", "webkit", "Moz", "MS", "ms", "o"];
|
|
17
|
-
var TEST_ELEMENT = document2.createElement("div");
|
|
18
|
-
var TYPE_FUNCTION = "function";
|
|
19
|
-
var round = Math.round;
|
|
20
|
-
var abs = Math.abs;
|
|
21
|
-
var now = Date.now;
|
|
22
|
-
function setTimeoutContext(fn, timeout, context) {
|
|
23
|
-
return setTimeout(bindFn(fn, context), timeout);
|
|
24
|
-
}
|
|
25
|
-
function invokeArrayArg(arg, fn, context) {
|
|
26
|
-
if (Array.isArray(arg)) {
|
|
27
|
-
each(arg, context[fn], context);
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
function each(obj, iterator, context) {
|
|
33
|
-
var i;
|
|
34
|
-
if (!obj) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
if (obj.forEach) {
|
|
38
|
-
obj.forEach(iterator, context);
|
|
39
|
-
} else if (obj.length !== undefined$1) {
|
|
40
|
-
i = 0;
|
|
41
|
-
while (i < obj.length) {
|
|
42
|
-
iterator.call(context, obj[i], i, obj);
|
|
43
|
-
i++;
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
for (i in obj) {
|
|
47
|
-
obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function deprecate(method, name, message) {
|
|
52
|
-
var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
|
|
53
|
-
return function() {
|
|
54
|
-
var e = new Error("get-stack-trace");
|
|
55
|
-
var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace";
|
|
56
|
-
var log = window2.console && (window2.console.warn || window2.console.log);
|
|
57
|
-
if (log) {
|
|
58
|
-
log.call(window2.console, deprecationMessage, stack);
|
|
59
|
-
}
|
|
60
|
-
return method.apply(this, arguments);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
var assign;
|
|
64
|
-
if (typeof Object.assign !== "function") {
|
|
65
|
-
assign = function assign2(target) {
|
|
66
|
-
if (target === undefined$1 || target === null) {
|
|
67
|
-
throw new TypeError("Cannot convert undefined or null to object");
|
|
68
|
-
}
|
|
69
|
-
var output = Object(target);
|
|
70
|
-
for (var index = 1; index < arguments.length; index++) {
|
|
71
|
-
var source = arguments[index];
|
|
72
|
-
if (source !== undefined$1 && source !== null) {
|
|
73
|
-
for (var nextKey in source) {
|
|
74
|
-
if (source.hasOwnProperty(nextKey)) {
|
|
75
|
-
output[nextKey] = source[nextKey];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return output;
|
|
81
|
-
};
|
|
82
|
-
} else {
|
|
83
|
-
assign = Object.assign;
|
|
84
|
-
}
|
|
85
|
-
var extend = deprecate(function extend2(dest, src, merge2) {
|
|
86
|
-
var keys = Object.keys(src);
|
|
87
|
-
var i = 0;
|
|
88
|
-
while (i < keys.length) {
|
|
89
|
-
if (!merge2 || merge2 && dest[keys[i]] === undefined$1) {
|
|
90
|
-
dest[keys[i]] = src[keys[i]];
|
|
91
|
-
}
|
|
92
|
-
i++;
|
|
93
|
-
}
|
|
94
|
-
return dest;
|
|
95
|
-
}, "extend", "Use `assign`.");
|
|
96
|
-
var merge = deprecate(function merge2(dest, src) {
|
|
97
|
-
return extend(dest, src, true);
|
|
98
|
-
}, "merge", "Use `assign`.");
|
|
99
|
-
function inherit(child, base, properties) {
|
|
100
|
-
var baseP = base.prototype, childP;
|
|
101
|
-
childP = child.prototype = Object.create(baseP);
|
|
102
|
-
childP.constructor = child;
|
|
103
|
-
childP._super = baseP;
|
|
104
|
-
if (properties) {
|
|
105
|
-
assign(childP, properties);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
function bindFn(fn, context) {
|
|
109
|
-
return function boundFn() {
|
|
110
|
-
return fn.apply(context, arguments);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function boolOrFn(val, args) {
|
|
114
|
-
if (typeof val == TYPE_FUNCTION) {
|
|
115
|
-
return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
|
|
116
|
-
}
|
|
117
|
-
return val;
|
|
118
|
-
}
|
|
119
|
-
function ifUndefined(val1, val2) {
|
|
120
|
-
return val1 === undefined$1 ? val2 : val1;
|
|
121
|
-
}
|
|
122
|
-
function addEventListeners(target, types, handler) {
|
|
123
|
-
each(splitStr(types), function(type) {
|
|
124
|
-
target.addEventListener(type, handler, false);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function removeEventListeners(target, types, handler) {
|
|
128
|
-
each(splitStr(types), function(type) {
|
|
129
|
-
target.removeEventListener(type, handler, false);
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
function hasParent(node, parent) {
|
|
133
|
-
while (node) {
|
|
134
|
-
if (node == parent) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
node = node.parentNode;
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
function inStr(str, find) {
|
|
142
|
-
return str.indexOf(find) > -1;
|
|
143
|
-
}
|
|
144
|
-
function splitStr(str) {
|
|
145
|
-
return str.trim().split(/\s+/g);
|
|
146
|
-
}
|
|
147
|
-
function inArray(src, find, findByKey) {
|
|
148
|
-
if (src.indexOf && !findByKey) {
|
|
149
|
-
return src.indexOf(find);
|
|
150
|
-
} else {
|
|
151
|
-
var i = 0;
|
|
152
|
-
while (i < src.length) {
|
|
153
|
-
if (findByKey && src[i][findByKey] == find || !findByKey && src[i] === find) {
|
|
154
|
-
return i;
|
|
155
|
-
}
|
|
156
|
-
i++;
|
|
157
|
-
}
|
|
158
|
-
return -1;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function toArray(obj) {
|
|
162
|
-
return Array.prototype.slice.call(obj, 0);
|
|
163
|
-
}
|
|
164
|
-
function uniqueArray(src, key, sort) {
|
|
165
|
-
var results = [];
|
|
166
|
-
var values = [];
|
|
167
|
-
var i = 0;
|
|
168
|
-
while (i < src.length) {
|
|
169
|
-
var val = src[i][key];
|
|
170
|
-
if (inArray(values, val) < 0) {
|
|
171
|
-
results.push(src[i]);
|
|
172
|
-
}
|
|
173
|
-
values[i] = val;
|
|
174
|
-
i++;
|
|
175
|
-
}
|
|
176
|
-
{
|
|
177
|
-
{
|
|
178
|
-
results = results.sort(function sortUniqueArray(a, b) {
|
|
179
|
-
return a[key] > b[key];
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return results;
|
|
184
|
-
}
|
|
185
|
-
function prefixed(obj, property) {
|
|
186
|
-
var prefix, prop;
|
|
187
|
-
var camelProp = property[0].toUpperCase() + property.slice(1);
|
|
188
|
-
var i = 0;
|
|
189
|
-
while (i < VENDOR_PREFIXES.length) {
|
|
190
|
-
prefix = VENDOR_PREFIXES[i];
|
|
191
|
-
prop = prefix ? prefix + camelProp : property;
|
|
192
|
-
if (prop in obj) {
|
|
193
|
-
return prop;
|
|
194
|
-
}
|
|
195
|
-
i++;
|
|
196
|
-
}
|
|
197
|
-
return undefined$1;
|
|
198
|
-
}
|
|
199
|
-
var _uniqueId = 1;
|
|
200
|
-
function uniqueId() {
|
|
201
|
-
return _uniqueId++;
|
|
202
|
-
}
|
|
203
|
-
function getWindowForElement(element) {
|
|
204
|
-
var doc = element.ownerDocument || element;
|
|
205
|
-
return doc.defaultView || doc.parentWindow || window2;
|
|
206
|
-
}
|
|
207
|
-
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
208
|
-
var SUPPORT_TOUCH = "ontouchstart" in window2;
|
|
209
|
-
var SUPPORT_POINTER_EVENTS = prefixed(window2, "PointerEvent") !== undefined$1;
|
|
210
|
-
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
|
211
|
-
var INPUT_TYPE_TOUCH = "touch";
|
|
212
|
-
var INPUT_TYPE_PEN = "pen";
|
|
213
|
-
var INPUT_TYPE_MOUSE = "mouse";
|
|
214
|
-
var INPUT_TYPE_KINECT = "kinect";
|
|
215
|
-
var COMPUTE_INTERVAL = 25;
|
|
216
|
-
var INPUT_START = 1;
|
|
217
|
-
var INPUT_MOVE = 2;
|
|
218
|
-
var INPUT_END = 4;
|
|
219
|
-
var INPUT_CANCEL = 8;
|
|
220
|
-
var DIRECTION_NONE = 1;
|
|
221
|
-
var DIRECTION_LEFT = 2;
|
|
222
|
-
var DIRECTION_RIGHT = 4;
|
|
223
|
-
var DIRECTION_UP = 8;
|
|
224
|
-
var DIRECTION_DOWN = 16;
|
|
225
|
-
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
226
|
-
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
227
|
-
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
|
228
|
-
var PROPS_XY = ["x", "y"];
|
|
229
|
-
var PROPS_CLIENT_XY = ["clientX", "clientY"];
|
|
230
|
-
function Input(manager, callback) {
|
|
231
|
-
var self2 = this;
|
|
232
|
-
this.manager = manager;
|
|
233
|
-
this.callback = callback;
|
|
234
|
-
this.element = manager.element;
|
|
235
|
-
this.target = manager.options.inputTarget;
|
|
236
|
-
this.domHandler = function(ev) {
|
|
237
|
-
if (boolOrFn(manager.options.enable, [manager])) {
|
|
238
|
-
self2.handler(ev);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
this.init();
|
|
242
|
-
}
|
|
243
|
-
Input.prototype = {
|
|
244
|
-
/**
|
|
245
|
-
* should handle the inputEvent data and trigger the callback
|
|
246
|
-
* @virtual
|
|
247
|
-
*/
|
|
248
|
-
handler: function() {
|
|
249
|
-
},
|
|
250
|
-
/**
|
|
251
|
-
* bind the events
|
|
252
|
-
*/
|
|
253
|
-
init: function() {
|
|
254
|
-
this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
|
255
|
-
this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
|
256
|
-
this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
257
|
-
},
|
|
258
|
-
/**
|
|
259
|
-
* unbind the events
|
|
260
|
-
*/
|
|
261
|
-
destroy: function() {
|
|
262
|
-
this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
|
263
|
-
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
|
264
|
-
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
function createInputInstance(manager) {
|
|
268
|
-
var Type;
|
|
269
|
-
var inputClass = manager.options.inputClass;
|
|
270
|
-
if (inputClass) {
|
|
271
|
-
Type = inputClass;
|
|
272
|
-
} else if (SUPPORT_POINTER_EVENTS) {
|
|
273
|
-
Type = PointerEventInput;
|
|
274
|
-
} else if (SUPPORT_ONLY_TOUCH) {
|
|
275
|
-
Type = TouchInput;
|
|
276
|
-
} else if (!SUPPORT_TOUCH) {
|
|
277
|
-
Type = MouseInput;
|
|
278
|
-
} else {
|
|
279
|
-
Type = TouchMouseInput;
|
|
280
|
-
}
|
|
281
|
-
return new Type(manager, inputHandler);
|
|
282
|
-
}
|
|
283
|
-
function inputHandler(manager, eventType, input) {
|
|
284
|
-
var pointersLen = input.pointers.length;
|
|
285
|
-
var changedPointersLen = input.changedPointers.length;
|
|
286
|
-
var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
|
287
|
-
var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
|
288
|
-
input.isFirst = !!isFirst;
|
|
289
|
-
input.isFinal = !!isFinal;
|
|
290
|
-
if (isFirst) {
|
|
291
|
-
manager.session = {};
|
|
292
|
-
}
|
|
293
|
-
input.eventType = eventType;
|
|
294
|
-
computeInputData(manager, input);
|
|
295
|
-
manager.emit("hammer.input", input);
|
|
296
|
-
manager.recognize(input);
|
|
297
|
-
manager.session.prevInput = input;
|
|
298
|
-
}
|
|
299
|
-
function computeInputData(manager, input) {
|
|
300
|
-
var session = manager.session;
|
|
301
|
-
var pointers = input.pointers;
|
|
302
|
-
var pointersLength = pointers.length;
|
|
303
|
-
if (!session.firstInput) {
|
|
304
|
-
session.firstInput = simpleCloneInputData(input);
|
|
305
|
-
}
|
|
306
|
-
if (pointersLength > 1 && !session.firstMultiple) {
|
|
307
|
-
session.firstMultiple = simpleCloneInputData(input);
|
|
308
|
-
} else if (pointersLength === 1) {
|
|
309
|
-
session.firstMultiple = false;
|
|
310
|
-
}
|
|
311
|
-
var firstInput = session.firstInput;
|
|
312
|
-
var firstMultiple = session.firstMultiple;
|
|
313
|
-
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
|
314
|
-
var center = input.center = getCenter(pointers);
|
|
315
|
-
input.timeStamp = now();
|
|
316
|
-
input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
|
317
|
-
input.angle = getAngle(offsetCenter, center);
|
|
318
|
-
input.distance = getDistance(offsetCenter, center);
|
|
319
|
-
computeDeltaXY(session, input);
|
|
320
|
-
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
|
321
|
-
var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
|
322
|
-
input.overallVelocityX = overallVelocity.x;
|
|
323
|
-
input.overallVelocityY = overallVelocity.y;
|
|
324
|
-
input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
|
325
|
-
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
|
326
|
-
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
|
327
|
-
input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
|
328
|
-
computeIntervalInputData(session, input);
|
|
329
|
-
var target = manager.element;
|
|
330
|
-
if (hasParent(input.srcEvent.target, target)) {
|
|
331
|
-
target = input.srcEvent.target;
|
|
332
|
-
}
|
|
333
|
-
input.target = target;
|
|
334
|
-
}
|
|
335
|
-
function computeDeltaXY(session, input) {
|
|
336
|
-
var center = input.center;
|
|
337
|
-
var offset = session.offsetDelta || {};
|
|
338
|
-
var prevDelta = session.prevDelta || {};
|
|
339
|
-
var prevInput = session.prevInput || {};
|
|
340
|
-
if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
|
341
|
-
prevDelta = session.prevDelta = {
|
|
342
|
-
x: prevInput.deltaX || 0,
|
|
343
|
-
y: prevInput.deltaY || 0
|
|
344
|
-
};
|
|
345
|
-
offset = session.offsetDelta = {
|
|
346
|
-
x: center.x,
|
|
347
|
-
y: center.y
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
input.deltaX = prevDelta.x + (center.x - offset.x);
|
|
351
|
-
input.deltaY = prevDelta.y + (center.y - offset.y);
|
|
352
|
-
}
|
|
353
|
-
function computeIntervalInputData(session, input) {
|
|
354
|
-
var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
|
|
355
|
-
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
|
|
356
|
-
var deltaX = input.deltaX - last.deltaX;
|
|
357
|
-
var deltaY = input.deltaY - last.deltaY;
|
|
358
|
-
var v = getVelocity(deltaTime, deltaX, deltaY);
|
|
359
|
-
velocityX = v.x;
|
|
360
|
-
velocityY = v.y;
|
|
361
|
-
velocity = abs(v.x) > abs(v.y) ? v.x : v.y;
|
|
362
|
-
direction = getDirection(deltaX, deltaY);
|
|
363
|
-
session.lastInterval = input;
|
|
364
|
-
} else {
|
|
365
|
-
velocity = last.velocity;
|
|
366
|
-
velocityX = last.velocityX;
|
|
367
|
-
velocityY = last.velocityY;
|
|
368
|
-
direction = last.direction;
|
|
369
|
-
}
|
|
370
|
-
input.velocity = velocity;
|
|
371
|
-
input.velocityX = velocityX;
|
|
372
|
-
input.velocityY = velocityY;
|
|
373
|
-
input.direction = direction;
|
|
374
|
-
}
|
|
375
|
-
function simpleCloneInputData(input) {
|
|
376
|
-
var pointers = [];
|
|
377
|
-
var i = 0;
|
|
378
|
-
while (i < input.pointers.length) {
|
|
379
|
-
pointers[i] = {
|
|
380
|
-
clientX: round(input.pointers[i].clientX),
|
|
381
|
-
clientY: round(input.pointers[i].clientY)
|
|
382
|
-
};
|
|
383
|
-
i++;
|
|
384
|
-
}
|
|
385
|
-
return {
|
|
386
|
-
timeStamp: now(),
|
|
387
|
-
pointers,
|
|
388
|
-
center: getCenter(pointers),
|
|
389
|
-
deltaX: input.deltaX,
|
|
390
|
-
deltaY: input.deltaY
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function getCenter(pointers) {
|
|
394
|
-
var pointersLength = pointers.length;
|
|
395
|
-
if (pointersLength === 1) {
|
|
396
|
-
return {
|
|
397
|
-
x: round(pointers[0].clientX),
|
|
398
|
-
y: round(pointers[0].clientY)
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
var x = 0, y = 0, i = 0;
|
|
402
|
-
while (i < pointersLength) {
|
|
403
|
-
x += pointers[i].clientX;
|
|
404
|
-
y += pointers[i].clientY;
|
|
405
|
-
i++;
|
|
406
|
-
}
|
|
407
|
-
return {
|
|
408
|
-
x: round(x / pointersLength),
|
|
409
|
-
y: round(y / pointersLength)
|
|
410
|
-
};
|
|
411
|
-
}
|
|
412
|
-
function getVelocity(deltaTime, x, y) {
|
|
413
|
-
return {
|
|
414
|
-
x: x / deltaTime || 0,
|
|
415
|
-
y: y / deltaTime || 0
|
|
416
|
-
};
|
|
417
|
-
}
|
|
418
|
-
function getDirection(x, y) {
|
|
419
|
-
if (x === y) {
|
|
420
|
-
return DIRECTION_NONE;
|
|
421
|
-
}
|
|
422
|
-
if (abs(x) >= abs(y)) {
|
|
423
|
-
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
424
|
-
}
|
|
425
|
-
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
426
|
-
}
|
|
427
|
-
function getDistance(p1, p2, props) {
|
|
428
|
-
if (!props) {
|
|
429
|
-
props = PROPS_XY;
|
|
430
|
-
}
|
|
431
|
-
var x = p2[props[0]] - p1[props[0]], y = p2[props[1]] - p1[props[1]];
|
|
432
|
-
return Math.sqrt(x * x + y * y);
|
|
433
|
-
}
|
|
434
|
-
function getAngle(p1, p2, props) {
|
|
435
|
-
if (!props) {
|
|
436
|
-
props = PROPS_XY;
|
|
437
|
-
}
|
|
438
|
-
var x = p2[props[0]] - p1[props[0]], y = p2[props[1]] - p1[props[1]];
|
|
439
|
-
return Math.atan2(y, x) * 180 / Math.PI;
|
|
440
|
-
}
|
|
441
|
-
function getRotation(start, end) {
|
|
442
|
-
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
|
443
|
-
}
|
|
444
|
-
function getScale(start, end) {
|
|
445
|
-
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
|
446
|
-
}
|
|
447
|
-
var MOUSE_INPUT_MAP = {
|
|
448
|
-
mousedown: INPUT_START,
|
|
449
|
-
mousemove: INPUT_MOVE,
|
|
450
|
-
mouseup: INPUT_END
|
|
451
|
-
};
|
|
452
|
-
var MOUSE_ELEMENT_EVENTS = "mousedown";
|
|
453
|
-
var MOUSE_WINDOW_EVENTS = "mousemove mouseup";
|
|
454
|
-
function MouseInput() {
|
|
455
|
-
this.evEl = MOUSE_ELEMENT_EVENTS;
|
|
456
|
-
this.evWin = MOUSE_WINDOW_EVENTS;
|
|
457
|
-
this.pressed = false;
|
|
458
|
-
Input.apply(this, arguments);
|
|
459
|
-
}
|
|
460
|
-
inherit(MouseInput, Input, {
|
|
461
|
-
/**
|
|
462
|
-
* handle mouse events
|
|
463
|
-
* @param {Object} ev
|
|
464
|
-
*/
|
|
465
|
-
handler: function MEhandler(ev) {
|
|
466
|
-
var eventType = MOUSE_INPUT_MAP[ev.type];
|
|
467
|
-
if (eventType & INPUT_START && ev.button === 0) {
|
|
468
|
-
this.pressed = true;
|
|
469
|
-
}
|
|
470
|
-
if (eventType & INPUT_MOVE && ev.which !== 1) {
|
|
471
|
-
eventType = INPUT_END;
|
|
472
|
-
}
|
|
473
|
-
if (!this.pressed) {
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
if (eventType & INPUT_END) {
|
|
477
|
-
this.pressed = false;
|
|
478
|
-
}
|
|
479
|
-
this.callback(this.manager, eventType, {
|
|
480
|
-
pointers: [ev],
|
|
481
|
-
changedPointers: [ev],
|
|
482
|
-
pointerType: INPUT_TYPE_MOUSE,
|
|
483
|
-
srcEvent: ev
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
var POINTER_INPUT_MAP = {
|
|
488
|
-
pointerdown: INPUT_START,
|
|
489
|
-
pointermove: INPUT_MOVE,
|
|
490
|
-
pointerup: INPUT_END,
|
|
491
|
-
pointercancel: INPUT_CANCEL,
|
|
492
|
-
pointerout: INPUT_CANCEL
|
|
493
|
-
};
|
|
494
|
-
var IE10_POINTER_TYPE_ENUM = {
|
|
495
|
-
2: INPUT_TYPE_TOUCH,
|
|
496
|
-
3: INPUT_TYPE_PEN,
|
|
497
|
-
4: INPUT_TYPE_MOUSE,
|
|
498
|
-
5: INPUT_TYPE_KINECT
|
|
499
|
-
// see https://twitter.com/jacobrossi/status/480596438489890816
|
|
500
|
-
};
|
|
501
|
-
var POINTER_ELEMENT_EVENTS = "pointerdown";
|
|
502
|
-
var POINTER_WINDOW_EVENTS = "pointermove pointerup pointercancel";
|
|
503
|
-
if (window2.MSPointerEvent && !window2.PointerEvent) {
|
|
504
|
-
POINTER_ELEMENT_EVENTS = "MSPointerDown";
|
|
505
|
-
POINTER_WINDOW_EVENTS = "MSPointerMove MSPointerUp MSPointerCancel";
|
|
506
|
-
}
|
|
507
|
-
function PointerEventInput() {
|
|
508
|
-
this.evEl = POINTER_ELEMENT_EVENTS;
|
|
509
|
-
this.evWin = POINTER_WINDOW_EVENTS;
|
|
510
|
-
Input.apply(this, arguments);
|
|
511
|
-
this.store = this.manager.session.pointerEvents = [];
|
|
512
|
-
}
|
|
513
|
-
inherit(PointerEventInput, Input, {
|
|
514
|
-
/**
|
|
515
|
-
* handle mouse events
|
|
516
|
-
* @param {Object} ev
|
|
517
|
-
*/
|
|
518
|
-
handler: function PEhandler(ev) {
|
|
519
|
-
var store = this.store;
|
|
520
|
-
var removePointer = false;
|
|
521
|
-
var eventTypeNormalized = ev.type.toLowerCase().replace("ms", "");
|
|
522
|
-
var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
|
523
|
-
var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
|
524
|
-
var isTouch = pointerType == INPUT_TYPE_TOUCH;
|
|
525
|
-
var storeIndex = inArray(store, ev.pointerId, "pointerId");
|
|
526
|
-
if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
|
527
|
-
if (storeIndex < 0) {
|
|
528
|
-
store.push(ev);
|
|
529
|
-
storeIndex = store.length - 1;
|
|
530
|
-
}
|
|
531
|
-
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
532
|
-
removePointer = true;
|
|
533
|
-
}
|
|
534
|
-
if (storeIndex < 0) {
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
store[storeIndex] = ev;
|
|
538
|
-
this.callback(this.manager, eventType, {
|
|
539
|
-
pointers: store,
|
|
540
|
-
changedPointers: [ev],
|
|
541
|
-
pointerType,
|
|
542
|
-
srcEvent: ev
|
|
543
|
-
});
|
|
544
|
-
if (removePointer) {
|
|
545
|
-
store.splice(storeIndex, 1);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
var SINGLE_TOUCH_INPUT_MAP = {
|
|
550
|
-
touchstart: INPUT_START,
|
|
551
|
-
touchmove: INPUT_MOVE,
|
|
552
|
-
touchend: INPUT_END,
|
|
553
|
-
touchcancel: INPUT_CANCEL
|
|
554
|
-
};
|
|
555
|
-
var SINGLE_TOUCH_TARGET_EVENTS = "touchstart";
|
|
556
|
-
var SINGLE_TOUCH_WINDOW_EVENTS = "touchstart touchmove touchend touchcancel";
|
|
557
|
-
function SingleTouchInput() {
|
|
558
|
-
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
|
559
|
-
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
|
560
|
-
this.started = false;
|
|
561
|
-
Input.apply(this, arguments);
|
|
562
|
-
}
|
|
563
|
-
inherit(SingleTouchInput, Input, {
|
|
564
|
-
handler: function TEhandler(ev) {
|
|
565
|
-
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
|
566
|
-
if (type === INPUT_START) {
|
|
567
|
-
this.started = true;
|
|
568
|
-
}
|
|
569
|
-
if (!this.started) {
|
|
570
|
-
return;
|
|
571
|
-
}
|
|
572
|
-
var touches = normalizeSingleTouches.call(this, ev, type);
|
|
573
|
-
if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
|
574
|
-
this.started = false;
|
|
575
|
-
}
|
|
576
|
-
this.callback(this.manager, type, {
|
|
577
|
-
pointers: touches[0],
|
|
578
|
-
changedPointers: touches[1],
|
|
579
|
-
pointerType: INPUT_TYPE_TOUCH,
|
|
580
|
-
srcEvent: ev
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
function normalizeSingleTouches(ev, type) {
|
|
585
|
-
var all = toArray(ev.touches);
|
|
586
|
-
var changed = toArray(ev.changedTouches);
|
|
587
|
-
if (type & (INPUT_END | INPUT_CANCEL)) {
|
|
588
|
-
all = uniqueArray(all.concat(changed), "identifier");
|
|
589
|
-
}
|
|
590
|
-
return [all, changed];
|
|
591
|
-
}
|
|
592
|
-
var TOUCH_INPUT_MAP = {
|
|
593
|
-
touchstart: INPUT_START,
|
|
594
|
-
touchmove: INPUT_MOVE,
|
|
595
|
-
touchend: INPUT_END,
|
|
596
|
-
touchcancel: INPUT_CANCEL
|
|
597
|
-
};
|
|
598
|
-
var TOUCH_TARGET_EVENTS = "touchstart touchmove touchend touchcancel";
|
|
599
|
-
function TouchInput() {
|
|
600
|
-
this.evTarget = TOUCH_TARGET_EVENTS;
|
|
601
|
-
this.targetIds = {};
|
|
602
|
-
Input.apply(this, arguments);
|
|
603
|
-
}
|
|
604
|
-
inherit(TouchInput, Input, {
|
|
605
|
-
handler: function MTEhandler(ev) {
|
|
606
|
-
var type = TOUCH_INPUT_MAP[ev.type];
|
|
607
|
-
var touches = getTouches.call(this, ev, type);
|
|
608
|
-
if (!touches) {
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
this.callback(this.manager, type, {
|
|
612
|
-
pointers: touches[0],
|
|
613
|
-
changedPointers: touches[1],
|
|
614
|
-
pointerType: INPUT_TYPE_TOUCH,
|
|
615
|
-
srcEvent: ev
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
});
|
|
619
|
-
function getTouches(ev, type) {
|
|
620
|
-
var allTouches = toArray(ev.touches);
|
|
621
|
-
var targetIds = this.targetIds;
|
|
622
|
-
if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
|
623
|
-
targetIds[allTouches[0].identifier] = true;
|
|
624
|
-
return [allTouches, allTouches];
|
|
625
|
-
}
|
|
626
|
-
var i, targetTouches, changedTouches = toArray(ev.changedTouches), changedTargetTouches = [], target = this.target;
|
|
627
|
-
targetTouches = allTouches.filter(function(touch) {
|
|
628
|
-
return hasParent(touch.target, target);
|
|
629
|
-
});
|
|
630
|
-
if (type === INPUT_START) {
|
|
631
|
-
i = 0;
|
|
632
|
-
while (i < targetTouches.length) {
|
|
633
|
-
targetIds[targetTouches[i].identifier] = true;
|
|
634
|
-
i++;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
i = 0;
|
|
638
|
-
while (i < changedTouches.length) {
|
|
639
|
-
if (targetIds[changedTouches[i].identifier]) {
|
|
640
|
-
changedTargetTouches.push(changedTouches[i]);
|
|
641
|
-
}
|
|
642
|
-
if (type & (INPUT_END | INPUT_CANCEL)) {
|
|
643
|
-
delete targetIds[changedTouches[i].identifier];
|
|
644
|
-
}
|
|
645
|
-
i++;
|
|
646
|
-
}
|
|
647
|
-
if (!changedTargetTouches.length) {
|
|
648
|
-
return;
|
|
649
|
-
}
|
|
650
|
-
return [
|
|
651
|
-
// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
|
|
652
|
-
uniqueArray(targetTouches.concat(changedTargetTouches), "identifier"),
|
|
653
|
-
changedTargetTouches
|
|
654
|
-
];
|
|
655
|
-
}
|
|
656
|
-
var DEDUP_TIMEOUT = 2500;
|
|
657
|
-
var DEDUP_DISTANCE = 25;
|
|
658
|
-
function TouchMouseInput() {
|
|
659
|
-
Input.apply(this, arguments);
|
|
660
|
-
var handler = bindFn(this.handler, this);
|
|
661
|
-
this.touch = new TouchInput(this.manager, handler);
|
|
662
|
-
this.mouse = new MouseInput(this.manager, handler);
|
|
663
|
-
this.primaryTouch = null;
|
|
664
|
-
this.lastTouches = [];
|
|
665
|
-
}
|
|
666
|
-
inherit(TouchMouseInput, Input, {
|
|
667
|
-
/**
|
|
668
|
-
* handle mouse and touch events
|
|
669
|
-
* @param {Hammer} manager
|
|
670
|
-
* @param {String} inputEvent
|
|
671
|
-
* @param {Object} inputData
|
|
672
|
-
*/
|
|
673
|
-
handler: function TMEhandler(manager, inputEvent, inputData) {
|
|
674
|
-
var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH, isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
|
|
675
|
-
if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
if (isTouch) {
|
|
679
|
-
recordTouches.call(this, inputEvent, inputData);
|
|
680
|
-
} else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
|
681
|
-
return;
|
|
682
|
-
}
|
|
683
|
-
this.callback(manager, inputEvent, inputData);
|
|
684
|
-
},
|
|
685
|
-
/**
|
|
686
|
-
* remove the event listeners
|
|
687
|
-
*/
|
|
688
|
-
destroy: function destroy() {
|
|
689
|
-
this.touch.destroy();
|
|
690
|
-
this.mouse.destroy();
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
function recordTouches(eventType, eventData) {
|
|
694
|
-
if (eventType & INPUT_START) {
|
|
695
|
-
this.primaryTouch = eventData.changedPointers[0].identifier;
|
|
696
|
-
setLastTouch.call(this, eventData);
|
|
697
|
-
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
698
|
-
setLastTouch.call(this, eventData);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
function setLastTouch(eventData) {
|
|
702
|
-
var touch = eventData.changedPointers[0];
|
|
703
|
-
if (touch.identifier === this.primaryTouch) {
|
|
704
|
-
var lastTouch = { x: touch.clientX, y: touch.clientY };
|
|
705
|
-
this.lastTouches.push(lastTouch);
|
|
706
|
-
var lts = this.lastTouches;
|
|
707
|
-
var removeLastTouch = function() {
|
|
708
|
-
var i = lts.indexOf(lastTouch);
|
|
709
|
-
if (i > -1) {
|
|
710
|
-
lts.splice(i, 1);
|
|
711
|
-
}
|
|
712
|
-
};
|
|
713
|
-
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
function isSyntheticEvent(eventData) {
|
|
717
|
-
var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
|
718
|
-
for (var i = 0; i < this.lastTouches.length; i++) {
|
|
719
|
-
var t = this.lastTouches[i];
|
|
720
|
-
var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
|
|
721
|
-
if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
|
722
|
-
return true;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
|
-
var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, "touchAction");
|
|
728
|
-
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
|
|
729
|
-
var TOUCH_ACTION_COMPUTE = "compute";
|
|
730
|
-
var TOUCH_ACTION_AUTO = "auto";
|
|
731
|
-
var TOUCH_ACTION_MANIPULATION = "manipulation";
|
|
732
|
-
var TOUCH_ACTION_NONE = "none";
|
|
733
|
-
var TOUCH_ACTION_PAN_X = "pan-x";
|
|
734
|
-
var TOUCH_ACTION_PAN_Y = "pan-y";
|
|
735
|
-
var TOUCH_ACTION_MAP = getTouchActionProps();
|
|
736
|
-
function TouchAction(manager, value) {
|
|
737
|
-
this.manager = manager;
|
|
738
|
-
this.set(value);
|
|
739
|
-
}
|
|
740
|
-
TouchAction.prototype = {
|
|
741
|
-
/**
|
|
742
|
-
* set the touchAction value on the element or enable the polyfill
|
|
743
|
-
* @param {String} value
|
|
744
|
-
*/
|
|
745
|
-
set: function(value) {
|
|
746
|
-
if (value == TOUCH_ACTION_COMPUTE) {
|
|
747
|
-
value = this.compute();
|
|
748
|
-
}
|
|
749
|
-
if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
|
750
|
-
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
|
751
|
-
}
|
|
752
|
-
this.actions = value.toLowerCase().trim();
|
|
753
|
-
},
|
|
754
|
-
/**
|
|
755
|
-
* just re-set the touchAction value
|
|
756
|
-
*/
|
|
757
|
-
update: function() {
|
|
758
|
-
this.set(this.manager.options.touchAction);
|
|
759
|
-
},
|
|
760
|
-
/**
|
|
761
|
-
* compute the value for the touchAction property based on the recognizer's settings
|
|
762
|
-
* @returns {String} value
|
|
763
|
-
*/
|
|
764
|
-
compute: function() {
|
|
765
|
-
var actions = [];
|
|
766
|
-
each(this.manager.recognizers, function(recognizer) {
|
|
767
|
-
if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
|
768
|
-
actions = actions.concat(recognizer.getTouchAction());
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
return cleanTouchActions(actions.join(" "));
|
|
772
|
-
},
|
|
773
|
-
/**
|
|
774
|
-
* this method is called on each input cycle and provides the preventing of the browser behavior
|
|
775
|
-
* @param {Object} input
|
|
776
|
-
*/
|
|
777
|
-
preventDefaults: function(input) {
|
|
778
|
-
var srcEvent = input.srcEvent;
|
|
779
|
-
var direction = input.offsetDirection;
|
|
780
|
-
if (this.manager.session.prevented) {
|
|
781
|
-
srcEvent.preventDefault();
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
var actions = this.actions;
|
|
785
|
-
var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
|
786
|
-
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
|
787
|
-
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
|
788
|
-
if (hasNone) {
|
|
789
|
-
var isTapPointer = input.pointers.length === 1;
|
|
790
|
-
var isTapMovement = input.distance < 2;
|
|
791
|
-
var isTapTouchTime = input.deltaTime < 250;
|
|
792
|
-
if (isTapPointer && isTapMovement && isTapTouchTime) {
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
if (hasPanX && hasPanY) {
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
|
|
800
|
-
return this.preventSrc(srcEvent);
|
|
801
|
-
}
|
|
802
|
-
},
|
|
803
|
-
/**
|
|
804
|
-
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
|
|
805
|
-
* @param {Object} srcEvent
|
|
806
|
-
*/
|
|
807
|
-
preventSrc: function(srcEvent) {
|
|
808
|
-
this.manager.session.prevented = true;
|
|
809
|
-
srcEvent.preventDefault();
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
function cleanTouchActions(actions) {
|
|
813
|
-
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
|
814
|
-
return TOUCH_ACTION_NONE;
|
|
815
|
-
}
|
|
816
|
-
var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
|
|
817
|
-
var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
|
|
818
|
-
if (hasPanX && hasPanY) {
|
|
819
|
-
return TOUCH_ACTION_NONE;
|
|
820
|
-
}
|
|
821
|
-
if (hasPanX || hasPanY) {
|
|
822
|
-
return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
|
823
|
-
}
|
|
824
|
-
if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
|
|
825
|
-
return TOUCH_ACTION_MANIPULATION;
|
|
826
|
-
}
|
|
827
|
-
return TOUCH_ACTION_AUTO;
|
|
828
|
-
}
|
|
829
|
-
function getTouchActionProps() {
|
|
830
|
-
if (!NATIVE_TOUCH_ACTION) {
|
|
831
|
-
return false;
|
|
832
|
-
}
|
|
833
|
-
var touchMap = {};
|
|
834
|
-
var cssSupports = window2.CSS && window2.CSS.supports;
|
|
835
|
-
["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function(val) {
|
|
836
|
-
touchMap[val] = cssSupports ? window2.CSS.supports("touch-action", val) : true;
|
|
837
|
-
});
|
|
838
|
-
return touchMap;
|
|
839
|
-
}
|
|
840
|
-
var STATE_POSSIBLE = 1;
|
|
841
|
-
var STATE_BEGAN = 2;
|
|
842
|
-
var STATE_CHANGED = 4;
|
|
843
|
-
var STATE_ENDED = 8;
|
|
844
|
-
var STATE_RECOGNIZED = STATE_ENDED;
|
|
845
|
-
var STATE_CANCELLED = 16;
|
|
846
|
-
var STATE_FAILED = 32;
|
|
847
|
-
function Recognizer(options) {
|
|
848
|
-
this.options = assign({}, this.defaults, options || {});
|
|
849
|
-
this.id = uniqueId();
|
|
850
|
-
this.manager = null;
|
|
851
|
-
this.options.enable = ifUndefined(this.options.enable, true);
|
|
852
|
-
this.state = STATE_POSSIBLE;
|
|
853
|
-
this.simultaneous = {};
|
|
854
|
-
this.requireFail = [];
|
|
855
|
-
}
|
|
856
|
-
Recognizer.prototype = {
|
|
857
|
-
/**
|
|
858
|
-
* @virtual
|
|
859
|
-
* @type {Object}
|
|
860
|
-
*/
|
|
861
|
-
defaults: {},
|
|
862
|
-
/**
|
|
863
|
-
* set options
|
|
864
|
-
* @param {Object} options
|
|
865
|
-
* @return {Recognizer}
|
|
866
|
-
*/
|
|
867
|
-
set: function(options) {
|
|
868
|
-
assign(this.options, options);
|
|
869
|
-
this.manager && this.manager.touchAction.update();
|
|
870
|
-
return this;
|
|
871
|
-
},
|
|
872
|
-
/**
|
|
873
|
-
* recognize simultaneous with an other recognizer.
|
|
874
|
-
* @param {Recognizer} otherRecognizer
|
|
875
|
-
* @returns {Recognizer} this
|
|
876
|
-
*/
|
|
877
|
-
recognizeWith: function(otherRecognizer) {
|
|
878
|
-
if (invokeArrayArg(otherRecognizer, "recognizeWith", this)) {
|
|
879
|
-
return this;
|
|
880
|
-
}
|
|
881
|
-
var simultaneous = this.simultaneous;
|
|
882
|
-
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
883
|
-
if (!simultaneous[otherRecognizer.id]) {
|
|
884
|
-
simultaneous[otherRecognizer.id] = otherRecognizer;
|
|
885
|
-
otherRecognizer.recognizeWith(this);
|
|
886
|
-
}
|
|
887
|
-
return this;
|
|
888
|
-
},
|
|
889
|
-
/**
|
|
890
|
-
* drop the simultaneous link. it doesnt remove the link on the other recognizer.
|
|
891
|
-
* @param {Recognizer} otherRecognizer
|
|
892
|
-
* @returns {Recognizer} this
|
|
893
|
-
*/
|
|
894
|
-
dropRecognizeWith: function(otherRecognizer) {
|
|
895
|
-
if (invokeArrayArg(otherRecognizer, "dropRecognizeWith", this)) {
|
|
896
|
-
return this;
|
|
897
|
-
}
|
|
898
|
-
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
899
|
-
delete this.simultaneous[otherRecognizer.id];
|
|
900
|
-
return this;
|
|
901
|
-
},
|
|
902
|
-
/**
|
|
903
|
-
* recognizer can only run when an other is failing
|
|
904
|
-
* @param {Recognizer} otherRecognizer
|
|
905
|
-
* @returns {Recognizer} this
|
|
906
|
-
*/
|
|
907
|
-
requireFailure: function(otherRecognizer) {
|
|
908
|
-
if (invokeArrayArg(otherRecognizer, "requireFailure", this)) {
|
|
909
|
-
return this;
|
|
910
|
-
}
|
|
911
|
-
var requireFail = this.requireFail;
|
|
912
|
-
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
913
|
-
if (inArray(requireFail, otherRecognizer) === -1) {
|
|
914
|
-
requireFail.push(otherRecognizer);
|
|
915
|
-
otherRecognizer.requireFailure(this);
|
|
916
|
-
}
|
|
917
|
-
return this;
|
|
918
|
-
},
|
|
919
|
-
/**
|
|
920
|
-
* drop the requireFailure link. it does not remove the link on the other recognizer.
|
|
921
|
-
* @param {Recognizer} otherRecognizer
|
|
922
|
-
* @returns {Recognizer} this
|
|
923
|
-
*/
|
|
924
|
-
dropRequireFailure: function(otherRecognizer) {
|
|
925
|
-
if (invokeArrayArg(otherRecognizer, "dropRequireFailure", this)) {
|
|
926
|
-
return this;
|
|
927
|
-
}
|
|
928
|
-
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
929
|
-
var index = inArray(this.requireFail, otherRecognizer);
|
|
930
|
-
if (index > -1) {
|
|
931
|
-
this.requireFail.splice(index, 1);
|
|
932
|
-
}
|
|
933
|
-
return this;
|
|
934
|
-
},
|
|
935
|
-
/**
|
|
936
|
-
* has require failures boolean
|
|
937
|
-
* @returns {boolean}
|
|
938
|
-
*/
|
|
939
|
-
hasRequireFailures: function() {
|
|
940
|
-
return this.requireFail.length > 0;
|
|
941
|
-
},
|
|
942
|
-
/**
|
|
943
|
-
* if the recognizer can recognize simultaneous with an other recognizer
|
|
944
|
-
* @param {Recognizer} otherRecognizer
|
|
945
|
-
* @returns {Boolean}
|
|
946
|
-
*/
|
|
947
|
-
canRecognizeWith: function(otherRecognizer) {
|
|
948
|
-
return !!this.simultaneous[otherRecognizer.id];
|
|
949
|
-
},
|
|
950
|
-
/**
|
|
951
|
-
* You should use `tryEmit` instead of `emit` directly to check
|
|
952
|
-
* that all the needed recognizers has failed before emitting.
|
|
953
|
-
* @param {Object} input
|
|
954
|
-
*/
|
|
955
|
-
emit: function(input) {
|
|
956
|
-
var self2 = this;
|
|
957
|
-
var state = this.state;
|
|
958
|
-
function emit(event) {
|
|
959
|
-
self2.manager.emit(event, input);
|
|
960
|
-
}
|
|
961
|
-
if (state < STATE_ENDED) {
|
|
962
|
-
emit(self2.options.event + stateStr(state));
|
|
963
|
-
}
|
|
964
|
-
emit(self2.options.event);
|
|
965
|
-
if (input.additionalEvent) {
|
|
966
|
-
emit(input.additionalEvent);
|
|
967
|
-
}
|
|
968
|
-
if (state >= STATE_ENDED) {
|
|
969
|
-
emit(self2.options.event + stateStr(state));
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
/**
|
|
973
|
-
* Check that all the require failure recognizers has failed,
|
|
974
|
-
* if true, it emits a gesture event,
|
|
975
|
-
* otherwise, setup the state to FAILED.
|
|
976
|
-
* @param {Object} input
|
|
977
|
-
*/
|
|
978
|
-
tryEmit: function(input) {
|
|
979
|
-
if (this.canEmit()) {
|
|
980
|
-
return this.emit(input);
|
|
981
|
-
}
|
|
982
|
-
this.state = STATE_FAILED;
|
|
983
|
-
},
|
|
984
|
-
/**
|
|
985
|
-
* can we emit?
|
|
986
|
-
* @returns {boolean}
|
|
987
|
-
*/
|
|
988
|
-
canEmit: function() {
|
|
989
|
-
var i = 0;
|
|
990
|
-
while (i < this.requireFail.length) {
|
|
991
|
-
if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
|
992
|
-
return false;
|
|
993
|
-
}
|
|
994
|
-
i++;
|
|
995
|
-
}
|
|
996
|
-
return true;
|
|
997
|
-
},
|
|
998
|
-
/**
|
|
999
|
-
* update the recognizer
|
|
1000
|
-
* @param {Object} inputData
|
|
1001
|
-
*/
|
|
1002
|
-
recognize: function(inputData) {
|
|
1003
|
-
var inputDataClone = assign({}, inputData);
|
|
1004
|
-
if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
|
1005
|
-
this.reset();
|
|
1006
|
-
this.state = STATE_FAILED;
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
|
1010
|
-
this.state = STATE_POSSIBLE;
|
|
1011
|
-
}
|
|
1012
|
-
this.state = this.process(inputDataClone);
|
|
1013
|
-
if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
|
1014
|
-
this.tryEmit(inputDataClone);
|
|
1015
|
-
}
|
|
1016
|
-
},
|
|
1017
|
-
/**
|
|
1018
|
-
* return the state of the recognizer
|
|
1019
|
-
* the actual recognizing happens in this method
|
|
1020
|
-
* @virtual
|
|
1021
|
-
* @param {Object} inputData
|
|
1022
|
-
* @returns {Const} STATE
|
|
1023
|
-
*/
|
|
1024
|
-
process: function(inputData) {
|
|
1025
|
-
},
|
|
1026
|
-
// jshint ignore:line
|
|
1027
|
-
/**
|
|
1028
|
-
* return the preferred touch-action
|
|
1029
|
-
* @virtual
|
|
1030
|
-
* @returns {Array}
|
|
1031
|
-
*/
|
|
1032
|
-
getTouchAction: function() {
|
|
1033
|
-
},
|
|
1034
|
-
/**
|
|
1035
|
-
* called when the gesture isn't allowed to recognize
|
|
1036
|
-
* like when another is being recognized or it is disabled
|
|
1037
|
-
* @virtual
|
|
1038
|
-
*/
|
|
1039
|
-
reset: function() {
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
function stateStr(state) {
|
|
1043
|
-
if (state & STATE_CANCELLED) {
|
|
1044
|
-
return "cancel";
|
|
1045
|
-
} else if (state & STATE_ENDED) {
|
|
1046
|
-
return "end";
|
|
1047
|
-
} else if (state & STATE_CHANGED) {
|
|
1048
|
-
return "move";
|
|
1049
|
-
} else if (state & STATE_BEGAN) {
|
|
1050
|
-
return "start";
|
|
1051
|
-
}
|
|
1052
|
-
return "";
|
|
1053
|
-
}
|
|
1054
|
-
function directionStr(direction) {
|
|
1055
|
-
if (direction == DIRECTION_DOWN) {
|
|
1056
|
-
return "down";
|
|
1057
|
-
} else if (direction == DIRECTION_UP) {
|
|
1058
|
-
return "up";
|
|
1059
|
-
} else if (direction == DIRECTION_LEFT) {
|
|
1060
|
-
return "left";
|
|
1061
|
-
} else if (direction == DIRECTION_RIGHT) {
|
|
1062
|
-
return "right";
|
|
1063
|
-
}
|
|
1064
|
-
return "";
|
|
1065
|
-
}
|
|
1066
|
-
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
|
1067
|
-
var manager = recognizer.manager;
|
|
1068
|
-
if (manager) {
|
|
1069
|
-
return manager.get(otherRecognizer);
|
|
1070
|
-
}
|
|
1071
|
-
return otherRecognizer;
|
|
1072
|
-
}
|
|
1073
|
-
function AttrRecognizer() {
|
|
1074
|
-
Recognizer.apply(this, arguments);
|
|
1075
|
-
}
|
|
1076
|
-
inherit(AttrRecognizer, Recognizer, {
|
|
1077
|
-
/**
|
|
1078
|
-
* @namespace
|
|
1079
|
-
* @memberof AttrRecognizer
|
|
1080
|
-
*/
|
|
1081
|
-
defaults: {
|
|
1082
|
-
/**
|
|
1083
|
-
* @type {Number}
|
|
1084
|
-
* @default 1
|
|
1085
|
-
*/
|
|
1086
|
-
pointers: 1
|
|
1087
|
-
},
|
|
1088
|
-
/**
|
|
1089
|
-
* Used to check if it the recognizer receives valid input, like input.distance > 10.
|
|
1090
|
-
* @memberof AttrRecognizer
|
|
1091
|
-
* @param {Object} input
|
|
1092
|
-
* @returns {Boolean} recognized
|
|
1093
|
-
*/
|
|
1094
|
-
attrTest: function(input) {
|
|
1095
|
-
var optionPointers = this.options.pointers;
|
|
1096
|
-
return optionPointers === 0 || input.pointers.length === optionPointers;
|
|
1097
|
-
},
|
|
1098
|
-
/**
|
|
1099
|
-
* Process the input and return the state for the recognizer
|
|
1100
|
-
* @memberof AttrRecognizer
|
|
1101
|
-
* @param {Object} input
|
|
1102
|
-
* @returns {*} State
|
|
1103
|
-
*/
|
|
1104
|
-
process: function(input) {
|
|
1105
|
-
var state = this.state;
|
|
1106
|
-
var eventType = input.eventType;
|
|
1107
|
-
var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
|
1108
|
-
var isValid = this.attrTest(input);
|
|
1109
|
-
if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
|
1110
|
-
return state | STATE_CANCELLED;
|
|
1111
|
-
} else if (isRecognized || isValid) {
|
|
1112
|
-
if (eventType & INPUT_END) {
|
|
1113
|
-
return state | STATE_ENDED;
|
|
1114
|
-
} else if (!(state & STATE_BEGAN)) {
|
|
1115
|
-
return STATE_BEGAN;
|
|
1116
|
-
}
|
|
1117
|
-
return state | STATE_CHANGED;
|
|
1118
|
-
}
|
|
1119
|
-
return STATE_FAILED;
|
|
1120
|
-
}
|
|
1121
|
-
});
|
|
1122
|
-
function PanRecognizer() {
|
|
1123
|
-
AttrRecognizer.apply(this, arguments);
|
|
1124
|
-
this.pX = null;
|
|
1125
|
-
this.pY = null;
|
|
1126
|
-
}
|
|
1127
|
-
inherit(PanRecognizer, AttrRecognizer, {
|
|
1128
|
-
/**
|
|
1129
|
-
* @namespace
|
|
1130
|
-
* @memberof PanRecognizer
|
|
1131
|
-
*/
|
|
1132
|
-
defaults: {
|
|
1133
|
-
event: "pan",
|
|
1134
|
-
threshold: 10,
|
|
1135
|
-
pointers: 1,
|
|
1136
|
-
direction: DIRECTION_ALL
|
|
1137
|
-
},
|
|
1138
|
-
getTouchAction: function() {
|
|
1139
|
-
var direction = this.options.direction;
|
|
1140
|
-
var actions = [];
|
|
1141
|
-
if (direction & DIRECTION_HORIZONTAL) {
|
|
1142
|
-
actions.push(TOUCH_ACTION_PAN_Y);
|
|
1143
|
-
}
|
|
1144
|
-
if (direction & DIRECTION_VERTICAL) {
|
|
1145
|
-
actions.push(TOUCH_ACTION_PAN_X);
|
|
1146
|
-
}
|
|
1147
|
-
return actions;
|
|
1148
|
-
},
|
|
1149
|
-
directionTest: function(input) {
|
|
1150
|
-
var options = this.options;
|
|
1151
|
-
var hasMoved = true;
|
|
1152
|
-
var distance = input.distance;
|
|
1153
|
-
var direction = input.direction;
|
|
1154
|
-
var x = input.deltaX;
|
|
1155
|
-
var y = input.deltaY;
|
|
1156
|
-
if (!(direction & options.direction)) {
|
|
1157
|
-
if (options.direction & DIRECTION_HORIZONTAL) {
|
|
1158
|
-
direction = x === 0 ? DIRECTION_NONE : x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
1159
|
-
hasMoved = x != this.pX;
|
|
1160
|
-
distance = Math.abs(input.deltaX);
|
|
1161
|
-
} else {
|
|
1162
|
-
direction = y === 0 ? DIRECTION_NONE : y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
1163
|
-
hasMoved = y != this.pY;
|
|
1164
|
-
distance = Math.abs(input.deltaY);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
input.direction = direction;
|
|
1168
|
-
return hasMoved && distance > options.threshold && direction & options.direction;
|
|
1169
|
-
},
|
|
1170
|
-
attrTest: function(input) {
|
|
1171
|
-
return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
|
1172
|
-
},
|
|
1173
|
-
emit: function(input) {
|
|
1174
|
-
this.pX = input.deltaX;
|
|
1175
|
-
this.pY = input.deltaY;
|
|
1176
|
-
var direction = directionStr(input.direction);
|
|
1177
|
-
if (direction) {
|
|
1178
|
-
input.additionalEvent = this.options.event + direction;
|
|
1179
|
-
}
|
|
1180
|
-
this._super.emit.call(this, input);
|
|
1181
|
-
}
|
|
1182
|
-
});
|
|
1183
|
-
function PinchRecognizer() {
|
|
1184
|
-
AttrRecognizer.apply(this, arguments);
|
|
1185
|
-
}
|
|
1186
|
-
inherit(PinchRecognizer, AttrRecognizer, {
|
|
1187
|
-
/**
|
|
1188
|
-
* @namespace
|
|
1189
|
-
* @memberof PinchRecognizer
|
|
1190
|
-
*/
|
|
1191
|
-
defaults: {
|
|
1192
|
-
event: "pinch",
|
|
1193
|
-
threshold: 0,
|
|
1194
|
-
pointers: 2
|
|
1195
|
-
},
|
|
1196
|
-
getTouchAction: function() {
|
|
1197
|
-
return [TOUCH_ACTION_NONE];
|
|
1198
|
-
},
|
|
1199
|
-
attrTest: function(input) {
|
|
1200
|
-
return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
|
1201
|
-
},
|
|
1202
|
-
emit: function(input) {
|
|
1203
|
-
if (input.scale !== 1) {
|
|
1204
|
-
var inOut = input.scale < 1 ? "in" : "out";
|
|
1205
|
-
input.additionalEvent = this.options.event + inOut;
|
|
1206
|
-
}
|
|
1207
|
-
this._super.emit.call(this, input);
|
|
1208
|
-
}
|
|
1209
|
-
});
|
|
1210
|
-
function PressRecognizer() {
|
|
1211
|
-
Recognizer.apply(this, arguments);
|
|
1212
|
-
this._timer = null;
|
|
1213
|
-
this._input = null;
|
|
1214
|
-
}
|
|
1215
|
-
inherit(PressRecognizer, Recognizer, {
|
|
1216
|
-
/**
|
|
1217
|
-
* @namespace
|
|
1218
|
-
* @memberof PressRecognizer
|
|
1219
|
-
*/
|
|
1220
|
-
defaults: {
|
|
1221
|
-
event: "press",
|
|
1222
|
-
pointers: 1,
|
|
1223
|
-
time: 251,
|
|
1224
|
-
// minimal time of the pointer to be pressed
|
|
1225
|
-
threshold: 9
|
|
1226
|
-
// a minimal movement is ok, but keep it low
|
|
1227
|
-
},
|
|
1228
|
-
getTouchAction: function() {
|
|
1229
|
-
return [TOUCH_ACTION_AUTO];
|
|
1230
|
-
},
|
|
1231
|
-
process: function(input) {
|
|
1232
|
-
var options = this.options;
|
|
1233
|
-
var validPointers = input.pointers.length === options.pointers;
|
|
1234
|
-
var validMovement = input.distance < options.threshold;
|
|
1235
|
-
var validTime = input.deltaTime > options.time;
|
|
1236
|
-
this._input = input;
|
|
1237
|
-
if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
|
|
1238
|
-
this.reset();
|
|
1239
|
-
} else if (input.eventType & INPUT_START) {
|
|
1240
|
-
this.reset();
|
|
1241
|
-
this._timer = setTimeoutContext(function() {
|
|
1242
|
-
this.state = STATE_RECOGNIZED;
|
|
1243
|
-
this.tryEmit();
|
|
1244
|
-
}, options.time, this);
|
|
1245
|
-
} else if (input.eventType & INPUT_END) {
|
|
1246
|
-
return STATE_RECOGNIZED;
|
|
1247
|
-
}
|
|
1248
|
-
return STATE_FAILED;
|
|
1249
|
-
},
|
|
1250
|
-
reset: function() {
|
|
1251
|
-
clearTimeout(this._timer);
|
|
1252
|
-
},
|
|
1253
|
-
emit: function(input) {
|
|
1254
|
-
if (this.state !== STATE_RECOGNIZED) {
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
if (input && input.eventType & INPUT_END) {
|
|
1258
|
-
this.manager.emit(this.options.event + "up", input);
|
|
1259
|
-
} else {
|
|
1260
|
-
this._input.timeStamp = now();
|
|
1261
|
-
this.manager.emit(this.options.event, this._input);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
});
|
|
1265
|
-
function RotateRecognizer() {
|
|
1266
|
-
AttrRecognizer.apply(this, arguments);
|
|
1267
|
-
}
|
|
1268
|
-
inherit(RotateRecognizer, AttrRecognizer, {
|
|
1269
|
-
/**
|
|
1270
|
-
* @namespace
|
|
1271
|
-
* @memberof RotateRecognizer
|
|
1272
|
-
*/
|
|
1273
|
-
defaults: {
|
|
1274
|
-
event: "rotate",
|
|
1275
|
-
threshold: 0,
|
|
1276
|
-
pointers: 2
|
|
1277
|
-
},
|
|
1278
|
-
getTouchAction: function() {
|
|
1279
|
-
return [TOUCH_ACTION_NONE];
|
|
1280
|
-
},
|
|
1281
|
-
attrTest: function(input) {
|
|
1282
|
-
return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
|
1283
|
-
}
|
|
1284
|
-
});
|
|
1285
|
-
function SwipeRecognizer() {
|
|
1286
|
-
AttrRecognizer.apply(this, arguments);
|
|
1287
|
-
}
|
|
1288
|
-
inherit(SwipeRecognizer, AttrRecognizer, {
|
|
1289
|
-
/**
|
|
1290
|
-
* @namespace
|
|
1291
|
-
* @memberof SwipeRecognizer
|
|
1292
|
-
*/
|
|
1293
|
-
defaults: {
|
|
1294
|
-
event: "swipe",
|
|
1295
|
-
threshold: 10,
|
|
1296
|
-
velocity: 0.3,
|
|
1297
|
-
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
|
1298
|
-
pointers: 1
|
|
1299
|
-
},
|
|
1300
|
-
getTouchAction: function() {
|
|
1301
|
-
return PanRecognizer.prototype.getTouchAction.call(this);
|
|
1302
|
-
},
|
|
1303
|
-
attrTest: function(input) {
|
|
1304
|
-
var direction = this.options.direction;
|
|
1305
|
-
var velocity;
|
|
1306
|
-
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
|
1307
|
-
velocity = input.overallVelocity;
|
|
1308
|
-
} else if (direction & DIRECTION_HORIZONTAL) {
|
|
1309
|
-
velocity = input.overallVelocityX;
|
|
1310
|
-
} else if (direction & DIRECTION_VERTICAL) {
|
|
1311
|
-
velocity = input.overallVelocityY;
|
|
1312
|
-
}
|
|
1313
|
-
return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
|
1314
|
-
},
|
|
1315
|
-
emit: function(input) {
|
|
1316
|
-
var direction = directionStr(input.offsetDirection);
|
|
1317
|
-
if (direction) {
|
|
1318
|
-
this.manager.emit(this.options.event + direction, input);
|
|
1319
|
-
}
|
|
1320
|
-
this.manager.emit(this.options.event, input);
|
|
1321
|
-
}
|
|
1322
|
-
});
|
|
1323
|
-
function TapRecognizer() {
|
|
1324
|
-
Recognizer.apply(this, arguments);
|
|
1325
|
-
this.pTime = false;
|
|
1326
|
-
this.pCenter = false;
|
|
1327
|
-
this._timer = null;
|
|
1328
|
-
this._input = null;
|
|
1329
|
-
this.count = 0;
|
|
1330
|
-
}
|
|
1331
|
-
inherit(TapRecognizer, Recognizer, {
|
|
1332
|
-
/**
|
|
1333
|
-
* @namespace
|
|
1334
|
-
* @memberof PinchRecognizer
|
|
1335
|
-
*/
|
|
1336
|
-
defaults: {
|
|
1337
|
-
event: "tap",
|
|
1338
|
-
pointers: 1,
|
|
1339
|
-
taps: 1,
|
|
1340
|
-
interval: 300,
|
|
1341
|
-
// max time between the multi-tap taps
|
|
1342
|
-
time: 250,
|
|
1343
|
-
// max time of the pointer to be down (like finger on the screen)
|
|
1344
|
-
threshold: 9,
|
|
1345
|
-
// a minimal movement is ok, but keep it low
|
|
1346
|
-
posThreshold: 10
|
|
1347
|
-
// a multi-tap can be a bit off the initial position
|
|
1348
|
-
},
|
|
1349
|
-
getTouchAction: function() {
|
|
1350
|
-
return [TOUCH_ACTION_MANIPULATION];
|
|
1351
|
-
},
|
|
1352
|
-
process: function(input) {
|
|
1353
|
-
var options = this.options;
|
|
1354
|
-
var validPointers = input.pointers.length === options.pointers;
|
|
1355
|
-
var validMovement = input.distance < options.threshold;
|
|
1356
|
-
var validTouchTime = input.deltaTime < options.time;
|
|
1357
|
-
this.reset();
|
|
1358
|
-
if (input.eventType & INPUT_START && this.count === 0) {
|
|
1359
|
-
return this.failTimeout();
|
|
1360
|
-
}
|
|
1361
|
-
if (validMovement && validTouchTime && validPointers) {
|
|
1362
|
-
if (input.eventType != INPUT_END) {
|
|
1363
|
-
return this.failTimeout();
|
|
1364
|
-
}
|
|
1365
|
-
var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
|
|
1366
|
-
var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
|
1367
|
-
this.pTime = input.timeStamp;
|
|
1368
|
-
this.pCenter = input.center;
|
|
1369
|
-
if (!validMultiTap || !validInterval) {
|
|
1370
|
-
this.count = 1;
|
|
1371
|
-
} else {
|
|
1372
|
-
this.count += 1;
|
|
1373
|
-
}
|
|
1374
|
-
this._input = input;
|
|
1375
|
-
var tapCount = this.count % options.taps;
|
|
1376
|
-
if (tapCount === 0) {
|
|
1377
|
-
if (!this.hasRequireFailures()) {
|
|
1378
|
-
return STATE_RECOGNIZED;
|
|
1379
|
-
} else {
|
|
1380
|
-
this._timer = setTimeoutContext(function() {
|
|
1381
|
-
this.state = STATE_RECOGNIZED;
|
|
1382
|
-
this.tryEmit();
|
|
1383
|
-
}, options.interval, this);
|
|
1384
|
-
return STATE_BEGAN;
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
return STATE_FAILED;
|
|
1389
|
-
},
|
|
1390
|
-
failTimeout: function() {
|
|
1391
|
-
this._timer = setTimeoutContext(function() {
|
|
1392
|
-
this.state = STATE_FAILED;
|
|
1393
|
-
}, this.options.interval, this);
|
|
1394
|
-
return STATE_FAILED;
|
|
1395
|
-
},
|
|
1396
|
-
reset: function() {
|
|
1397
|
-
clearTimeout(this._timer);
|
|
1398
|
-
},
|
|
1399
|
-
emit: function() {
|
|
1400
|
-
if (this.state == STATE_RECOGNIZED) {
|
|
1401
|
-
this._input.tapCount = this.count;
|
|
1402
|
-
this.manager.emit(this.options.event, this._input);
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1406
|
-
function Hammer(element, options) {
|
|
1407
|
-
options = options || {};
|
|
1408
|
-
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
|
1409
|
-
return new Manager(element, options);
|
|
1410
|
-
}
|
|
1411
|
-
Hammer.VERSION = "2.0.7";
|
|
1412
|
-
Hammer.defaults = {
|
|
1413
|
-
/**
|
|
1414
|
-
* set if DOM events are being triggered.
|
|
1415
|
-
* But this is slower and unused by simple implementations, so disabled by default.
|
|
1416
|
-
* @type {Boolean}
|
|
1417
|
-
* @default false
|
|
1418
|
-
*/
|
|
1419
|
-
domEvents: false,
|
|
1420
|
-
/**
|
|
1421
|
-
* The value for the touchAction property/fallback.
|
|
1422
|
-
* When set to `compute` it will magically set the correct value based on the added recognizers.
|
|
1423
|
-
* @type {String}
|
|
1424
|
-
* @default compute
|
|
1425
|
-
*/
|
|
1426
|
-
touchAction: TOUCH_ACTION_COMPUTE,
|
|
1427
|
-
/**
|
|
1428
|
-
* @type {Boolean}
|
|
1429
|
-
* @default true
|
|
1430
|
-
*/
|
|
1431
|
-
enable: true,
|
|
1432
|
-
/**
|
|
1433
|
-
* EXPERIMENTAL FEATURE -- can be removed/changed
|
|
1434
|
-
* Change the parent input target element.
|
|
1435
|
-
* If Null, then it is being set the to main element.
|
|
1436
|
-
* @type {Null|EventTarget}
|
|
1437
|
-
* @default null
|
|
1438
|
-
*/
|
|
1439
|
-
inputTarget: null,
|
|
1440
|
-
/**
|
|
1441
|
-
* force an input class
|
|
1442
|
-
* @type {Null|Function}
|
|
1443
|
-
* @default null
|
|
1444
|
-
*/
|
|
1445
|
-
inputClass: null,
|
|
1446
|
-
/**
|
|
1447
|
-
* Default recognizer setup when calling `Hammer()`
|
|
1448
|
-
* When creating a new Manager these will be skipped.
|
|
1449
|
-
* @type {Array}
|
|
1450
|
-
*/
|
|
1451
|
-
preset: [
|
|
1452
|
-
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
|
|
1453
|
-
[RotateRecognizer, { enable: false }],
|
|
1454
|
-
[PinchRecognizer, { enable: false }, ["rotate"]],
|
|
1455
|
-
[SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
|
|
1456
|
-
[PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ["swipe"]],
|
|
1457
|
-
[TapRecognizer],
|
|
1458
|
-
[TapRecognizer, { event: "doubletap", taps: 2 }, ["tap"]],
|
|
1459
|
-
[PressRecognizer]
|
|
1460
|
-
],
|
|
1461
|
-
/**
|
|
1462
|
-
* Some CSS properties can be used to improve the working of Hammer.
|
|
1463
|
-
* Add them to this method and they will be set when creating a new Manager.
|
|
1464
|
-
* @namespace
|
|
1465
|
-
*/
|
|
1466
|
-
cssProps: {
|
|
1467
|
-
/**
|
|
1468
|
-
* Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
|
|
1469
|
-
* @type {String}
|
|
1470
|
-
* @default 'none'
|
|
1471
|
-
*/
|
|
1472
|
-
userSelect: "none",
|
|
1473
|
-
/**
|
|
1474
|
-
* Disable the Windows Phone grippers when pressing an element.
|
|
1475
|
-
* @type {String}
|
|
1476
|
-
* @default 'none'
|
|
1477
|
-
*/
|
|
1478
|
-
touchSelect: "none",
|
|
1479
|
-
/**
|
|
1480
|
-
* Disables the default callout shown when you touch and hold a touch target.
|
|
1481
|
-
* On iOS, when you touch and hold a touch target such as a link, Safari displays
|
|
1482
|
-
* a callout containing information about the link. This property allows you to disable that callout.
|
|
1483
|
-
* @type {String}
|
|
1484
|
-
* @default 'none'
|
|
1485
|
-
*/
|
|
1486
|
-
touchCallout: "none",
|
|
1487
|
-
/**
|
|
1488
|
-
* Specifies whether zooming is enabled. Used by IE10>
|
|
1489
|
-
* @type {String}
|
|
1490
|
-
* @default 'none'
|
|
1491
|
-
*/
|
|
1492
|
-
contentZooming: "none",
|
|
1493
|
-
/**
|
|
1494
|
-
* Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
|
|
1495
|
-
* @type {String}
|
|
1496
|
-
* @default 'none'
|
|
1497
|
-
*/
|
|
1498
|
-
userDrag: "none",
|
|
1499
|
-
/**
|
|
1500
|
-
* Overrides the highlight color shown when the user taps a link or a JavaScript
|
|
1501
|
-
* clickable element in iOS. This property obeys the alpha value, if specified.
|
|
1502
|
-
* @type {String}
|
|
1503
|
-
* @default 'rgba(0,0,0,0)'
|
|
1504
|
-
*/
|
|
1505
|
-
tapHighlightColor: "rgba(0,0,0,0)"
|
|
1506
|
-
}
|
|
1507
|
-
};
|
|
1508
|
-
var STOP = 1;
|
|
1509
|
-
var FORCED_STOP = 2;
|
|
1510
|
-
function Manager(element, options) {
|
|
1511
|
-
this.options = assign({}, Hammer.defaults, options || {});
|
|
1512
|
-
this.options.inputTarget = this.options.inputTarget || element;
|
|
1513
|
-
this.handlers = {};
|
|
1514
|
-
this.session = {};
|
|
1515
|
-
this.recognizers = [];
|
|
1516
|
-
this.oldCssProps = {};
|
|
1517
|
-
this.element = element;
|
|
1518
|
-
this.input = createInputInstance(this);
|
|
1519
|
-
this.touchAction = new TouchAction(this, this.options.touchAction);
|
|
1520
|
-
toggleCssProps(this, true);
|
|
1521
|
-
each(this.options.recognizers, function(item) {
|
|
1522
|
-
var recognizer = this.add(new item[0](item[1]));
|
|
1523
|
-
item[2] && recognizer.recognizeWith(item[2]);
|
|
1524
|
-
item[3] && recognizer.requireFailure(item[3]);
|
|
1525
|
-
}, this);
|
|
1526
|
-
}
|
|
1527
|
-
Manager.prototype = {
|
|
1528
|
-
/**
|
|
1529
|
-
* set options
|
|
1530
|
-
* @param {Object} options
|
|
1531
|
-
* @returns {Manager}
|
|
1532
|
-
*/
|
|
1533
|
-
set: function(options) {
|
|
1534
|
-
assign(this.options, options);
|
|
1535
|
-
if (options.touchAction) {
|
|
1536
|
-
this.touchAction.update();
|
|
1537
|
-
}
|
|
1538
|
-
if (options.inputTarget) {
|
|
1539
|
-
this.input.destroy();
|
|
1540
|
-
this.input.target = options.inputTarget;
|
|
1541
|
-
this.input.init();
|
|
1542
|
-
}
|
|
1543
|
-
return this;
|
|
1544
|
-
},
|
|
1545
|
-
/**
|
|
1546
|
-
* stop recognizing for this session.
|
|
1547
|
-
* This session will be discarded, when a new [input]start event is fired.
|
|
1548
|
-
* When forced, the recognizer cycle is stopped immediately.
|
|
1549
|
-
* @param {Boolean} [force]
|
|
1550
|
-
*/
|
|
1551
|
-
stop: function(force) {
|
|
1552
|
-
this.session.stopped = force ? FORCED_STOP : STOP;
|
|
1553
|
-
},
|
|
1554
|
-
/**
|
|
1555
|
-
* run the recognizers!
|
|
1556
|
-
* called by the inputHandler function on every movement of the pointers (touches)
|
|
1557
|
-
* it walks through all the recognizers and tries to detect the gesture that is being made
|
|
1558
|
-
* @param {Object} inputData
|
|
1559
|
-
*/
|
|
1560
|
-
recognize: function(inputData) {
|
|
1561
|
-
var session = this.session;
|
|
1562
|
-
if (session.stopped) {
|
|
1563
|
-
return;
|
|
1564
|
-
}
|
|
1565
|
-
this.touchAction.preventDefaults(inputData);
|
|
1566
|
-
var recognizer;
|
|
1567
|
-
var recognizers = this.recognizers;
|
|
1568
|
-
var curRecognizer = session.curRecognizer;
|
|
1569
|
-
if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
|
1570
|
-
curRecognizer = session.curRecognizer = null;
|
|
1571
|
-
}
|
|
1572
|
-
var i = 0;
|
|
1573
|
-
while (i < recognizers.length) {
|
|
1574
|
-
recognizer = recognizers[i];
|
|
1575
|
-
if (session.stopped !== FORCED_STOP && // 1
|
|
1576
|
-
(!curRecognizer || recognizer == curRecognizer || // 2
|
|
1577
|
-
recognizer.canRecognizeWith(curRecognizer))) {
|
|
1578
|
-
recognizer.recognize(inputData);
|
|
1579
|
-
} else {
|
|
1580
|
-
recognizer.reset();
|
|
1581
|
-
}
|
|
1582
|
-
if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
|
1583
|
-
curRecognizer = session.curRecognizer = recognizer;
|
|
1584
|
-
}
|
|
1585
|
-
i++;
|
|
1586
|
-
}
|
|
1587
|
-
},
|
|
1588
|
-
/**
|
|
1589
|
-
* get a recognizer by its event name.
|
|
1590
|
-
* @param {Recognizer|String} recognizer
|
|
1591
|
-
* @returns {Recognizer|Null}
|
|
1592
|
-
*/
|
|
1593
|
-
get: function(recognizer) {
|
|
1594
|
-
if (recognizer instanceof Recognizer) {
|
|
1595
|
-
return recognizer;
|
|
1596
|
-
}
|
|
1597
|
-
var recognizers = this.recognizers;
|
|
1598
|
-
for (var i = 0; i < recognizers.length; i++) {
|
|
1599
|
-
if (recognizers[i].options.event == recognizer) {
|
|
1600
|
-
return recognizers[i];
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
return null;
|
|
1604
|
-
},
|
|
1605
|
-
/**
|
|
1606
|
-
* add a recognizer to the manager
|
|
1607
|
-
* existing recognizers with the same event name will be removed
|
|
1608
|
-
* @param {Recognizer} recognizer
|
|
1609
|
-
* @returns {Recognizer|Manager}
|
|
1610
|
-
*/
|
|
1611
|
-
add: function(recognizer) {
|
|
1612
|
-
if (invokeArrayArg(recognizer, "add", this)) {
|
|
1613
|
-
return this;
|
|
1614
|
-
}
|
|
1615
|
-
var existing = this.get(recognizer.options.event);
|
|
1616
|
-
if (existing) {
|
|
1617
|
-
this.remove(existing);
|
|
1618
|
-
}
|
|
1619
|
-
this.recognizers.push(recognizer);
|
|
1620
|
-
recognizer.manager = this;
|
|
1621
|
-
this.touchAction.update();
|
|
1622
|
-
return recognizer;
|
|
1623
|
-
},
|
|
1624
|
-
/**
|
|
1625
|
-
* remove a recognizer by name or instance
|
|
1626
|
-
* @param {Recognizer|String} recognizer
|
|
1627
|
-
* @returns {Manager}
|
|
1628
|
-
*/
|
|
1629
|
-
remove: function(recognizer) {
|
|
1630
|
-
if (invokeArrayArg(recognizer, "remove", this)) {
|
|
1631
|
-
return this;
|
|
1632
|
-
}
|
|
1633
|
-
recognizer = this.get(recognizer);
|
|
1634
|
-
if (recognizer) {
|
|
1635
|
-
var recognizers = this.recognizers;
|
|
1636
|
-
var index = inArray(recognizers, recognizer);
|
|
1637
|
-
if (index !== -1) {
|
|
1638
|
-
recognizers.splice(index, 1);
|
|
1639
|
-
this.touchAction.update();
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
return this;
|
|
1643
|
-
},
|
|
1644
|
-
/**
|
|
1645
|
-
* bind event
|
|
1646
|
-
* @param {String} events
|
|
1647
|
-
* @param {Function} handler
|
|
1648
|
-
* @returns {EventEmitter} this
|
|
1649
|
-
*/
|
|
1650
|
-
on: function(events, handler) {
|
|
1651
|
-
if (events === undefined$1) {
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
if (handler === undefined$1) {
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
var handlers = this.handlers;
|
|
1658
|
-
each(splitStr(events), function(event) {
|
|
1659
|
-
handlers[event] = handlers[event] || [];
|
|
1660
|
-
handlers[event].push(handler);
|
|
1661
|
-
});
|
|
1662
|
-
return this;
|
|
1663
|
-
},
|
|
1664
|
-
/**
|
|
1665
|
-
* unbind event, leave emit blank to remove all handlers
|
|
1666
|
-
* @param {String} events
|
|
1667
|
-
* @param {Function} [handler]
|
|
1668
|
-
* @returns {EventEmitter} this
|
|
1669
|
-
*/
|
|
1670
|
-
off: function(events, handler) {
|
|
1671
|
-
if (events === undefined$1) {
|
|
1672
|
-
return;
|
|
1673
|
-
}
|
|
1674
|
-
var handlers = this.handlers;
|
|
1675
|
-
each(splitStr(events), function(event) {
|
|
1676
|
-
if (!handler) {
|
|
1677
|
-
delete handlers[event];
|
|
1678
|
-
} else {
|
|
1679
|
-
handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
|
1680
|
-
}
|
|
1681
|
-
});
|
|
1682
|
-
return this;
|
|
1683
|
-
},
|
|
1684
|
-
/**
|
|
1685
|
-
* emit event to the listeners
|
|
1686
|
-
* @param {String} event
|
|
1687
|
-
* @param {Object} data
|
|
1688
|
-
*/
|
|
1689
|
-
emit: function(event, data) {
|
|
1690
|
-
if (this.options.domEvents) {
|
|
1691
|
-
triggerDomEvent(event, data);
|
|
1692
|
-
}
|
|
1693
|
-
var handlers = this.handlers[event] && this.handlers[event].slice();
|
|
1694
|
-
if (!handlers || !handlers.length) {
|
|
1695
|
-
return;
|
|
1696
|
-
}
|
|
1697
|
-
data.type = event;
|
|
1698
|
-
data.preventDefault = function() {
|
|
1699
|
-
data.srcEvent.preventDefault();
|
|
1700
|
-
};
|
|
1701
|
-
var i = 0;
|
|
1702
|
-
while (i < handlers.length) {
|
|
1703
|
-
handlers[i](data);
|
|
1704
|
-
i++;
|
|
1705
|
-
}
|
|
1706
|
-
},
|
|
1707
|
-
/**
|
|
1708
|
-
* destroy the manager and unbinds all events
|
|
1709
|
-
* it doesn't unbind dom events, that is the user own responsibility
|
|
1710
|
-
*/
|
|
1711
|
-
destroy: function() {
|
|
1712
|
-
this.element && toggleCssProps(this, false);
|
|
1713
|
-
this.handlers = {};
|
|
1714
|
-
this.session = {};
|
|
1715
|
-
this.input.destroy();
|
|
1716
|
-
this.element = null;
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1719
|
-
function toggleCssProps(manager, add) {
|
|
1720
|
-
var element = manager.element;
|
|
1721
|
-
if (!element.style) {
|
|
1722
|
-
return;
|
|
1723
|
-
}
|
|
1724
|
-
var prop;
|
|
1725
|
-
each(manager.options.cssProps, function(value, name) {
|
|
1726
|
-
prop = prefixed(element.style, name);
|
|
1727
|
-
if (add) {
|
|
1728
|
-
manager.oldCssProps[prop] = element.style[prop];
|
|
1729
|
-
element.style[prop] = value;
|
|
1730
|
-
} else {
|
|
1731
|
-
element.style[prop] = manager.oldCssProps[prop] || "";
|
|
1732
|
-
}
|
|
1733
|
-
});
|
|
1734
|
-
if (!add) {
|
|
1735
|
-
manager.oldCssProps = {};
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
function triggerDomEvent(event, data) {
|
|
1739
|
-
var gestureEvent = document2.createEvent("Event");
|
|
1740
|
-
gestureEvent.initEvent(event, true, true);
|
|
1741
|
-
gestureEvent.gesture = data;
|
|
1742
|
-
data.target.dispatchEvent(gestureEvent);
|
|
1743
|
-
}
|
|
1744
|
-
assign(Hammer, {
|
|
1745
|
-
INPUT_START,
|
|
1746
|
-
INPUT_MOVE,
|
|
1747
|
-
INPUT_END,
|
|
1748
|
-
INPUT_CANCEL,
|
|
1749
|
-
STATE_POSSIBLE,
|
|
1750
|
-
STATE_BEGAN,
|
|
1751
|
-
STATE_CHANGED,
|
|
1752
|
-
STATE_ENDED,
|
|
1753
|
-
STATE_RECOGNIZED,
|
|
1754
|
-
STATE_CANCELLED,
|
|
1755
|
-
STATE_FAILED,
|
|
1756
|
-
DIRECTION_NONE,
|
|
1757
|
-
DIRECTION_LEFT,
|
|
1758
|
-
DIRECTION_RIGHT,
|
|
1759
|
-
DIRECTION_UP,
|
|
1760
|
-
DIRECTION_DOWN,
|
|
1761
|
-
DIRECTION_HORIZONTAL,
|
|
1762
|
-
DIRECTION_VERTICAL,
|
|
1763
|
-
DIRECTION_ALL,
|
|
1764
|
-
Manager,
|
|
1765
|
-
Input,
|
|
1766
|
-
TouchAction,
|
|
1767
|
-
TouchInput,
|
|
1768
|
-
MouseInput,
|
|
1769
|
-
PointerEventInput,
|
|
1770
|
-
TouchMouseInput,
|
|
1771
|
-
SingleTouchInput,
|
|
1772
|
-
Recognizer,
|
|
1773
|
-
AttrRecognizer,
|
|
1774
|
-
Tap: TapRecognizer,
|
|
1775
|
-
Pan: PanRecognizer,
|
|
1776
|
-
Swipe: SwipeRecognizer,
|
|
1777
|
-
Pinch: PinchRecognizer,
|
|
1778
|
-
Rotate: RotateRecognizer,
|
|
1779
|
-
Press: PressRecognizer,
|
|
1780
|
-
on: addEventListeners,
|
|
1781
|
-
off: removeEventListeners,
|
|
1782
|
-
each,
|
|
1783
|
-
merge,
|
|
1784
|
-
extend,
|
|
1785
|
-
assign,
|
|
1786
|
-
inherit,
|
|
1787
|
-
bindFn,
|
|
1788
|
-
prefixed
|
|
1789
|
-
});
|
|
1790
|
-
var freeGlobal = typeof window2 !== "undefined" ? window2 : typeof self !== "undefined" ? self : {};
|
|
1791
|
-
freeGlobal.Hammer = Hammer;
|
|
1792
|
-
if (module.exports) {
|
|
1793
|
-
module.exports = Hammer;
|
|
1794
|
-
} else {
|
|
1795
|
-
window2[exportName] = Hammer;
|
|
1796
|
-
}
|
|
1797
|
-
})(window, document, "Hammer");
|
|
1798
|
-
})(hammer$2);
|
|
1799
|
-
return hammer$2.exports;
|
|
1800
|
-
}
|
|
1801
|
-
var hammerExports = requireHammer();
|
|
1802
|
-
const hammer = /* @__PURE__ */ getDefaultExportFromCjs(hammerExports);
|
|
1803
|
-
const hammer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1804
|
-
__proto__: null,
|
|
1805
|
-
default: hammer
|
|
1806
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1807
|
-
export {
|
|
1808
|
-
hammer$1 as h
|
|
1809
|
-
};
|
|
1810
|
-
//# sourceMappingURL=hammer-e1aXHboh.js.map
|