@karmo-co/drift-kit-public 25.30.0 → 25.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/components.js CHANGED
@@ -1722,6 +1722,101 @@
1722
1722
  start();
1723
1723
  })();
1724
1724
  })(typeof window !== 'undefined' ? window : undefined);
1725
+ (function (w) {
1726
+ if (!w)
1727
+ return;
1728
+ var d = (w.dk = w.dk || {});
1729
+ d.__loaded = d.__loaded || {};
1730
+ if (d.__loaded['kit/press.js'])
1731
+ return;
1732
+ d.__loaded['kit/press.js'] = true;
1733
+ (function () {
1734
+ 'use strict';
1735
+ if (typeof window === 'undefined' || typeof document === 'undefined')
1736
+ return;
1737
+ var dk = (window.dk = window.dk || {});
1738
+ dk.interactive = dk.interactive || {};
1739
+ if (dk.interactive.press)
1740
+ return;
1741
+ var ROOT = document.documentElement;
1742
+ var GATE = 'data-dk-press', MARK = 'data-dk-pressed';
1743
+ var SLOP = 10;
1744
+ var mq = window.matchMedia ? window.matchMedia('(hover: none)') : null;
1745
+ function sync() {
1746
+ if (mq && mq.matches)
1747
+ ROOT.setAttribute(GATE, '');
1748
+ else
1749
+ ROOT.removeAttribute(GATE);
1750
+ }
1751
+ sync();
1752
+ if (mq) {
1753
+ if (mq.addEventListener)
1754
+ mq.addEventListener('change', sync);
1755
+ else if (mq.addListener)
1756
+ mq.addListener(sync);
1757
+ }
1758
+ function ms(name, fallback) {
1759
+ var v = getComputedStyle(ROOT).getPropertyValue(name).trim();
1760
+ var n = parseFloat(v);
1761
+ if (isNaN(n))
1762
+ return fallback;
1763
+ return /ms$/.test(v) ? n : /s$/.test(v) ? n * 1000 : n;
1764
+ }
1765
+ var cur = null;
1766
+ function mark(c, on) {
1767
+ for (var i = 0; i < c.chain.length; i++) {
1768
+ if (on)
1769
+ c.chain[i].setAttribute(MARK, '');
1770
+ else
1771
+ c.chain[i].removeAttribute(MARK);
1772
+ }
1773
+ }
1774
+ function drop(c) { clearTimeout(c.timer); clearTimeout(c.lift); mark(c, false); }
1775
+ function cancel() { if (cur) {
1776
+ drop(cur);
1777
+ cur = null;
1778
+ } }
1779
+ document.addEventListener('pointerdown', function (e) {
1780
+ if (e.pointerType !== 'touch' || !ROOT.hasAttribute(GATE))
1781
+ return;
1782
+ cancel();
1783
+ var t = e.target && e.target.nodeType === 1 ? e.target : e.target && e.target.parentElement;
1784
+ if (!t)
1785
+ return;
1786
+ var chain = [];
1787
+ for (var el = t; el && el !== ROOT && el.nodeType === 1; el = el.parentElement)
1788
+ chain.push(el);
1789
+ var c = cur = { id: e.pointerId, x: e.clientX, y: e.clientY, chain: chain, shown: false };
1790
+ c.timer = setTimeout(function () { if (cur === c) {
1791
+ c.shown = true;
1792
+ mark(c, true);
1793
+ } }, ms('--dk-interactive-press-delay-touch', 120));
1794
+ }, { capture: true, passive: true });
1795
+ document.addEventListener('pointermove', function (e) {
1796
+ if (!cur || e.pointerId !== cur.id)
1797
+ return;
1798
+ if (Math.abs(e.clientX - cur.x) > SLOP || Math.abs(e.clientY - cur.y) > SLOP)
1799
+ cancel();
1800
+ }, { capture: true, passive: true });
1801
+ document.addEventListener('pointercancel', function (e) { if (cur && e.pointerId === cur.id)
1802
+ cancel(); }, true);
1803
+ document.addEventListener('scroll', cancel, { capture: true, passive: true });
1804
+ document.addEventListener('pointerup', function (e) {
1805
+ if (!cur || e.pointerId !== cur.id)
1806
+ return;
1807
+ var c = cur;
1808
+ cur = null;
1809
+ clearTimeout(c.timer);
1810
+ if (c.shown) {
1811
+ mark(c, false);
1812
+ return;
1813
+ }
1814
+ mark(c, true);
1815
+ c.lift = setTimeout(function () { mark(c, false); }, ms('--dk-motion-press-duration', 100));
1816
+ }, true);
1817
+ dk.interactive.press = { cancel: cancel };
1818
+ })();
1819
+ })(typeof window !== 'undefined' ? window : undefined);
1725
1820
  (function (w) {
1726
1821
  if (!w)
1727
1822
  return;