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

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