@zanichelli/albe-web-components 21.0.0-RC1 → 21.0.0-RC3

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 (132) hide show
  1. package/dist/cjs/dialog-polyfill.esm-D8Polhcd.js +863 -0
  2. package/dist/cjs/dialog-polyfill.esm-D8Polhcd.js.map +1 -0
  3. package/dist/cjs/hammer-CJF2Ixtg.js +2665 -0
  4. package/dist/cjs/hammer-CJF2Ixtg.js.map +1 -0
  5. package/dist/cjs/index-CZz7uP-M.js +6 -6
  6. package/dist/cjs/z-dragdrop-area_2.cjs.entry.js +8 -862
  7. package/dist/cjs/z-dragdrop-area_2.cjs.entry.js.map +1 -1
  8. package/dist/cjs/z-toast-notification.cjs.entry.js +7 -2657
  9. package/dist/cjs/z-toast-notification.cjs.entry.js.map +1 -1
  10. package/dist/collection/components/z-modal/index.js +8 -6
  11. package/dist/collection/components/z-modal/index.js.map +1 -1
  12. package/dist/collection/components/z-toast-notification/index.js +7 -5
  13. package/dist/collection/components/z-toast-notification/index.js.map +1 -1
  14. package/dist/components/p-BRkq64wS.js +2 -0
  15. package/dist/components/p-BRkq64wS.js.map +1 -0
  16. package/dist/components/p-Bt1M0wUw.js +7 -0
  17. package/dist/components/p-Bt1M0wUw.js.map +1 -0
  18. package/dist/components/p-BvCsF6Eq.js +2 -0
  19. package/dist/components/p-BvCsF6Eq.js.map +1 -0
  20. package/dist/components/z-file-upload.js +1 -1
  21. package/dist/components/z-modal.js +1 -1
  22. package/dist/components/z-toast-notification.js +2 -7
  23. package/dist/components/z-toast-notification.js.map +1 -1
  24. package/dist/esm/dialog-polyfill.esm-BRkq64wS.js +861 -0
  25. package/dist/esm/dialog-polyfill.esm-BRkq64wS.js.map +1 -0
  26. package/dist/esm/hammer-C3JqVNyx.js +2663 -0
  27. package/dist/esm/hammer-C3JqVNyx.js.map +1 -0
  28. package/dist/esm/index-BcDWN4F1.js +6 -6
  29. package/dist/esm/z-dragdrop-area_2.entry.js +8 -862
  30. package/dist/esm/z-dragdrop-area_2.entry.js.map +1 -1
  31. package/dist/esm/z-toast-notification.entry.js +7 -2657
  32. package/dist/esm/z-toast-notification.entry.js.map +1 -1
  33. package/dist/types/components/z-modal/index.d.ts +1 -1
  34. package/dist/web-components-library/p-67051e01.entry.js +3 -0
  35. package/dist/web-components-library/p-67051e01.entry.js.map +1 -0
  36. package/dist/web-components-library/p-BRkq64wS.js +2 -0
  37. package/dist/web-components-library/p-BRkq64wS.js.map +1 -0
  38. package/dist/web-components-library/p-Bt1M0wUw.js +7 -0
  39. package/dist/web-components-library/p-Bt1M0wUw.js.map +1 -0
  40. package/dist/web-components-library/p-c3f69ac9.entry.js +2 -0
  41. package/dist/web-components-library/p-c3f69ac9.entry.js.map +1 -0
  42. package/dist/web-components-library/web-components-library.esm.js +1 -1
  43. package/package.json +3 -3
  44. package/react/components.js +64 -132
  45. package/react/index.d.ts +1 -1
  46. package/react/index.js +1 -17
  47. package/react/package.json +3 -0
  48. package/react/z-accordion.js +7 -13
  49. package/react/z-anchor-navigation.js +7 -13
  50. package/react/z-app-header.js +7 -13
  51. package/react/z-aria-alert.js +7 -13
  52. package/react/z-avatar.js +7 -13
  53. package/react/z-book-card-app.js +7 -13
  54. package/react/z-book-card.js +7 -13
  55. package/react/z-book-cover.js +7 -13
  56. package/react/z-breadcrumb.js +7 -13
  57. package/react/z-button-sort.js +7 -13
  58. package/react/z-button.js +7 -13
  59. package/react/z-card.js +7 -13
  60. package/react/z-carousel.js +7 -13
  61. package/react/z-chip.js +7 -13
  62. package/react/z-color-picker.js +7 -13
  63. package/react/z-combobox.js +7 -13
  64. package/react/z-cover-hero.js +7 -13
  65. package/react/z-date-picker.js +7 -13
  66. package/react/z-divider.js +7 -13
  67. package/react/z-dragdrop-area.js +7 -13
  68. package/react/z-file-upload.js +7 -13
  69. package/react/z-file.js +7 -13
  70. package/react/z-ghost-loading.js +7 -13
  71. package/react/z-icon.js +7 -13
  72. package/react/z-info-box.js +7 -13
  73. package/react/z-info-reveal.js +7 -13
  74. package/react/z-input-message.js +7 -13
  75. package/react/z-input-range.js +7 -13
  76. package/react/z-input.js +7 -13
  77. package/react/z-list-element.js +7 -13
  78. package/react/z-list-group.js +7 -13
  79. package/react/z-list.js +7 -13
  80. package/react/z-logo.js +7 -13
  81. package/react/z-menu-section.js +7 -13
  82. package/react/z-menu.js +7 -13
  83. package/react/z-modal.js +7 -13
  84. package/react/z-navigation-tabs.js +7 -13
  85. package/react/z-notification.js +7 -13
  86. package/react/z-offcanvas.js +7 -13
  87. package/react/z-pagination.js +7 -13
  88. package/react/z-popover.js +7 -13
  89. package/react/z-range-picker.js +7 -13
  90. package/react/z-result-card.js +7 -13
  91. package/react/z-searchbar.js +7 -13
  92. package/react/z-select.js +7 -13
  93. package/react/z-skip-to-content.js +7 -13
  94. package/react/z-stepper-item.js +7 -13
  95. package/react/z-stepper.js +7 -13
  96. package/react/z-table.js +7 -13
  97. package/react/z-tag.js +7 -13
  98. package/react/z-tbody.js +7 -13
  99. package/react/z-td.js +7 -13
  100. package/react/z-tfoot.js +7 -13
  101. package/react/z-th.js +7 -13
  102. package/react/z-thead.js +7 -13
  103. package/react/z-toast-notification-list.js +7 -13
  104. package/react/z-toast-notification.js +7 -13
  105. package/react/z-toggle-switch.js +7 -13
  106. package/react/z-tool.js +7 -13
  107. package/react/z-toolbar.js +7 -13
  108. package/react/z-tooltip.js +7 -13
  109. package/react/z-tr.js +7 -13
  110. package/react/z-tree-list.js +7 -13
  111. package/react/z-visually-hidden.js +7 -13
  112. package/www/build/{p-de6e8c2b.js → p-3ddbf8a7.js} +1 -1
  113. package/www/build/p-67051e01.entry.js +3 -0
  114. package/www/build/p-67051e01.entry.js.map +1 -0
  115. package/www/build/p-BRkq64wS.js +2 -0
  116. package/www/build/p-BRkq64wS.js.map +1 -0
  117. package/www/build/p-Bt1M0wUw.js +7 -0
  118. package/www/build/p-Bt1M0wUw.js.map +1 -0
  119. package/www/build/p-c3f69ac9.entry.js +2 -0
  120. package/www/build/p-c3f69ac9.entry.js.map +1 -0
  121. package/www/build/web-components-library.esm.js +1 -1
  122. package/www/index.html +1 -1
  123. package/dist/components/p-BbZelagf.js +0 -2
  124. package/dist/components/p-BbZelagf.js.map +0 -1
  125. package/dist/web-components-library/p-baa35a6e.entry.js +0 -2
  126. package/dist/web-components-library/p-baa35a6e.entry.js.map +0 -1
  127. package/dist/web-components-library/p-ea96790b.entry.js +0 -8
  128. package/dist/web-components-library/p-ea96790b.entry.js.map +0 -1
  129. package/www/build/p-baa35a6e.entry.js +0 -2
  130. package/www/build/p-baa35a6e.entry.js.map +0 -1
  131. package/www/build/p-ea96790b.entry.js +0 -8
  132. package/www/build/p-ea96790b.entry.js.map +0 -1
@@ -2,7 +2,6 @@
2
2
 
3
3
  var index = require('./index-CZz7uP-M.js');
4
4
  var index$1 = require('./index-DppFfqsn.js');
5
- var _commonjsHelpers = require('./_commonjsHelpers-CFO10eej.js');
6
5
 
7
6
  /*! @license DOMPurify 3.4.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.0/LICENSE */
8
7
 
@@ -1400,2658 +1399,6 @@ function createDOMPurify() {
1400
1399
  }
1401
1400
  var purify = createDOMPurify();
1402
1401
 
