chunk-NAPKCKEX.js 62 KB

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