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