1403
- var hammer = {exports: {}};
1404
-
1405
- /*! Hammer.JS - v2.0.7 - 2016-04-22
1406
- * http://hammerjs.github.io/
1407
- *
1408
- * Copyright (c) 2016 Jorik Tangelder;
1409
- * Licensed under the MIT license */
1410
-
1411
- var hasRequiredHammer;
1412
-
1413
- function requireHammer () {
1414
- if (hasRequiredHammer) return hammer.exports;
1415
- hasRequiredHammer = 1;
1416
- (function (module) {
1417
- (function(window, document, exportName, undefined$1) {
1418
-
1419
- var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
1420
- var TEST_ELEMENT = document.createElement('div');
1421
-
1422
- var TYPE_FUNCTION = 'function';
1423
-
1424
- var round = Math.round;
1425
- var abs = Math.abs;
1426
- var now = Date.now;
1427
-
1428
- /**
1429
- * set a timeout with a given scope
1430
- * @param {Function} fn
1431
- * @param {Number} timeout
1432
- * @param {Object} context
1433
- * @returns {number}
1434
- */
1435
- function setTimeoutContext(fn, timeout, context) {
1436
- return setTimeout(bindFn(fn, context), timeout);
1437
- }
1438
-
1439
- /**
1440
- * if the argument is an array, we want to execute the fn on each entry
1441
- * if it aint an array we don't want to do a thing.
1442
- * this is used by all the methods that accept a single and array argument.
1443
- * @param {*|Array} arg
1444
- * @param {String} fn
1445
- * @param {Object} [context]
1446
- * @returns {Boolean}
1447
- */
1448
- function invokeArrayArg(arg, fn, context) {
1449
- if (Array.isArray(arg)) {
1450
- each(arg, context[fn], context);
1451
- return true;
1452
- }
1453
- return false;
1454
- }
1455
-
1456
- /**
1457
- * walk objects and arrays
1458
- * @param {Object} obj
1459
- * @param {Function} iterator
1460
- * @param {Object} context
1461
- */
1462
- function each(obj, iterator, context) {
1463
- var i;
1464
-
1465
- if (!obj) {
1466
- return;
1467
- }
1468
-
1469
- if (obj.forEach) {
1470
- obj.forEach(iterator, context);
1471
- } else if (obj.length !== undefined$1) {
1472
- i = 0;
1473
- while (i < obj.length) {
1474
- iterator.call(context, obj[i], i, obj);
1475
- i++;
1476
- }
1477
- } else {
1478
- for (i in obj) {
1479
- obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
1480
- }
1481
- }
1482
- }
1483
-
1484
- /**
1485
- * wrap a method with a deprecation warning and stack trace
1486
- * @param {Function} method
1487
- * @param {String} name
1488
- * @param {String} message
1489
- * @returns {Function} A new function wrapping the supplied method.
1490
- */
1491
- function deprecate(method, name, message) {
1492
- var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
1493
- return function() {
1494
- var e = new Error('get-stack-trace');
1495
- var stack = e && e.stack ? e.stack.replace(/^[^\(]+?[\n$]/gm, '')
1496
- .replace(/^\s+at\s+/gm, '')
1497
- .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@') : 'Unknown Stack Trace';
1498
-
1499
- var log = window.console && (window.console.warn || window.console.log);
1500
- if (log) {
1501
- log.call(window.console, deprecationMessage, stack);
1502
- }
1503
- return method.apply(this, arguments);
1504
- };
1505
- }
1506
-
1507
- /**
1508
- * extend object.
1509
- * means that properties in dest will be overwritten by the ones in src.
1510
- * @param {Object} target
1511
- * @param {...Object} objects_to_assign
1512
- * @returns {Object} target
1513
- */
1514
- var assign;
1515
- if (typeof Object.assign !== 'function') {
1516
- assign = function assign(target) {
1517
- if (target === undefined$1 || target === null) {
1518
- throw new TypeError('Cannot convert undefined or null to object');
1519
- }
1520
-
1521
- var output = Object(target);
1522
- for (var index = 1; index < arguments.length; index++) {
1523
- var source = arguments[index];
1524
- if (source !== undefined$1 && source !== null) {
1525
- for (var nextKey in source) {
1526
- if (source.hasOwnProperty(nextKey)) {
1527
- output[nextKey] = source[nextKey];
1528
- }
1529
- }
1530
- }
1531
- }
1532
- return output;
1533
- };
1534
- } else {
1535
- assign = Object.assign;
1536
- }
1537
-
1538
- /**
1539
- * extend object.
1540
- * means that properties in dest will be overwritten by the ones in src.
1541
- * @param {Object} dest
1542
- * @param {Object} src
1543
- * @param {Boolean} [merge=false]
1544
- * @returns {Object} dest
1545
- */
1546
- var extend = deprecate(function extend(dest, src, merge) {
1547
- var keys = Object.keys(src);
1548
- var i = 0;
1549
- while (i < keys.length) {
1550
- if (!merge || (merge && dest[keys[i]] === undefined$1)) {
1551
- dest[keys[i]] = src[keys[i]];
1552
- }
1553
- i++;
1554
- }
1555
- return dest;
1556
- }, 'extend', 'Use `assign`.');
1557
-
1558
- /**
1559
- * merge the values from src in the dest.
1560
- * means that properties that exist in dest will not be overwritten by src
1561
- * @param {Object} dest
1562
- * @param {Object} src
1563
- * @returns {Object} dest
1564
- */
1565
- var merge = deprecate(function merge(dest, src) {
1566
- return extend(dest, src, true);
1567
- }, 'merge', 'Use `assign`.');
1568
-
1569
- /**
1570
- * simple class inheritance
1571
- * @param {Function} child
1572
- * @param {Function} base
1573
- * @param {Object} [properties]
1574
- */
1575
- function inherit(child, base, properties) {
1576
- var baseP = base.prototype,
1577
- childP;
1578
-
1579
- childP = child.prototype = Object.create(baseP);
1580
- childP.constructor = child;
1581
- childP._super = baseP;
1582
-
1583
- if (properties) {
1584
- assign(childP, properties);
1585
- }
1586
- }
1587
-
1588
- /**
1589
- * simple function bind
1590
- * @param {Function} fn
1591
- * @param {Object} context
1592
- * @returns {Function}
1593
- */
1594
- function bindFn(fn, context) {
1595
- return function boundFn() {
1596
- return fn.apply(context, arguments);
1597
- };
1598
- }
1599
-
1600
- /**
1601
- * let a boolean value also be a function that must return a boolean
1602
- * this first item in args will be used as the context
1603
- * @param {Boolean|Function} val
1604
- * @param {Array} [args]
1605
- * @returns {Boolean}
1606
- */
1607
- function boolOrFn(val, args) {
1608
- if (typeof val == TYPE_FUNCTION) {
1609
- return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
1610
- }
1611
- return val;
1612
- }
1613
-
1614
- /**
1615
- * use the val2 when val1 is undefined
1616
- * @param {*} val1
1617
- * @param {*} val2
1618
- * @returns {*}
1619
- */
1620
- function ifUndefined(val1, val2) {
1621
- return (val1 === undefined$1) ? val2 : val1;
1622
- }
1623
-
1624
- /**
1625
- * addEventListener with multiple events at once
1626
- * @param {EventTarget} target
1627
- * @param {String} types
1628
- * @param {Function} handler
1629
- */
1630
- function addEventListeners(target, types, handler) {
1631
- each(splitStr(types), function(type) {
1632
- target.addEventListener(type, handler, false);
1633
- });
1634
- }
1635
-
1636
- /**
1637
- * removeEventListener with multiple events at once
1638
- * @param {EventTarget} target
1639
- * @param {String} types
1640
- * @param {Function} handler
1641
- */
1642
- function removeEventListeners(target, types, handler) {
1643
- each(splitStr(types), function(type) {
1644
- target.removeEventListener(type, handler, false);
1645
- });
1646
- }
1647
-
1648
- /**
1649
- * find if a node is in the given parent
1650
- * @method hasParent
1651
- * @param {HTMLElement} node
1652
- * @param {HTMLElement} parent
1653
- * @return {Boolean} found
1654
- */
1655
- function hasParent(node, parent) {
1656
- while (node) {
1657
- if (node == parent) {
1658
- return true;
1659
- }
1660
- node = node.parentNode;
1661
- }
1662
- return false;
1663
- }
1664
-
1665
- /**
1666
- * small indexOf wrapper
1667
- * @param {String} str
1668
- * @param {String} find
1669
- * @returns {Boolean} found
1670
- */
1671
- function inStr(str, find) {
1672
- return str.indexOf(find) > -1;
1673
- }
1674
-
1675
- /**
1676
- * split string on whitespace
1677
- * @param {String} str
1678
- * @returns {Array} words
1679
- */
1680
- function splitStr(str) {
1681
- return str.trim().split(/\s+/g);
1682
- }
1683
-
1684
- /**
1685
- * find if a array contains the object using indexOf or a simple polyFill
1686
- * @param {Array} src
1687
- * @param {String} find
1688
- * @param {String} [findByKey]
1689
- * @return {Boolean|Number} false when not found, or the index
1690
- */
1691
- function inArray(src, find, findByKey) {
1692
- if (src.indexOf && !findByKey) {
1693
- return src.indexOf(find);
1694
- } else {
1695
- var i = 0;
1696
- while (i < src.length) {
1697
- if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
1698
- return i;
1699
- }
1700
- i++;
1701
- }
1702
- return -1;
1703
- }
1704
- }
1705
-
1706
- /**
1707
- * convert array-like objects to real arrays
1708
- * @param {Object} obj
1709
- * @returns {Array}
1710
- */
1711
- function toArray(obj) {
1712
- return Array.prototype.slice.call(obj, 0);
1713
- }
1714
-
1715
- /**
1716
- * unique array with objects based on a key (like 'id') or just by the array's value
1717
- * @param {Array} src [{id:1},{id:2},{id:1}]
1718
- * @param {String} [key]
1719
- * @param {Boolean} [sort=False]
1720
- * @returns {Array} [{id:1},{id:2}]
1721
- */
1722
- function uniqueArray(src, key, sort) {
1723
- var results = [];
1724
- var values = [];
1725
- var i = 0;
1726
-
1727
- while (i < src.length) {
1728
- var val = src[i][key] ;
1729
- if (inArray(values, val) < 0) {
1730
- results.push(src[i]);
1731
- }
1732
- values[i] = val;
1733
- i++;
1734
- }
1735
-
1736
- {
1737
- {
1738
- results = results.sort(function sortUniqueArray(a, b) {
1739
- return a[key] > b[key];
1740
- });
1741
- }
1742
- }
1743
-
1744
- return results;
1745
- }
1746
-
1747
- /**
1748
- * get the prefixed property
1749
- * @param {Object} obj
1750
- * @param {String} property
1751
- * @returns {String|Undefined} prefixed
1752
- */
1753
- function prefixed(obj, property) {
1754
- var prefix, prop;
1755
- var camelProp = property[0].toUpperCase() + property.slice(1);
1756
-
1757
- var i = 0;
1758
- while (i < VENDOR_PREFIXES.length) {
1759
- prefix = VENDOR_PREFIXES[i];
1760
- prop = (prefix) ? prefix + camelProp : property;
1761
-
1762
- if (prop in obj) {
1763
- return prop;
1764
- }
1765
- i++;
1766
- }
1767
- return undefined$1;
1768
- }
1769
-
1770
- /**
1771
- * get a unique id
1772
- * @returns {number} uniqueId
1773
- */
1774
- var _uniqueId = 1;
1775
- function uniqueId() {
1776
- return _uniqueId++;
1777
- }
1778
-
1779
- /**
1780
- * get the window object of an element
1781
- * @param {HTMLElement} element
1782
- * @returns {DocumentView|Window}
1783
- */
1784
- function getWindowForElement(element) {
1785
- var doc = element.ownerDocument || element;
1786
- return (doc.defaultView || doc.parentWindow || window);
1787
- }
1788
-
1789
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
1790
-
1791
- var SUPPORT_TOUCH = ('ontouchstart' in window);
1792
- var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined$1;
1793
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
1794
-
1795
- var INPUT_TYPE_TOUCH = 'touch';
1796
- var INPUT_TYPE_PEN = 'pen';
1797
- var INPUT_TYPE_MOUSE = 'mouse';
1798
- var INPUT_TYPE_KINECT = 'kinect';
1799
-
1800
- var COMPUTE_INTERVAL = 25;
1801
-
1802
- var INPUT_START = 1;
1803
- var INPUT_MOVE = 2;
1804
- var INPUT_END = 4;
1805
- var INPUT_CANCEL = 8;
1806
-
1807
- var DIRECTION_NONE = 1;
1808
- var DIRECTION_LEFT = 2;
1809
- var DIRECTION_RIGHT = 4;
1810
- var DIRECTION_UP = 8;
1811
- var DIRECTION_DOWN = 16;
1812
-
1813
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
1814
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
1815
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
1816
-
1817
- var PROPS_XY = ['x', 'y'];
1818
- var PROPS_CLIENT_XY = ['clientX', 'clientY'];
1819
-
1820
- /**
1821
- * create new input type manager
1822
- * @param {Manager} manager
1823
- * @param {Function} callback
1824
- * @returns {Input}
1825
- * @constructor
1826
- */
1827
- function Input(manager, callback) {
1828
- var self = this;
1829
- this.manager = manager;
1830
- this.callback = callback;
1831
- this.element = manager.element;
1832
- this.target = manager.options.inputTarget;
1833
-
1834
- // smaller wrapper around the handler, for the scope and the enabled state of the manager,
1835
- // so when disabled the input events are completely bypassed.
1836
- this.domHandler = function(ev) {
1837
- if (boolOrFn(manager.options.enable, [manager])) {
1838
- self.handler(ev);
1839
- }
1840
- };
1841
-
1842
- this.init();
1843
-
1844
- }
1845
-
1846
- Input.prototype = {
1847
- /**
1848
- * should handle the inputEvent data and trigger the callback
1849
- * @virtual
1850
- */
1851
- handler: function() { },
1852
-
1853
- /**
1854
- * bind the events
1855
- */
1856
- init: function() {
1857
- this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
1858
- this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
1859
- this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
1860
- },
1861
-
1862
- /**
1863
- * unbind the events
1864
- */
1865
- destroy: function() {
1866
- this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
1867
- this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
1868
- this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
1869
- }
1870
- };
1871
-
1872
- /**
1873
- * create new input type manager
1874
- * called by the Manager constructor
1875
- * @param {Hammer} manager
1876
- * @returns {Input}
1877
- */
1878
- function createInputInstance(manager) {
1879
- var Type;
1880
- var inputClass = manager.options.inputClass;
1881
-
1882
- if (inputClass) {
1883
- Type = inputClass;
1884
- } else if (SUPPORT_POINTER_EVENTS) {
1885
- Type = PointerEventInput;
1886
- } else if (SUPPORT_ONLY_TOUCH) {
1887
- Type = TouchInput;
1888
- } else if (!SUPPORT_TOUCH) {
1889
- Type = MouseInput;
1890
- } else {
1891
- Type = TouchMouseInput;
1892
- }
1893
- return new (Type)(manager, inputHandler);
1894
- }
1895
-
1896
- /**
1897
- * handle input events
1898
- * @param {Manager} manager
1899
- * @param {String} eventType
1900
- * @param {Object} input
1901
- */
1902
- function inputHandler(manager, eventType, input) {
1903
- var pointersLen = input.pointers.length;
1904
- var changedPointersLen = input.changedPointers.length;
1905
- var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
1906
- var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
1907
-
1908
- input.isFirst = !!isFirst;
1909
- input.isFinal = !!isFinal;
1910
-
1911
- if (isFirst) {
1912
- manager.session = {};
1913
- }
1914
-
1915
- // source event is the normalized value of the domEvents
1916
- // like 'touchstart, mouseup, pointerdown'
1917
- input.eventType = eventType;
1918
-
1919
- // compute scale, rotation etc
1920
- computeInputData(manager, input);
1921
-
1922
- // emit secret event
1923
- manager.emit('hammer.input', input);
1924
-
1925
- manager.recognize(input);
1926
- manager.session.prevInput = input;
1927
- }
1928
-
1929
- /**
1930
- * extend the data with some usable properties like scale, rotate, velocity etc
1931
- * @param {Object} manager
1932
- * @param {Object} input
1933
- */
1934
- function computeInputData(manager, input) {
1935
- var session = manager.session;
1936
- var pointers = input.pointers;
1937
- var pointersLength = pointers.length;
1938
-
1939
- // store the first input to calculate the distance and direction
1940
- if (!session.firstInput) {
1941
- session.firstInput = simpleCloneInputData(input);
1942
- }
1943
-
1944
- // to compute scale and rotation we need to store the multiple touches
1945
- if (pointersLength > 1 && !session.firstMultiple) {
1946
- session.firstMultiple = simpleCloneInputData(input);
1947
- } else if (pointersLength === 1) {
1948
- session.firstMultiple = false;
1949
- }
1950
-
1951
- var firstInput = session.firstInput;
1952
- var firstMultiple = session.firstMultiple;
1953
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
1954
-
1955
- var center = input.center = getCenter(pointers);
1956
- input.timeStamp = now();
1957
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
1958
-
1959
- input.angle = getAngle(offsetCenter, center);
1960
- input.distance = getDistance(offsetCenter, center);
1961
-
1962
- computeDeltaXY(session, input);
1963
- input.offsetDirection = getDirection(input.deltaX, input.deltaY);
1964
-
1965
- var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
1966
- input.overallVelocityX = overallVelocity.x;
1967
- input.overallVelocityY = overallVelocity.y;
1968
- input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;
1969
-
1970
- input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
1971
- input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
1972
-
1973
- input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
1974
- session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);
1975
-
1976
- computeIntervalInputData(session, input);
1977
-
1978
- // find the correct target
1979
- var target = manager.element;
1980
- if (hasParent(input.srcEvent.target, target)) {
1981
- target = input.srcEvent.target;
1982
- }
1983
- input.target = target;
1984
- }
1985
-
1986
- function computeDeltaXY(session, input) {
1987
- var center = input.center;
1988
- var offset = session.offsetDelta || {};
1989
- var prevDelta = session.prevDelta || {};
1990
- var prevInput = session.prevInput || {};
1991
-
1992
- if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
1993
- prevDelta = session.prevDelta = {
1994
- x: prevInput.deltaX || 0,
1995
- y: prevInput.deltaY || 0
1996
- };
1997
-
1998
- offset = session.offsetDelta = {
1999
- x: center.x,
2000
- y: center.y
2001
- };
2002
- }
2003
-
2004
- input.deltaX = prevDelta.x + (center.x - offset.x);
2005
- input.deltaY = prevDelta.y + (center.y - offset.y);
2006
- }
2007
-
2008
- /**
2009
- * velocity is calculated every x ms
2010
- * @param {Object} session
2011
- * @param {Object} input
2012
- */
2013
- function computeIntervalInputData(session, input) {
2014
- var last = session.lastInterval || input,
2015
- deltaTime = input.timeStamp - last.timeStamp,
2016
- velocity, velocityX, velocityY, direction;
2017
-
2018
- if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
2019
- var deltaX = input.deltaX - last.deltaX;
2020
- var deltaY = input.deltaY - last.deltaY;
2021
-
2022
- var v = getVelocity(deltaTime, deltaX, deltaY);
2023
- velocityX = v.x;
2024
- velocityY = v.y;
2025
- velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
2026
- direction = getDirection(deltaX, deltaY);
2027
-
2028
- session.lastInterval = input;
2029
- } else {
2030
- // use latest velocity info if it doesn't overtake a minimum period
2031
- velocity = last.velocity;
2032
- velocityX = last.velocityX;
2033
- velocityY = last.velocityY;
2034
- direction = last.direction;
2035
- }
2036
-
2037
- input.velocity = velocity;
2038
- input.velocityX = velocityX;
2039
- input.velocityY = velocityY;
2040
- input.direction = direction;
2041
- }
2042
-
2043
- /**
2044
- * create a simple clone from the input used for storage of firstInput and firstMultiple
2045
- * @param {Object} input
2046
- * @returns {Object} clonedInputData
2047
- */
2048
- function simpleCloneInputData(input) {
2049
- // make a simple copy of the pointers because we will get a reference if we don't
2050
- // we only need clientXY for the calculations
2051
- var pointers = [];
2052
- var i = 0;
2053
- while (i < input.pointers.length) {
2054
- pointers[i] = {
2055
- clientX: round(input.pointers[i].clientX),
2056
- clientY: round(input.pointers[i].clientY)
2057
- };
2058
- i++;
2059
- }
2060
-
2061
- return {
2062
- timeStamp: now(),
2063
- pointers: pointers,
2064
- center: getCenter(pointers),
2065
- deltaX: input.deltaX,
2066
- deltaY: input.deltaY
2067
- };
2068
- }
2069
-
2070
- /**
2071
- * get the center of all the pointers
2072
- * @param {Array} pointers
2073
- * @return {Object} center contains `x` and `y` properties
2074
- */
2075
- function getCenter(pointers) {
2076
- var pointersLength = pointers.length;
2077
-
2078
- // no need to loop when only one touch
2079
- if (pointersLength === 1) {
2080
- return {
2081
- x: round(pointers[0].clientX),
2082
- y: round(pointers[0].clientY)
2083
- };
2084
- }
2085
-
2086
- var x = 0, y = 0, i = 0;
2087
- while (i < pointersLength) {
2088
- x += pointers[i].clientX;
2089
- y += pointers[i].clientY;
2090
- i++;
2091
- }
2092
-
2093
- return {
2094
- x: round(x / pointersLength),
2095
- y: round(y / pointersLength)
2096
- };
2097
- }
2098
-
2099
- /**
2100
- * calculate the velocity between two points. unit is in px per ms.
2101
- * @param {Number} deltaTime
2102
- * @param {Number} x
2103
- * @param {Number} y
2104
- * @return {Object} velocity `x` and `y`
2105
- */
2106
- function getVelocity(deltaTime, x, y) {
2107
- return {
2108
- x: x / deltaTime || 0,
2109
- y: y / deltaTime || 0
2110
- };
2111
- }
2112
-
2113
- /**
2114
- * get the direction between two points
2115
- * @param {Number} x
2116
- * @param {Number} y
2117
- * @return {Number} direction
2118
- */
2119
- function getDirection(x, y) {
2120
- if (x === y) {
2121
- return DIRECTION_NONE;
2122
- }
2123
-
2124
- if (abs(x) >= abs(y)) {
2125
- return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
2126
- }
2127
- return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
2128
- }
2129
-
2130
- /**
2131
- * calculate the absolute distance between two points
2132
- * @param {Object} p1 {x, y}
2133
- * @param {Object} p2 {x, y}
2134
- * @param {Array} [props] containing x and y keys
2135
- * @return {Number} distance
2136
- */
2137
- function getDistance(p1, p2, props) {
2138
- if (!props) {
2139
- props = PROPS_XY;
2140
- }
2141
- var x = p2[props[0]] - p1[props[0]],
2142
- y = p2[props[1]] - p1[props[1]];
2143
-
2144
- return Math.sqrt((x * x) + (y * y));
2145
- }
2146
-
2147
- /**
2148
- * calculate the angle between two coordinates
2149
- * @param {Object} p1
2150
- * @param {Object} p2
2151
- * @param {Array} [props] containing x and y keys
2152
- * @return {Number} angle
2153
- */
2154
- function getAngle(p1, p2, props) {
2155
- if (!props) {
2156
- props = PROPS_XY;
2157
- }
2158
- var x = p2[props[0]] - p1[props[0]],
2159
- y = p2[props[1]] - p1[props[1]];
2160
- return Math.atan2(y, x) * 180 / Math.PI;
2161
- }
2162
-
2163
- /**
2164
- * calculate the rotation degrees between two pointersets
2165
- * @param {Array} start array of pointers
2166
- * @param {Array} end array of pointers
2167
- * @return {Number} rotation
2168
- */
2169
- function getRotation(start, end) {
2170
- return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
2171
- }
2172
-
2173
- /**
2174
- * calculate the scale factor between two pointersets
2175
- * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
2176
- * @param {Array} start array of pointers
2177
- * @param {Array} end array of pointers
2178
- * @return {Number} scale
2179
- */
2180
- function getScale(start, end) {
2181
- return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
2182
- }
2183
-
2184
- var MOUSE_INPUT_MAP = {
2185
- mousedown: INPUT_START,
2186
- mousemove: INPUT_MOVE,
2187
- mouseup: INPUT_END
2188
- };
2189
-
2190
- var MOUSE_ELEMENT_EVENTS = 'mousedown';
2191
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
2192
-
2193
- /**
2194
- * Mouse events input
2195
- * @constructor
2196
- * @extends Input
2197
- */
2198
- function MouseInput() {
2199
- this.evEl = MOUSE_ELEMENT_EVENTS;
2200
- this.evWin = MOUSE_WINDOW_EVENTS;
2201
-
2202
- this.pressed = false; // mousedown state
2203
-
2204
- Input.apply(this, arguments);
2205
- }
2206
-
2207
- inherit(MouseInput, Input, {
2208
- /**
2209
- * handle mouse events
2210
- * @param {Object} ev
2211
- */
2212
- handler: function MEhandler(ev) {
2213
- var eventType = MOUSE_INPUT_MAP[ev.type];
2214
-
2215
- // on start we want to have the left mouse button down
2216
- if (eventType & INPUT_START && ev.button === 0) {
2217
- this.pressed = true;
2218
- }
2219
-
2220
- if (eventType & INPUT_MOVE && ev.which !== 1) {
2221
- eventType = INPUT_END;
2222
- }
2223
-
2224
- // mouse must be down
2225
- if (!this.pressed) {
2226
- return;
2227
- }
2228
-
2229
- if (eventType & INPUT_END) {
2230
- this.pressed = false;
2231
- }
2232
-
2233
- this.callback(this.manager, eventType, {
2234
- pointers: [ev],
2235
- changedPointers: [ev],
2236
- pointerType: INPUT_TYPE_MOUSE,
2237
- srcEvent: ev
2238
- });
2239
- }
2240
- });
2241
-
2242
- var POINTER_INPUT_MAP = {
2243
- pointerdown: INPUT_START,
2244
- pointermove: INPUT_MOVE,
2245
- pointerup: INPUT_END,
2246
- pointercancel: INPUT_CANCEL,
2247
- pointerout: INPUT_CANCEL
2248
- };
2249
-
2250
- // in IE10 the pointer types is defined as an enum
2251
- var IE10_POINTER_TYPE_ENUM = {
2252
- 2: INPUT_TYPE_TOUCH,
2253
- 3: INPUT_TYPE_PEN,
2254
- 4: INPUT_TYPE_MOUSE,
2255
- 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
2256
- };
2257
-
2258
- var POINTER_ELEMENT_EVENTS = 'pointerdown';
2259
- var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
2260
-
2261
- // IE10 has prefixed support, and case-sensitive
2262
- if (window.MSPointerEvent && !window.PointerEvent) {
2263
- POINTER_ELEMENT_EVENTS = 'MSPointerDown';
2264
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
2265
- }
2266
-
2267
- /**
2268
- * Pointer events input
2269
- * @constructor
2270
- * @extends Input
2271
- */
2272
- function PointerEventInput() {
2273
- this.evEl = POINTER_ELEMENT_EVENTS;
2274
- this.evWin = POINTER_WINDOW_EVENTS;
2275
-
2276
- Input.apply(this, arguments);
2277
-
2278
- this.store = (this.manager.session.pointerEvents = []);
2279
- }
2280
-
2281
- inherit(PointerEventInput, Input, {
2282
- /**
2283
- * handle mouse events
2284
- * @param {Object} ev
2285
- */
2286
- handler: function PEhandler(ev) {
2287
- var store = this.store;
2288
- var removePointer = false;
2289
-
2290
- var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
2291
- var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
2292
- var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
2293
-
2294
- var isTouch = (pointerType == INPUT_TYPE_TOUCH);
2295
-
2296
- // get index of the event in the store
2297
- var storeIndex = inArray(store, ev.pointerId, 'pointerId');
2298
-
2299
- // start and mouse must be down
2300
- if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
2301
- if (storeIndex < 0) {
2302
- store.push(ev);
2303
- storeIndex = store.length - 1;
2304
- }
2305
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
2306
- removePointer = true;
2307
- }
2308
-
2309
- // it not found, so the pointer hasn't been down (so it's probably a hover)
2310
- if (storeIndex < 0) {
2311
- return;
2312
- }
2313
-
2314
- // update the event in the store
2315
- store[storeIndex] = ev;
2316
-
2317
- this.callback(this.manager, eventType, {
2318
- pointers: store,
2319
- changedPointers: [ev],
2320
- pointerType: pointerType,
2321
- srcEvent: ev
2322
- });
2323
-
2324
- if (removePointer) {
2325
- // remove from the store
2326
- store.splice(storeIndex, 1);
2327
- }
2328
- }
2329
- });
2330
-
2331
- var SINGLE_TOUCH_INPUT_MAP = {
2332
- touchstart: INPUT_START,
2333
- touchmove: INPUT_MOVE,
2334
- touchend: INPUT_END,
2335
- touchcancel: INPUT_CANCEL
2336
- };
2337
-
2338
- var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
2339
- var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
2340
-
2341
- /**
2342
- * Touch events input
2343
- * @constructor
2344
- * @extends Input
2345
- */
2346
- function SingleTouchInput() {
2347
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
2348
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
2349
- this.started = false;
2350
-
2351
- Input.apply(this, arguments);
2352
- }
2353
-
2354
- inherit(SingleTouchInput, Input, {
2355
- handler: function TEhandler(ev) {
2356
- var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
2357
-
2358
- // should we handle the touch events?
2359
- if (type === INPUT_START) {
2360
- this.started = true;
2361
- }
2362
-
2363
- if (!this.started) {
2364
- return;
2365
- }
2366
-
2367
- var touches = normalizeSingleTouches.call(this, ev, type);
2368
-
2369
- // when done, reset the started state
2370
- if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
2371
- this.started = false;
2372
- }
2373
-
2374
- this.callback(this.manager, type, {
2375
- pointers: touches[0],
2376
- changedPointers: touches[1],
2377
- pointerType: INPUT_TYPE_TOUCH,
2378
- srcEvent: ev
2379
- });
2380
- }
2381
- });
2382
-
2383
- /**
2384
- * @this {TouchInput}
2385
- * @param {Object} ev
2386
- * @param {Number} type flag
2387
- * @returns {undefined|Array} [all, changed]
2388
- */
2389
- function normalizeSingleTouches(ev, type) {
2390
- var all = toArray(ev.touches);
2391
- var changed = toArray(ev.changedTouches);
2392
-
2393
- if (type & (INPUT_END | INPUT_CANCEL)) {
2394
- all = uniqueArray(all.concat(changed), 'identifier');
2395
- }
2396
-
2397
- return [all, changed];
2398
- }
2399
-
2400
- var TOUCH_INPUT_MAP = {
2401
- touchstart: INPUT_START,
2402
- touchmove: INPUT_MOVE,
2403
- touchend: INPUT_END,
2404
- touchcancel: INPUT_CANCEL
2405
- };
2406
-
2407
- var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
2408
-
2409
- /**
2410
- * Multi-user touch events input
2411
- * @constructor
2412
- * @extends Input
2413
- */
2414
- function TouchInput() {
2415
- this.evTarget = TOUCH_TARGET_EVENTS;
2416
- this.targetIds = {};
2417
-
2418
- Input.apply(this, arguments);
2419
- }
2420
-
2421
- inherit(TouchInput, Input, {
2422
- handler: function MTEhandler(ev) {
2423
- var type = TOUCH_INPUT_MAP[ev.type];
2424
- var touches = getTouches.call(this, ev, type);
2425
- if (!touches) {
2426
- return;
2427
- }
2428
-
2429
- this.callback(this.manager, type, {
2430
- pointers: touches[0],
2431
- changedPointers: touches[1],
2432
- pointerType: INPUT_TYPE_TOUCH,
2433
- srcEvent: ev
2434
- });
2435
- }
2436
- });
2437
-
2438
- /**
2439
- * @this {TouchInput}
2440
- * @param {Object} ev
2441
- * @param {Number} type flag
2442
- * @returns {undefined|Array} [all, changed]
2443
- */
2444
- function getTouches(ev, type) {
2445
- var allTouches = toArray(ev.touches);
2446
- var targetIds = this.targetIds;
2447
-
2448
- // when there is only one touch, the process can be simplified
2449
- if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
2450
- targetIds[allTouches[0].identifier] = true;
2451
- return [allTouches, allTouches];
2452
- }
2453
-
2454
- var i,
2455
- targetTouches,
2456
- changedTouches = toArray(ev.changedTouches),
2457
- changedTargetTouches = [],
2458
- target = this.target;
2459
-
2460
- // get target touches from touches
2461
- targetTouches = allTouches.filter(function(touch) {
2462
- return hasParent(touch.target, target);
2463
- });
2464
-
2465
- // collect touches
2466
- if (type === INPUT_START) {
2467
- i = 0;
2468
- while (i < targetTouches.length) {
2469
- targetIds[targetTouches[i].identifier] = true;
2470
- i++;
2471
- }
2472
- }
2473
-
2474
- // filter changed touches to only contain touches that exist in the collected target ids
2475
- i = 0;
2476
- while (i < changedTouches.length) {
2477
- if (targetIds[changedTouches[i].identifier]) {
2478
- changedTargetTouches.push(changedTouches[i]);
2479
- }
2480
-
2481
- // cleanup removed touches
2482
- if (type & (INPUT_END | INPUT_CANCEL)) {
2483
- delete targetIds[changedTouches[i].identifier];
2484
- }
2485
- i++;
2486
- }
2487
-
2488
- if (!changedTargetTouches.length) {
2489
- return;
2490
- }
2491
-
2492
- return [
2493
- // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
2494
- uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier'),
2495
- changedTargetTouches
2496
- ];
2497
- }
2498
-
2499
- /**
2500
- * Combined touch and mouse input
2501
- *
2502
- * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
2503
- * This because touch devices also emit mouse events while doing a touch.
2504
- *
2505
- * @constructor
2506
- * @extends Input
2507
- */
2508
-
2509
- var DEDUP_TIMEOUT = 2500;
2510
- var DEDUP_DISTANCE = 25;
2511
-
2512
- function TouchMouseInput() {
2513
- Input.apply(this, arguments);
2514
-
2515
- var handler = bindFn(this.handler, this);
2516
- this.touch = new TouchInput(this.manager, handler);
2517
- this.mouse = new MouseInput(this.manager, handler);
2518
-
2519
- this.primaryTouch = null;
2520
- this.lastTouches = [];
2521
- }
2522
-
2523
- inherit(TouchMouseInput, Input, {
2524
- /**
2525
- * handle mouse and touch events
2526
- * @param {Hammer} manager
2527
- * @param {String} inputEvent
2528
- * @param {Object} inputData
2529
- */
2530
- handler: function TMEhandler(manager, inputEvent, inputData) {
2531
- var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
2532
- isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
2533
-
2534
- if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
2535
- return;
2536
- }
2537
-
2538
- // when we're in a touch event, record touches to de-dupe synthetic mouse event
2539
- if (isTouch) {
2540
- recordTouches.call(this, inputEvent, inputData);
2541
- } else if (isMouse && isSyntheticEvent.call(this, inputData)) {
2542
- return;
2543
- }
2544
-
2545
- this.callback(manager, inputEvent, inputData);
2546
- },
2547
-
2548
- /**
2549
- * remove the event listeners
2550
- */
2551
- destroy: function destroy() {
2552
- this.touch.destroy();
2553
- this.mouse.destroy();
2554
- }
2555
- });
2556
-
2557
- function recordTouches(eventType, eventData) {
2558
- if (eventType & INPUT_START) {
2559
- this.primaryTouch = eventData.changedPointers[0].identifier;
2560
- setLastTouch.call(this, eventData);
2561
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
2562
- setLastTouch.call(this, eventData);
2563
- }
2564
- }
2565
-
2566
- function setLastTouch(eventData) {
2567
- var touch = eventData.changedPointers[0];
2568
-
2569
- if (touch.identifier === this.primaryTouch) {
2570
- var lastTouch = {x: touch.clientX, y: touch.clientY};
2571
- this.lastTouches.push(lastTouch);
2572
- var lts = this.lastTouches;
2573
- var removeLastTouch = function() {
2574
- var i = lts.indexOf(lastTouch);
2575
- if (i > -1) {
2576
- lts.splice(i, 1);
2577
- }
2578
- };
2579
- setTimeout(removeLastTouch, DEDUP_TIMEOUT);
2580
- }
2581
- }
2582
-
2583
- function isSyntheticEvent(eventData) {
2584
- var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
2585
- for (var i = 0; i < this.lastTouches.length; i++) {
2586
- var t = this.lastTouches[i];
2587
- var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y);
2588
- if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
2589
- return true;
2590
- }
2591
- }
2592
- return false;
2593
- }
2594
-
2595
- var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
2596
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
2597
-
2598
- // magical touchAction value
2599
- var TOUCH_ACTION_COMPUTE = 'compute';
2600
- var TOUCH_ACTION_AUTO = 'auto';
2601
- var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
2602
- var TOUCH_ACTION_NONE = 'none';
2603
- var TOUCH_ACTION_PAN_X = 'pan-x';
2604
- var TOUCH_ACTION_PAN_Y = 'pan-y';
2605
- var TOUCH_ACTION_MAP = getTouchActionProps();
2606
-
2607
- /**
2608
- * Touch Action
2609
- * sets the touchAction property or uses the js alternative
2610
- * @param {Manager} manager
2611
- * @param {String} value
2612
- * @constructor
2613
- */
2614
- function TouchAction(manager, value) {
2615
- this.manager = manager;
2616
- this.set(value);
2617
- }
2618
-
2619
- TouchAction.prototype = {
2620
- /**
2621
- * set the touchAction value on the element or enable the polyfill
2622
- * @param {String} value
2623
- */
2624
- set: function(value) {
2625
- // find out the touch-action by the event handlers
2626
- if (value == TOUCH_ACTION_COMPUTE) {
2627
- value = this.compute();
2628
- }
2629
-
2630
- if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
2631
- this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
2632
- }
2633
- this.actions = value.toLowerCase().trim();
2634
- },
2635
-
2636
- /**
2637
- * just re-set the touchAction value
2638
- */
2639
- update: function() {
2640
- this.set(this.manager.options.touchAction);
2641
- },
2642
-
2643
- /**
2644
- * compute the value for the touchAction property based on the recognizer's settings
2645
- * @returns {String} value
2646
- */
2647
- compute: function() {
2648
- var actions = [];
2649
- each(this.manager.recognizers, function(recognizer) {
2650
- if (boolOrFn(recognizer.options.enable, [recognizer])) {
2651
- actions = actions.concat(recognizer.getTouchAction());
2652
- }
2653
- });
2654
- return cleanTouchActions(actions.join(' '));
2655
- },
2656
-
2657
- /**
2658
- * this method is called on each input cycle and provides the preventing of the browser behavior
2659
- * @param {Object} input
2660
- */
2661
- preventDefaults: function(input) {
2662
- var srcEvent = input.srcEvent;
2663
- var direction = input.offsetDirection;
2664
-
2665
- // if the touch action did prevented once this session
2666
- if (this.manager.session.prevented) {
2667
- srcEvent.preventDefault();
2668
- return;
2669
- }
2670
-
2671
- var actions = this.actions;
2672
- var hasNone = inStr(actions, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
2673
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
2674
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
2675
-
2676
- if (hasNone) {
2677
- //do not prevent defaults if this is a tap gesture
2678
-
2679
- var isTapPointer = input.pointers.length === 1;
2680
- var isTapMovement = input.distance < 2;
2681
- var isTapTouchTime = input.deltaTime < 250;
2682
-
2683
- if (isTapPointer && isTapMovement && isTapTouchTime) {
2684
- return;
2685
- }
2686
- }
2687
-
2688
- if (hasPanX && hasPanY) {
2689
- // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
2690
- return;
2691
- }
2692
-
2693
- if (hasNone ||
2694
- (hasPanY && direction & DIRECTION_HORIZONTAL) ||
2695
- (hasPanX && direction & DIRECTION_VERTICAL)) {
2696
- return this.preventSrc(srcEvent);
2697
- }
2698
- },
2699
-
2700
- /**
2701
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
2702
- * @param {Object} srcEvent
2703
- */
2704
- preventSrc: function(srcEvent) {
2705
- this.manager.session.prevented = true;
2706
- srcEvent.preventDefault();
2707
- }
2708
- };
2709
-
2710
- /**
2711
- * when the touchActions are collected they are not a valid value, so we need to clean things up. *
2712
- * @param {String} actions
2713
- * @returns {*}
2714
- */
2715
- function cleanTouchActions(actions) {
2716
- // none
2717
- if (inStr(actions, TOUCH_ACTION_NONE)) {
2718
- return TOUCH_ACTION_NONE;
2719
- }
2720
-
2721
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
2722
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
2723
-
2724
- // if both pan-x and pan-y are set (different recognizers
2725
- // for different directions, e.g. horizontal pan but vertical swipe?)
2726
- // we need none (as otherwise with pan-x pan-y combined none of these
2727
- // recognizers will work, since the browser would handle all panning
2728
- if (hasPanX && hasPanY) {
2729
- return TOUCH_ACTION_NONE;
2730
- }
2731
-
2732
- // pan-x OR pan-y
2733
- if (hasPanX || hasPanY) {
2734
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
2735
- }
2736
-
2737
- // manipulation
2738
- if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
2739
- return TOUCH_ACTION_MANIPULATION;
2740
- }
2741
-
2742
- return TOUCH_ACTION_AUTO;
2743
- }
2744
-
2745
- function getTouchActionProps() {
2746
- if (!NATIVE_TOUCH_ACTION) {
2747
- return false;
2748
- }
2749
- var touchMap = {};
2750
- var cssSupports = window.CSS && window.CSS.supports;
2751
- ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
2752
-
2753
- // If css.supports is not supported but there is native touch-action assume it supports
2754
- // all values. This is the case for IE 10 and 11.
2755
- touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
2756
- });
2757
- return touchMap;
2758
- }
2759
-
2760
- /**
2761
- * Recognizer flow explained; *
2762
- * All recognizers have the initial state of POSSIBLE when a input session starts.
2763
- * The definition of a input session is from the first input until the last input, with all it's movement in it. *
2764
- * Example session for mouse-input: mousedown -> mousemove -> mouseup
2765
- *
2766
- * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
2767
- * which determines with state it should be.
2768
- *
2769
- * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
2770
- * POSSIBLE to give it another change on the next cycle.
2771
- *
2772
- * Possible
2773
- * |
2774
- * +-----+---------------+
2775
- * | |
2776
- * +-----+-----+ |
2777
- * | | |
2778
- * Failed Cancelled |
2779
- * +-------+------+
2780
- * | |
2781
- * Recognized Began
2782
- * |
2783
- * Changed
2784
- * |
2785
- * Ended/Recognized
2786
- */
2787
- var STATE_POSSIBLE = 1;
2788
- var STATE_BEGAN = 2;
2789
- var STATE_CHANGED = 4;
2790
- var STATE_ENDED = 8;
2791
- var STATE_RECOGNIZED = STATE_ENDED;
2792
- var STATE_CANCELLED = 16;
2793
- var STATE_FAILED = 32;
2794
-
2795
- /**
2796
- * Recognizer
2797
- * Every recognizer needs to extend from this class.
2798
- * @constructor
2799
- * @param {Object} options
2800
- */
2801
- function Recognizer(options) {
2802
- this.options = assign({}, this.defaults, options || {});
2803
-
2804
- this.id = uniqueId();
2805
-
2806
- this.manager = null;
2807
-
2808
- // default is enable true
2809
- this.options.enable = ifUndefined(this.options.enable, true);
2810
-
2811
- this.state = STATE_POSSIBLE;
2812
-
2813
- this.simultaneous = {};
2814
- this.requireFail = [];
2815
- }
2816
-
2817
- Recognizer.prototype = {
2818
- /**
2819
- * @virtual
2820
- * @type {Object}
2821
- */
2822
- defaults: {},
2823
-
2824
- /**
2825
- * set options
2826
- * @param {Object} options
2827
- * @return {Recognizer}
2828
- */
2829
- set: function(options) {
2830
- assign(this.options, options);
2831
-
2832
- // also update the touchAction, in case something changed about the directions/enabled state
2833
- this.manager && this.manager.touchAction.update();
2834
- return this;
2835
- },
2836
-
2837
- /**
2838
- * recognize simultaneous with an other recognizer.
2839
- * @param {Recognizer} otherRecognizer
2840
- * @returns {Recognizer} this
2841
- */
2842
- recognizeWith: function(otherRecognizer) {
2843
- if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
2844
- return this;
2845
- }
2846
-
2847
- var simultaneous = this.simultaneous;
2848
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
2849
- if (!simultaneous[otherRecognizer.id]) {
2850
- simultaneous[otherRecognizer.id] = otherRecognizer;
2851
- otherRecognizer.recognizeWith(this);
2852
- }
2853
- return this;
2854
- },
2855
-
2856
- /**
2857
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
2858
- * @param {Recognizer} otherRecognizer
2859
- * @returns {Recognizer} this
2860
- */
2861
- dropRecognizeWith: function(otherRecognizer) {
2862
- if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
2863
- return this;
2864
- }
2865
-
2866
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
2867
- delete this.simultaneous[otherRecognizer.id];
2868
- return this;
2869
- },
2870
-
2871
- /**
2872
- * recognizer can only run when an other is failing
2873
- * @param {Recognizer} otherRecognizer
2874
- * @returns {Recognizer} this
2875
- */
2876
- requireFailure: function(otherRecognizer) {
2877
- if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
2878
- return this;
2879
- }
2880
-
2881
- var requireFail = this.requireFail;
2882
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
2883
- if (inArray(requireFail, otherRecognizer) === -1) {
2884
- requireFail.push(otherRecognizer);
2885
- otherRecognizer.requireFailure(this);
2886
- }
2887
- return this;
2888
- },
2889
-
2890
- /**
2891
- * drop the requireFailure link. it does not remove the link on the other recognizer.
2892
- * @param {Recognizer} otherRecognizer
2893
- * @returns {Recognizer} this
2894
- */
2895
- dropRequireFailure: function(otherRecognizer) {
2896
- if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
2897
- return this;
2898
- }
2899
-
2900
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
2901
- var index = inArray(this.requireFail, otherRecognizer);
2902
- if (index > -1) {
2903
- this.requireFail.splice(index, 1);
2904
- }
2905
- return this;
2906
- },
2907
-
2908
- /**
2909
- * has require failures boolean
2910
- * @returns {boolean}
2911
- */
2912
- hasRequireFailures: function() {
2913
- return this.requireFail.length > 0;
2914
- },
2915
-
2916
- /**
2917
- * if the recognizer can recognize simultaneous with an other recognizer
2918
- * @param {Recognizer} otherRecognizer
2919
- * @returns {Boolean}
2920
- */
2921
- canRecognizeWith: function(otherRecognizer) {
2922
- return !!this.simultaneous[otherRecognizer.id];
2923
- },
2924
-
2925
- /**
2926
- * You should use `tryEmit` instead of `emit` directly to check
2927
- * that all the needed recognizers has failed before emitting.
2928
- * @param {Object} input
2929
- */
2930
- emit: function(input) {
2931
- var self = this;
2932
- var state = this.state;
2933
-
2934
- function emit(event) {
2935
- self.manager.emit(event, input);
2936
- }
2937
-
2938
- // 'panstart' and 'panmove'
2939
- if (state < STATE_ENDED) {
2940
- emit(self.options.event + stateStr(state));
2941
- }
2942
-
2943
- emit(self.options.event); // simple 'eventName' events
2944
-
2945
- if (input.additionalEvent) { // additional event(panleft, panright, pinchin, pinchout...)
2946
- emit(input.additionalEvent);
2947
- }
2948
-
2949
- // panend and pancancel
2950
- if (state >= STATE_ENDED) {
2951
- emit(self.options.event + stateStr(state));
2952
- }
2953
- },
2954
-
2955
- /**
2956
- * Check that all the require failure recognizers has failed,
2957
- * if true, it emits a gesture event,
2958
- * otherwise, setup the state to FAILED.
2959
- * @param {Object} input
2960
- */
2961
- tryEmit: function(input) {
2962
- if (this.canEmit()) {
2963
- return this.emit(input);
2964
- }
2965
- // it's failing anyway
2966
- this.state = STATE_FAILED;
2967
- },
2968
-
2969
- /**
2970
- * can we emit?
2971
- * @returns {boolean}
2972
- */
2973
- canEmit: function() {
2974
- var i = 0;
2975
- while (i < this.requireFail.length) {
2976
- if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
2977
- return false;
2978
- }
2979
- i++;
2980
- }
2981
- return true;
2982
- },
2983
-
2984
- /**
2985
- * update the recognizer
2986
- * @param {Object} inputData
2987
- */
2988
- recognize: function(inputData) {
2989
- // make a new copy of the inputData
2990
- // so we can change the inputData without messing up the other recognizers
2991
- var inputDataClone = assign({}, inputData);
2992
-
2993
- // is is enabled and allow recognizing?
2994
- if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
2995
- this.reset();
2996
- this.state = STATE_FAILED;
2997
- return;
2998
- }
2999
-
3000
- // reset when we've reached the end
3001
- if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
3002
- this.state = STATE_POSSIBLE;
3003
- }
3004
-
3005
- this.state = this.process(inputDataClone);
3006
-
3007
- // the recognizer has recognized a gesture
3008
- // so trigger an event
3009
- if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
3010
- this.tryEmit(inputDataClone);
3011
- }
3012
- },
3013
-
3014
- /**
3015
- * return the state of the recognizer
3016
- * the actual recognizing happens in this method
3017
- * @virtual
3018
- * @param {Object} inputData
3019
- * @returns {Const} STATE
3020
- */
3021
- process: function(inputData) { }, // jshint ignore:line
3022
-
3023
- /**
3024
- * return the preferred touch-action
3025
- * @virtual
3026
- * @returns {Array}
3027
- */
3028
- getTouchAction: function() { },
3029
-
3030
- /**
3031
- * called when the gesture isn't allowed to recognize
3032
- * like when another is being recognized or it is disabled
3033
- * @virtual
3034
- */
3035
- reset: function() { }
3036
- };
3037
-
3038
- /**
3039
- * get a usable string, used as event postfix
3040
- * @param {Const} state
3041
- * @returns {String} state
3042
- */
3043
- function stateStr(state) {
3044
- if (state & STATE_CANCELLED) {
3045
- return 'cancel';
3046
- } else if (state & STATE_ENDED) {
3047
- return 'end';
3048
- } else if (state & STATE_CHANGED) {
3049
- return 'move';
3050
- } else if (state & STATE_BEGAN) {
3051
- return 'start';
3052
- }
3053
- return '';
3054
- }
3055
-
3056
- /**
3057
- * direction cons to string
3058
- * @param {Const} direction
3059
- * @returns {String}
3060
- */
3061
- function directionStr(direction) {
3062
- if (direction == DIRECTION_DOWN) {
3063
- return 'down';
3064
- } else if (direction == DIRECTION_UP) {
3065
- return 'up';
3066
- } else if (direction == DIRECTION_LEFT) {
3067
- return 'left';
3068
- } else if (direction == DIRECTION_RIGHT) {
3069
- return 'right';
3070
- }
3071
- return '';
3072
- }
3073
-
3074
- /**
3075
- * get a recognizer by name if it is bound to a manager
3076
- * @param {Recognizer|String} otherRecognizer
3077
- * @param {Recognizer} recognizer
3078
- * @returns {Recognizer}
3079
- */
3080
- function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
3081
- var manager = recognizer.manager;
3082
- if (manager) {
3083
- return manager.get(otherRecognizer);
3084
- }
3085
- return otherRecognizer;
3086
- }
3087
-
3088
- /**
3089
- * This recognizer is just used as a base for the simple attribute recognizers.
3090
- * @constructor
3091
- * @extends Recognizer
3092
- */
3093
- function AttrRecognizer() {
3094
- Recognizer.apply(this, arguments);
3095
- }
3096
-
3097
- inherit(AttrRecognizer, Recognizer, {
3098
- /**
3099
- * @namespace
3100
- * @memberof AttrRecognizer
3101
- */
3102
- defaults: {
3103
- /**
3104
- * @type {Number}
3105
- * @default 1
3106
- */
3107
- pointers: 1
3108
- },
3109
-
3110
- /**
3111
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
3112
- * @memberof AttrRecognizer
3113
- * @param {Object} input
3114
- * @returns {Boolean} recognized
3115
- */
3116
- attrTest: function(input) {
3117
- var optionPointers = this.options.pointers;
3118
- return optionPointers === 0 || input.pointers.length === optionPointers;
3119
- },
3120
-
3121
- /**
3122
- * Process the input and return the state for the recognizer
3123
- * @memberof AttrRecognizer
3124
- * @param {Object} input
3125
- * @returns {*} State
3126
- */
3127
- process: function(input) {
3128
- var state = this.state;
3129
- var eventType = input.eventType;
3130
-
3131
- var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
3132
- var isValid = this.attrTest(input);
3133
-
3134
- // on cancel input and we've recognized before, return STATE_CANCELLED
3135
- if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
3136
- return state | STATE_CANCELLED;
3137
- } else if (isRecognized || isValid) {
3138
- if (eventType & INPUT_END) {
3139
- return state | STATE_ENDED;
3140
- } else if (!(state & STATE_BEGAN)) {
3141
- return STATE_BEGAN;
3142
- }
3143
- return state | STATE_CHANGED;
3144
- }
3145
- return STATE_FAILED;
3146
- }
3147
- });
3148
-
3149
- /**
3150
- * Pan
3151
- * Recognized when the pointer is down and moved in the allowed direction.
3152
- * @constructor
3153
- * @extends AttrRecognizer
3154
- */
3155
- function PanRecognizer() {
3156
- AttrRecognizer.apply(this, arguments);
3157
-
3158
- this.pX = null;
3159
- this.pY = null;
3160
- }
3161
-
3162
- inherit(PanRecognizer, AttrRecognizer, {
3163
- /**
3164
- * @namespace
3165
- * @memberof PanRecognizer
3166
- */
3167
- defaults: {
3168
- event: 'pan',
3169
- threshold: 10,
3170
- pointers: 1,
3171
- direction: DIRECTION_ALL
3172
- },
3173
-
3174
- getTouchAction: function() {
3175
- var direction = this.options.direction;
3176
- var actions = [];
3177
- if (direction & DIRECTION_HORIZONTAL) {
3178
- actions.push(TOUCH_ACTION_PAN_Y);
3179
- }
3180
- if (direction & DIRECTION_VERTICAL) {
3181
- actions.push(TOUCH_ACTION_PAN_X);
3182
- }
3183
- return actions;
3184
- },
3185
-
3186
- directionTest: function(input) {
3187
- var options = this.options;
3188
- var hasMoved = true;
3189
- var distance = input.distance;
3190
- var direction = input.direction;
3191
- var x = input.deltaX;
3192
- var y = input.deltaY;
3193
-
3194
- // lock to axis?
3195
- if (!(direction & options.direction)) {
3196
- if (options.direction & DIRECTION_HORIZONTAL) {
3197
- direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
3198
- hasMoved = x != this.pX;
3199
- distance = Math.abs(input.deltaX);
3200
- } else {
3201
- direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
3202
- hasMoved = y != this.pY;
3203
- distance = Math.abs(input.deltaY);
3204
- }
3205
- }
3206
- input.direction = direction;
3207
- return hasMoved && distance > options.threshold && direction & options.direction;
3208
- },
3209
-
3210
- attrTest: function(input) {
3211
- return AttrRecognizer.prototype.attrTest.call(this, input) &&
3212
- (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
3213
- },
3214
-
3215
- emit: function(input) {
3216
-
3217
- this.pX = input.deltaX;
3218
- this.pY = input.deltaY;
3219
-
3220
- var direction = directionStr(input.direction);
3221
-
3222
- if (direction) {
3223
- input.additionalEvent = this.options.event + direction;
3224
- }
3225
- this._super.emit.call(this, input);
3226
- }
3227
- });
3228
-
3229
- /**
3230
- * Pinch
3231
- * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
3232
- * @constructor
3233
- * @extends AttrRecognizer
3234
- */
3235
- function PinchRecognizer() {
3236
- AttrRecognizer.apply(this, arguments);
3237
- }
3238
-
3239
- inherit(PinchRecognizer, AttrRecognizer, {
3240
- /**
3241
- * @namespace
3242
- * @memberof PinchRecognizer
3243
- */
3244
- defaults: {
3245
- event: 'pinch',
3246
- threshold: 0,
3247
- pointers: 2
3248
- },
3249
-
3250
- getTouchAction: function() {
3251
- return [TOUCH_ACTION_NONE];
3252
- },
3253
-
3254
- attrTest: function(input) {
3255
- return this._super.attrTest.call(this, input) &&
3256
- (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
3257
- },
3258
-
3259
- emit: function(input) {
3260
- if (input.scale !== 1) {
3261
- var inOut = input.scale < 1 ? 'in' : 'out';
3262
- input.additionalEvent = this.options.event + inOut;
3263
- }
3264
- this._super.emit.call(this, input);
3265
- }
3266
- });
3267
-
3268
- /**
3269
- * Press
3270
- * Recognized when the pointer is down for x ms without any movement.
3271
- * @constructor
3272
- * @extends Recognizer
3273
- */
3274
- function PressRecognizer() {
3275
- Recognizer.apply(this, arguments);
3276
-
3277
- this._timer = null;
3278
- this._input = null;
3279
- }
3280
-
3281
- inherit(PressRecognizer, Recognizer, {
3282
- /**
3283
- * @namespace
3284
- * @memberof PressRecognizer
3285
- */
3286
- defaults: {
3287
- event: 'press',
3288
- pointers: 1,
3289
- time: 251, // minimal time of the pointer to be pressed
3290
- threshold: 9 // a minimal movement is ok, but keep it low
3291
- },
3292
-
3293
- getTouchAction: function() {
3294
- return [TOUCH_ACTION_AUTO];
3295
- },
3296
-
3297
- process: function(input) {
3298
- var options = this.options;
3299
- var validPointers = input.pointers.length === options.pointers;
3300
- var validMovement = input.distance < options.threshold;
3301
- var validTime = input.deltaTime > options.time;
3302
-
3303
- this._input = input;
3304
-
3305
- // we only allow little movement
3306
- // and we've reached an end event, so a tap is possible
3307
- if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
3308
- this.reset();
3309
- } else if (input.eventType & INPUT_START) {
3310
- this.reset();
3311
- this._timer = setTimeoutContext(function() {
3312
- this.state = STATE_RECOGNIZED;
3313
- this.tryEmit();
3314
- }, options.time, this);
3315
- } else if (input.eventType & INPUT_END) {
3316
- return STATE_RECOGNIZED;
3317
- }
3318
- return STATE_FAILED;
3319
- },
3320
-
3321
- reset: function() {
3322
- clearTimeout(this._timer);
3323
- },
3324
-
3325
- emit: function(input) {
3326
- if (this.state !== STATE_RECOGNIZED) {
3327
- return;
3328
- }
3329
-
3330
- if (input && (input.eventType & INPUT_END)) {
3331
- this.manager.emit(this.options.event + 'up', input);
3332
- } else {
3333
- this._input.timeStamp = now();
3334
- this.manager.emit(this.options.event, this._input);
3335
- }
3336
- }
3337
- });
3338
-
3339
- /**
3340
- * Rotate
3341
- * Recognized when two or more pointer are moving in a circular motion.
3342
- * @constructor
3343
- * @extends AttrRecognizer
3344
- */
3345
- function RotateRecognizer() {
3346
- AttrRecognizer.apply(this, arguments);
3347
- }
3348
-
3349
- inherit(RotateRecognizer, AttrRecognizer, {
3350
- /**
3351
- * @namespace
3352
- * @memberof RotateRecognizer
3353
- */
3354
- defaults: {
3355
- event: 'rotate',
3356
- threshold: 0,
3357
- pointers: 2
3358
- },
3359
-
3360
- getTouchAction: function() {
3361
- return [TOUCH_ACTION_NONE];
3362
- },
3363
-
3364
- attrTest: function(input) {
3365
- return this._super.attrTest.call(this, input) &&
3366
- (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
3367
- }
3368
- });
3369
-
3370
- /**
3371
- * Swipe
3372
- * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
3373
- * @constructor
3374
- * @extends AttrRecognizer
3375
- */
3376
- function SwipeRecognizer() {
3377
- AttrRecognizer.apply(this, arguments);
3378
- }
3379
-
3380
- inherit(SwipeRecognizer, AttrRecognizer, {
3381
- /**
3382
- * @namespace
3383
- * @memberof SwipeRecognizer
3384
- */
3385
- defaults: {
3386
- event: 'swipe',
3387
- threshold: 10,
3388
- velocity: 0.3,
3389
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
3390
- pointers: 1
3391
- },
3392
-
3393
- getTouchAction: function() {
3394
- return PanRecognizer.prototype.getTouchAction.call(this);
3395
- },
3396
-
3397
- attrTest: function(input) {
3398
- var direction = this.options.direction;
3399
- var velocity;
3400
-
3401
- if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
3402
- velocity = input.overallVelocity;
3403
- } else if (direction & DIRECTION_HORIZONTAL) {
3404
- velocity = input.overallVelocityX;
3405
- } else if (direction & DIRECTION_VERTICAL) {
3406
- velocity = input.overallVelocityY;
3407
- }
3408
-
3409
- return this._super.attrTest.call(this, input) &&
3410
- direction & input.offsetDirection &&
3411
- input.distance > this.options.threshold &&
3412
- input.maxPointers == this.options.pointers &&
3413
- abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
3414
- },
3415
-
3416
- emit: function(input) {
3417
- var direction = directionStr(input.offsetDirection);
3418
- if (direction) {
3419
- this.manager.emit(this.options.event + direction, input);
3420
- }
3421
-
3422
- this.manager.emit(this.options.event, input);
3423
- }
3424
- });
3425
-
3426
- /**
3427
- * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
3428
- * between the given interval and position. The delay option can be used to recognize multi-taps without firing
3429
- * a single tap.
3430
- *
3431
- * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
3432
- * multi-taps being recognized.
3433
- * @constructor
3434
- * @extends Recognizer
3435
- */
3436
- function TapRecognizer() {
3437
- Recognizer.apply(this, arguments);
3438
-
3439
- // previous time and center,
3440
- // used for tap counting
3441
- this.pTime = false;
3442
- this.pCenter = false;
3443
-
3444
- this._timer = null;
3445
- this._input = null;
3446
- this.count = 0;
3447
- }
3448
-
3449
- inherit(TapRecognizer, Recognizer, {
3450
- /**
3451
- * @namespace
3452
- * @memberof PinchRecognizer
3453
- */
3454
- defaults: {
3455
- event: 'tap',
3456
- pointers: 1,
3457
- taps: 1,
3458
- interval: 300, // max time between the multi-tap taps
3459
- time: 250, // max time of the pointer to be down (like finger on the screen)
3460
- threshold: 9, // a minimal movement is ok, but keep it low
3461
- posThreshold: 10 // a multi-tap can be a bit off the initial position
3462
- },
3463
-
3464
- getTouchAction: function() {
3465
- return [TOUCH_ACTION_MANIPULATION];
3466
- },
3467
-
3468
- process: function(input) {
3469
- var options = this.options;
3470
-
3471
- var validPointers = input.pointers.length === options.pointers;
3472
- var validMovement = input.distance < options.threshold;
3473
- var validTouchTime = input.deltaTime < options.time;
3474
-
3475
- this.reset();
3476
-
3477
- if ((input.eventType & INPUT_START) && (this.count === 0)) {
3478
- return this.failTimeout();
3479
- }
3480
-
3481
- // we only allow little movement
3482
- // and we've reached an end event, so a tap is possible
3483
- if (validMovement && validTouchTime && validPointers) {
3484
- if (input.eventType != INPUT_END) {
3485
- return this.failTimeout();
3486
- }
3487
-
3488
- var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
3489
- var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
3490
-
3491
- this.pTime = input.timeStamp;
3492
- this.pCenter = input.center;
3493
-
3494
- if (!validMultiTap || !validInterval) {
3495
- this.count = 1;
3496
- } else {
3497
- this.count += 1;
3498
- }
3499
-
3500
- this._input = input;
3501
-
3502
- // if tap count matches we have recognized it,
3503
- // else it has began recognizing...
3504
- var tapCount = this.count % options.taps;
3505
- if (tapCount === 0) {
3506
- // no failing requirements, immediately trigger the tap event
3507
- // or wait as long as the multitap interval to trigger
3508
- if (!this.hasRequireFailures()) {
3509
- return STATE_RECOGNIZED;
3510
- } else {
3511
- this._timer = setTimeoutContext(function() {
3512
- this.state = STATE_RECOGNIZED;
3513
- this.tryEmit();
3514
- }, options.interval, this);
3515
- return STATE_BEGAN;
3516
- }
3517
- }
3518
- }
3519
- return STATE_FAILED;
3520
- },
3521
-
3522
- failTimeout: function() {
3523
- this._timer = setTimeoutContext(function() {
3524
- this.state = STATE_FAILED;
3525
- }, this.options.interval, this);
3526
- return STATE_FAILED;
3527
- },
3528
-
3529
- reset: function() {
3530
- clearTimeout(this._timer);
3531
- },
3532
-
3533
- emit: function() {
3534
- if (this.state == STATE_RECOGNIZED) {
3535
- this._input.tapCount = this.count;
3536
- this.manager.emit(this.options.event, this._input);
3537
- }
3538
- }
3539
- });
3540
-
3541
- /**
3542
- * Simple way to create a manager with a default set of recognizers.
3543
- * @param {HTMLElement} element
3544
- * @param {Object} [options]
3545
- * @constructor
3546
- */
3547
- function Hammer(element, options) {
3548
- options = options || {};
3549
- options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
3550
- return new Manager(element, options);
3551
- }
3552
-
3553
- /**
3554
- * @const {string}
3555
- */
3556
- Hammer.VERSION = '2.0.7';
3557
-
3558
- /**
3559
- * default settings
3560
- * @namespace
3561
- */
3562
- Hammer.defaults = {
3563
- /**
3564
- * set if DOM events are being triggered.
3565
- * But this is slower and unused by simple implementations, so disabled by default.
3566
- * @type {Boolean}
3567
- * @default false
3568
- */
3569
- domEvents: false,
3570
-
3571
- /**
3572
- * The value for the touchAction property/fallback.
3573
- * When set to `compute` it will magically set the correct value based on the added recognizers.
3574
- * @type {String}
3575
- * @default compute
3576
- */
3577
- touchAction: TOUCH_ACTION_COMPUTE,
3578
-
3579
- /**
3580
- * @type {Boolean}
3581
- * @default true
3582
- */
3583
- enable: true,
3584
-
3585
- /**
3586
- * EXPERIMENTAL FEATURE -- can be removed/changed
3587
- * Change the parent input target element.
3588
- * If Null, then it is being set the to main element.
3589
- * @type {Null|EventTarget}
3590
- * @default null
3591
- */
3592
- inputTarget: null,
3593
-
3594
- /**
3595
- * force an input class
3596
- * @type {Null|Function}
3597
- * @default null
3598
- */
3599
- inputClass: null,
3600
-
3601
- /**
3602
- * Default recognizer setup when calling `Hammer()`
3603
- * When creating a new Manager these will be skipped.
3604
- * @type {Array}
3605
- */
3606
- preset: [
3607
- // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
3608
- [RotateRecognizer, {enable: false}],
3609
- [PinchRecognizer, {enable: false}, ['rotate']],
3610
- [SwipeRecognizer, {direction: DIRECTION_HORIZONTAL}],
3611
- [PanRecognizer, {direction: DIRECTION_HORIZONTAL}, ['swipe']],
3612
- [TapRecognizer],
3613
- [TapRecognizer, {event: 'doubletap', taps: 2}, ['tap']],
3614
- [PressRecognizer]
3615
- ],
3616
-
3617
- /**
3618
- * Some CSS properties can be used to improve the working of Hammer.
3619
- * Add them to this method and they will be set when creating a new Manager.
3620
- * @namespace
3621
- */
3622
- cssProps: {
3623
- /**
3624
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
3625
- * @type {String}
3626
- * @default 'none'
3627
- */
3628
- userSelect: 'none',
3629
-
3630
- /**
3631
- * Disable the Windows Phone grippers when pressing an element.
3632
- * @type {String}
3633
- * @default 'none'
3634
- */
3635
- touchSelect: 'none',
3636
-
3637
- /**
3638
- * Disables the default callout shown when you touch and hold a touch target.
3639
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
3640
- * a callout containing information about the link. This property allows you to disable that callout.
3641
- * @type {String}
3642
- * @default 'none'
3643
- */
3644
- touchCallout: 'none',
3645
-
3646
- /**
3647
- * Specifies whether zooming is enabled. Used by IE10>
3648
- * @type {String}
3649
- * @default 'none'
3650
- */
3651
- contentZooming: 'none',
3652
-
3653
- /**
3654
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
3655
- * @type {String}
3656
- * @default 'none'
3657
- */
3658
- userDrag: 'none',
3659
-
3660
- /**
3661
- * Overrides the highlight color shown when the user taps a link or a JavaScript
3662
- * clickable element in iOS. This property obeys the alpha value, if specified.
3663
- * @type {String}
3664
- * @default 'rgba(0,0,0,0)'
3665
- */
3666
- tapHighlightColor: 'rgba(0,0,0,0)'
3667
- }
3668
- };
3669
-
3670
- var STOP = 1;
3671
- var FORCED_STOP = 2;
3672
-
3673
- /**
3674
- * Manager
3675
- * @param {HTMLElement} element
3676
- * @param {Object} [options]
3677
- * @constructor
3678
- */
3679
- function Manager(element, options) {
3680
- this.options = assign({}, Hammer.defaults, options || {});
3681
-
3682
- this.options.inputTarget = this.options.inputTarget || element;
3683
-
3684
- this.handlers = {};
3685
- this.session = {};
3686
- this.recognizers = [];
3687
- this.oldCssProps = {};
3688
-
3689
- this.element = element;
3690
- this.input = createInputInstance(this);
3691
- this.touchAction = new TouchAction(this, this.options.touchAction);
3692
-
3693
- toggleCssProps(this, true);
3694
-
3695
- each(this.options.recognizers, function(item) {
3696
- var recognizer = this.add(new (item[0])(item[1]));
3697
- item[2] && recognizer.recognizeWith(item[2]);
3698
- item[3] && recognizer.requireFailure(item[3]);
3699
- }, this);
3700
- }
3701
-
3702
- Manager.prototype = {
3703
- /**
3704
- * set options
3705
- * @param {Object} options
3706
- * @returns {Manager}
3707
- */
3708
- set: function(options) {
3709
- assign(this.options, options);
3710
-
3711
- // Options that need a little more setup
3712
- if (options.touchAction) {
3713
- this.touchAction.update();
3714
- }
3715
- if (options.inputTarget) {
3716
- // Clean up existing event listeners and reinitialize
3717
- this.input.destroy();
3718
- this.input.target = options.inputTarget;
3719
- this.input.init();
3720
- }
3721
- return this;
3722
- },
3723
-
3724
- /**
3725
- * stop recognizing for this session.
3726
- * This session will be discarded, when a new [input]start event is fired.
3727
- * When forced, the recognizer cycle is stopped immediately.
3728
- * @param {Boolean} [force]
3729
- */
3730
- stop: function(force) {
3731
- this.session.stopped = force ? FORCED_STOP : STOP;
3732
- },
3733
-
3734
- /**
3735
- * run the recognizers!
3736
- * called by the inputHandler function on every movement of the pointers (touches)
3737
- * it walks through all the recognizers and tries to detect the gesture that is being made
3738
- * @param {Object} inputData
3739
- */
3740
- recognize: function(inputData) {
3741
- var session = this.session;
3742
- if (session.stopped) {
3743
- return;
3744
- }
3745
-
3746
- // run the touch-action polyfill
3747
- this.touchAction.preventDefaults(inputData);
3748
-
3749
- var recognizer;
3750
- var recognizers = this.recognizers;
3751
-
3752
- // this holds the recognizer that is being recognized.
3753
- // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
3754
- // if no recognizer is detecting a thing, it is set to `null`
3755
- var curRecognizer = session.curRecognizer;
3756
-
3757
- // reset when the last recognizer is recognized
3758
- // or when we're in a new session
3759
- if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
3760
- curRecognizer = session.curRecognizer = null;
3761
- }
3762
-
3763
- var i = 0;
3764
- while (i < recognizers.length) {
3765
- recognizer = recognizers[i];
3766
-
3767
- // find out if we are allowed try to recognize the input for this one.
3768
- // 1. allow if the session is NOT forced stopped (see the .stop() method)
3769
- // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
3770
- // that is being recognized.
3771
- // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
3772
- // this can be setup with the `recognizeWith()` method on the recognizer.
3773
- if (session.stopped !== FORCED_STOP && ( // 1
3774
- !curRecognizer || recognizer == curRecognizer || // 2
3775
- recognizer.canRecognizeWith(curRecognizer))) { // 3
3776
- recognizer.recognize(inputData);
3777
- } else {
3778
- recognizer.reset();
3779
- }
3780
-
3781
- // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
3782
- // current active recognizer. but only if we don't already have an active recognizer
3783
- if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
3784
- curRecognizer = session.curRecognizer = recognizer;
3785
- }
3786
- i++;
3787
- }
3788
- },
3789
-
3790
- /**
3791
- * get a recognizer by its event name.
3792
- * @param {Recognizer|String} recognizer
3793
- * @returns {Recognizer|Null}
3794
- */
3795
- get: function(recognizer) {
3796
- if (recognizer instanceof Recognizer) {
3797
- return recognizer;
3798
- }
3799
-
3800
- var recognizers = this.recognizers;
3801
- for (var i = 0; i < recognizers.length; i++) {
3802
- if (recognizers[i].options.event == recognizer) {
3803
- return recognizers[i];
3804
- }
3805
- }
3806
- return null;
3807
- },
3808
-
3809
- /**
3810
- * add a recognizer to the manager
3811
- * existing recognizers with the same event name will be removed
3812
- * @param {Recognizer} recognizer
3813
- * @returns {Recognizer|Manager}
3814
- */
3815
- add: function(recognizer) {
3816
- if (invokeArrayArg(recognizer, 'add', this)) {
3817
- return this;
3818
- }
3819
-
3820
- // remove existing
3821
- var existing = this.get(recognizer.options.event);
3822
- if (existing) {
3823
- this.remove(existing);
3824
- }
3825
-
3826
- this.recognizers.push(recognizer);
3827
- recognizer.manager = this;
3828
-
3829
- this.touchAction.update();
3830
- return recognizer;
3831
- },
3832
-
3833
- /**
3834
- * remove a recognizer by name or instance
3835
- * @param {Recognizer|String} recognizer
3836
- * @returns {Manager}
3837
- */
3838
- remove: function(recognizer) {
3839
- if (invokeArrayArg(recognizer, 'remove', this)) {
3840
- return this;
3841
- }
3842
-
3843
- recognizer = this.get(recognizer);
3844
-
3845
- // let's make sure this recognizer exists
3846
- if (recognizer) {
3847
- var recognizers = this.recognizers;
3848
- var index = inArray(recognizers, recognizer);
3849
-
3850
- if (index !== -1) {
3851
- recognizers.splice(index, 1);
3852
- this.touchAction.update();
3853
- }
3854
- }
3855
-
3856
- return this;
3857
- },
3858
-
3859
- /**
3860
- * bind event
3861
- * @param {String} events
3862
- * @param {Function} handler
3863
- * @returns {EventEmitter} this
3864
- */
3865
- on: function(events, handler) {
3866
- if (events === undefined$1) {
3867
- return;
3868
- }
3869
- if (handler === undefined$1) {
3870
- return;
3871
- }
3872
-
3873
- var handlers = this.handlers;
3874
- each(splitStr(events), function(event) {
3875
- handlers[event] = handlers[event] || [];
3876
- handlers[event].push(handler);
3877
- });
3878
- return this;
3879
- },
3880
-
3881
- /**
3882
- * unbind event, leave emit blank to remove all handlers
3883
- * @param {String} events
3884
- * @param {Function} [handler]
3885
- * @returns {EventEmitter} this
3886
- */
3887
- off: function(events, handler) {
3888
- if (events === undefined$1) {
3889
- return;
3890
- }
3891
-
3892
- var handlers = this.handlers;
3893
- each(splitStr(events), function(event) {
3894
- if (!handler) {
3895
- delete handlers[event];
3896
- } else {
3897
- handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
3898
- }
3899
- });
3900
- return this;
3901
- },
3902
-
3903
- /**
3904
- * emit event to the listeners
3905
- * @param {String} event
3906
- * @param {Object} data
3907
- */
3908
- emit: function(event, data) {
3909
- // we also want to trigger dom events
3910
- if (this.options.domEvents) {
3911
- triggerDomEvent(event, data);
3912
- }
3913
-
3914
- // no handlers, so skip it all
3915
- var handlers = this.handlers[event] && this.handlers[event].slice();
3916
- if (!handlers || !handlers.length) {
3917
- return;
3918
- }
3919
-
3920
- data.type = event;
3921
- data.preventDefault = function() {
3922
- data.srcEvent.preventDefault();
3923
- };
3924
-
3925
- var i = 0;
3926
- while (i < handlers.length) {
3927
- handlers[i](data);
3928
- i++;
3929
- }
3930
- },
3931
-
3932
- /**
3933
- * destroy the manager and unbinds all events
3934
- * it doesn't unbind dom events, that is the user own responsibility
3935
- */
3936
- destroy: function() {
3937
- this.element && toggleCssProps(this, false);
3938
-
3939
- this.handlers = {};
3940
- this.session = {};
3941
- this.input.destroy();
3942
- this.element = null;
3943
- }
3944
- };
3945
-
3946
- /**
3947
- * add/remove the css properties as defined in manager.options.cssProps
3948
- * @param {Manager} manager
3949
- * @param {Boolean} add
3950
- */
3951
- function toggleCssProps(manager, add) {
3952
- var element = manager.element;
3953
- if (!element.style) {
3954
- return;
3955
- }
3956
- var prop;
3957
- each(manager.options.cssProps, function(value, name) {
3958
- prop = prefixed(element.style, name);
3959
- if (add) {
3960
- manager.oldCssProps[prop] = element.style[prop];
3961
- element.style[prop] = value;
3962
- } else {
3963
- element.style[prop] = manager.oldCssProps[prop] || '';
3964
- }
3965
- });
3966
- if (!add) {
3967
- manager.oldCssProps = {};
3968
- }
3969
- }
3970
-
3971
- /**
3972
- * trigger dom event
3973
- * @param {String} event
3974
- * @param {Object} data
3975
- */
3976
- function triggerDomEvent(event, data) {
3977
- var gestureEvent = document.createEvent('Event');
3978
- gestureEvent.initEvent(event, true, true);
3979
- gestureEvent.gesture = data;
3980
- data.target.dispatchEvent(gestureEvent);
3981
- }
3982
-
3983
- assign(Hammer, {
3984
- INPUT_START: INPUT_START,
3985
- INPUT_MOVE: INPUT_MOVE,
3986
- INPUT_END: INPUT_END,
3987
- INPUT_CANCEL: INPUT_CANCEL,
3988
-
3989
- STATE_POSSIBLE: STATE_POSSIBLE,
3990
- STATE_BEGAN: STATE_BEGAN,
3991
- STATE_CHANGED: STATE_CHANGED,
3992
- STATE_ENDED: STATE_ENDED,
3993
- STATE_RECOGNIZED: STATE_RECOGNIZED,
3994
- STATE_CANCELLED: STATE_CANCELLED,
3995
- STATE_FAILED: STATE_FAILED,
3996
-
3997
- DIRECTION_NONE: DIRECTION_NONE,
3998
- DIRECTION_LEFT: DIRECTION_LEFT,
3999
- DIRECTION_RIGHT: DIRECTION_RIGHT,
4000
- DIRECTION_UP: DIRECTION_UP,
4001
- DIRECTION_DOWN: DIRECTION_DOWN,
4002
- DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
4003
- DIRECTION_VERTICAL: DIRECTION_VERTICAL,
4004
- DIRECTION_ALL: DIRECTION_ALL,
4005
-
4006
- Manager: Manager,
4007
- Input: Input,
4008
- TouchAction: TouchAction,
4009
-
4010
- TouchInput: TouchInput,
4011
- MouseInput: MouseInput,
4012
- PointerEventInput: PointerEventInput,
4013
- TouchMouseInput: TouchMouseInput,
4014
- SingleTouchInput: SingleTouchInput,
4015
-
4016
- Recognizer: Recognizer,
4017
- AttrRecognizer: AttrRecognizer,
4018
- Tap: TapRecognizer,
4019
- Pan: PanRecognizer,
4020
- Swipe: SwipeRecognizer,
4021
- Pinch: PinchRecognizer,
4022
- Rotate: RotateRecognizer,
4023
- Press: PressRecognizer,
4024
-
4025
- on: addEventListeners,
4026
- off: removeEventListeners,
4027
- each: each,
4028
- merge: merge,
4029
- extend: extend,
4030
- assign: assign,
4031
- inherit: inherit,
4032
- bindFn: bindFn,
4033
- prefixed: prefixed
4034
- });
4035
-
4036
- // this prevents errors when Hammer is loaded in the presence of an AMD
4037
- // style loader but by script tag, not by the loader.
4038
- var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
4039
- freeGlobal.Hammer = Hammer;
4040
-
4041
- if (module.exports) {
4042
- module.exports = Hammer;
4043
- } else {
4044
- window[exportName] = Hammer;
4045
- }
4046
-
4047
- })(window, document, 'Hammer');
4048
- } (hammer));
4049
- return hammer.exports;
4050
- }
4051
-
4052
- var hammerExports = requireHammer();
4053
- var Hammer = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(hammerExports);
4054
-
4055
1402
  const stylesCss = () => `:host{--percentuale:0;display:flex;width:100%;min-width:200px;max-width:100dvw;box-sizing:border-box;background:var(--color-surface01);border-radius:var(--border-size-large);box-shadow:var(--shadow-3);color:var(--color-default-text);fill:var(--color-primary01-icon);font-family:var(--font-family-sans);font-size:var(--font-size-2);font-weight:var(--font-rg)}:host(.slide-in-left){animation:slideinleft 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-right){animation:slideinright 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-down){animation:slideindown 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-in-up){animation:slideinup 1s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-left){animation:slideoutleft 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-right){animation:slideoutright 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-down){animation:slideoutdown 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}:host(.slide-out-up){animation:slideoutup 0.5s cubic-bezier(0.25, 0.1, 0.25, 0.1);animation-fill-mode:forwards}.toast-notification-container{display:flex;width:100%;align-items:baseline;justify-content:space-between;padding:calc(var(--space-unit) * 2);border-radius:var(--border-radius);gap:calc(var(--space-unit) * 2)}.toast-notification-content{display:flex;width:100%;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:calc(var(--space-unit) * 2)}.toast-notification-content .toast-notification-text{color:inherit;letter-spacing:0.16px;line-height:1.25rem}.toast-notification-content .toast-notification-text .title{margin-right:calc(var(--space-unit) / 2);font-weight:var(--font-sb)}.close-button{height:1.125rem;padding:0;border:none;background-color:transparent;cursor:pointer}.close-button z-icon{--z-icon-width:1.125rem;--z-icon-height:1.125rem;display:inline-block;height:1.25rem}.close-button:focus:focus-visible{border-radius:50%;box-shadow:var(--shadow-focus-primary);outline:none}:host(.dark){background:var(--color-surface05);color:var(--color-text-inverse);fill:var(--color-inverse-icon)}:host(.dark) .close-button:focus:focus-visible{box-shadow:0 0 0 2px var(--gray900), 0 0 2px 5px var(--blue25)}:host(.accent){background:var(--color-primary01)}:host(.error){background:var(--color-default-error)}:host(.success){background:var(--color-default-success)}:host(.warning){background:var(--color-default-warning)}:host(.accent),:host(.error),:host(.success){color:var(--color-text-inverse);fill:var(--color-inverse-icon)}:host(.warning) .close-button{fill:var(--color-default-icon)}@media (min-width: 768px){:host{width:fit-content;max-width:50vw}.toast-notification-content{flex-wrap:nowrap}}@media (min-width: 1366px){:host{max-width:33vw}}@keyframes slideinleft{0%{transform:translateX(100%)}100%{transform:translateX(0)}}@keyframes slideinright{0%{transform:translateX(-100%)}100%{transform:translateX(0)}}@keyframes slideinup{0%{opacity:0;transform:translateY(100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideindown{0%{opacity:0;transform:translateY(-100%)}100%{opacity:1;transform:translateY(0)}}@keyframes slideoutleft{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(-100%)}}@keyframes slideoutright{0%{opacity:calc(100% - var(--percentuale));transform:translateX(var(--percentuale))}100%{opacity:0;transform:translateX(100%)}}@keyframes slideoutup{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(-100%)}}@keyframes slideoutdown{0%{opacity:1;transform:translateY(var(--percentuale))}100%{opacity:0;transform:translateY(100%)}}`;
4056
1403
 
4057
1404
  /** Map of slide-in transitions to their corresponding slide-out transitions */
@@ -4128,7 +1475,10 @@ const ZToastNotification = class {
4128
1475
  const bounding = this.hostElement.getBoundingClientRect();
4129
1476
  return Math.round((100 * e.deltaX) / bounding.width);
4130
1477
  }
4131
- handleSlideOutDragAnimation() {
1478
+ async handleSlideOutDragAnimation() {
1479
+ /* imported dynamically so its browser-only, module-level side effects (e.g. reading `window`/`document`
1480
+ at the top of its UMD wrapper) never run at module-evaluation time in non-browser environments (e.g. Next.js SSR) */
1481
+ const { default: Hammer } = await Promise.resolve().then(function () { return require('./hammer-CJF2Ixtg.js'); }).then(function (n) { return n.hammer; });
4132
1482
  this.sliderManager = new Hammer(this.hostElement);
4133
1483
  this.sliderManager.get("pan").set({
4134
1484
  direction: Hammer.DIRECTION_HORIZONTAL,
@@ -4200,19 +1550,19 @@ const ZToastNotification = class {
4200
1550
  }
4201
1551
  }
4202
1552
  render() {
4203
- return (index.h(index.Host, { key: '129c4628c3809f638a02596bff82f4a5700ae566', style: { "--percentuale": `${this.percentage}%` }, class: { [this.transition]: !!this.transition, [this.type]: !!this.type }, onAnimationEnd: (e) => {
1553
+ return (index.h(index.Host, { key: 'c014f617bd53be486dda1fa2172130ef9be592a0', style: { "--percentuale": `${this.percentage}%` }, class: { [this.transition]: !!this.transition, [this.type]: !!this.type }, onAnimationEnd: (e) => {
4204
1554
  if (this.autoclose && e.animationName.includes("slidein")) {
4205
1555
  this.startClosingTimeout(this.autoclose);
4206
1556
  }
4207
1557
  if (e.animationName.includes("slideout")) {
4208
1558
  this.hostElement.parentNode.removeChild(this.hostElement);
4209
1559
  }
4210
- } }, index.h("div", { key: '39360c2661ac44f4e3e8ae25aceccaea8179a03e', class: "toast-notification-container" }, index.h("div", { key: '6778d83e83590f5981ff9dfb5fbb8fbe92143404', class: "toast-notification-content" }, index.h("div", { key: '896d9bb0c412381f9ad81c799666dd54503a50b0', class: "toast-notification-text" }, this.heading && index.h("span", { key: 'a431608d859dede1cc17e840ebf2e01b872a1d48', class: "title" }, this.heading), index.h("span", { key: '23f29016f7eb04790a6adf136b0e064f5f2d87d9', class: "message" }, index.h("slot", { key: 'a793b4e4fee43ad139f0eef51ec1ed1a6cd5c31f', name: "message" }, this.message && index.h("span", { key: 'fc84e8b14208ff6d150dfea28924387f845cb371', innerHTML: purify.sanitize(this.message) })))), index.h("div", { key: '475e54939682a3b7bba6032a92bd04b8a21772b3', class: "button-container", hidden: !this.hasSlottedButton }, index.h("slot", { key: 'e9bd0b4e65504476b59a97dcf82b233b5259bc00', name: "button", onSlotchange: () => this.checkSlottedButton() }))), this.closebutton && (index.h("button", { key: '14b143ec8e4d8e02b039d01464532ba25bcc2bea', class: "close-button", "aria-label": "Chiudi notifica", onClick: () => this.close(SLIDE_OUT_TRANSITION_MAP[this.transition], true), onKeyDown: (e) => {
1560
+ } }, index.h("div", { key: '2b0fc9855f7bc18b53993d86f57cd89b42c978a6', class: "toast-notification-container" }, index.h("div", { key: '5c8b59419b7681de8f53f91008da3b518f50aa8d', class: "toast-notification-content" }, index.h("div", { key: '529a5f030878dcd0bd5af77de5b173bca605ce6b', class: "toast-notification-text" }, this.heading && index.h("span", { key: '6d3f35baedee97f6dcfa724cf2a8c6e2fa2c0bd2', class: "title" }, this.heading), index.h("span", { key: '436716a867110db25aaf9be5904a3569d4eba6a7', class: "message" }, index.h("slot", { key: '495e77fd7d36993fbef8294aa53b7be36a9b36e8', name: "message" }, this.message && index.h("span", { key: '7444baa70ab2c51685f4d715d5613bf35722b7dd', innerHTML: purify.sanitize(this.message) })))), index.h("div", { key: '73b62f17af82468596a4c6156b8135d80f3db370', class: "button-container", hidden: !this.hasSlottedButton }, index.h("slot", { key: '085054eff600b85556771740734f17ceab8d769a', name: "button", onSlotchange: () => this.checkSlottedButton() }))), this.closebutton && (index.h("button", { key: '3145c42f74cabd0d29fc14840dbdcc7afeee6e83', class: "close-button", "aria-label": "Chiudi notifica", onClick: () => this.close(SLIDE_OUT_TRANSITION_MAP[this.transition], true), onKeyDown: (e) => {
4211
1561
  if (e.code == index$1.KeyboardCode.SPACE || e.code == index$1.KeyboardCode.ENTER) {
4212
1562
  e.preventDefault();
4213
1563
  this.close(SLIDE_OUT_TRANSITION_MAP[this.transition], true);
4214
1564
  }
4215
- } }, index.h("z-icon", { key: '4870673eb2e49f6dbd06788a3b279daaa8236ab6', name: "multiply-circled" }))))));
1565
+ } }, index.h("z-icon", { key: '0eb747dd65066e371130dbe79a41cecdedcdbe87', name: "multiply-circled" }))))));
4216
1566
  }
4217
1567
  get hostElement() { return index.getElement(this); }
4218
1568
  static get watchers() { return {