@wix/interact 2.2.1 → 2.2.2

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.
@@ -9,7 +9,7 @@ function C(t, e) {
9
9
  return r !== void 0 ? `[${r}]` : "[]";
10
10
  }) : t;
11
11
  }
12
- class N {
12
+ class G {
13
13
  animations;
14
14
  options;
15
15
  ready;
@@ -253,7 +253,7 @@ function He(t) {
253
253
  const e = we[t];
254
254
  return e || (qt(t) ?? xt(t) ?? we.linear);
255
255
  }
256
- class Mt extends N {
256
+ class Mt extends G {
257
257
  animationGroups;
258
258
  delay;
259
259
  offset;
@@ -636,7 +636,7 @@ function L(t, e) {
636
636
  function zt(t, e) {
637
637
  return t?.matches(`[data-motion-part~="${e}"]`) ? t : t?.querySelector(`[data-motion-part~="${e}"]`);
638
638
  }
639
- function Dt(t) {
639
+ function Nt(t) {
640
640
  const e = t.alternate ? "alternate" : "";
641
641
  return t.reversed ? `${e ? `${e}-` : ""}reverse` : e || "normal";
642
642
  }
@@ -646,7 +646,7 @@ function re(t) {
646
646
  function Ie(t, e, n) {
647
647
  return `${t.name || "cover"} ${n && t.offset.unit !== "percentage" ? `calc(100% + ${re(t.offset)}${e ? ` + ${e}` : ""})` : e ? `calc(${re(t.offset)} + ${e})` : re(t.offset)}`;
648
648
  }
649
- function Gt(t) {
649
+ function Dt(t) {
650
650
  return {
651
651
  start: Ie(t.startOffset, t.startOffsetAdd),
652
652
  end: Ie(t.endOffset, t.endOffsetAdd, !0)
@@ -655,7 +655,7 @@ function Gt(t) {
655
655
  function ze(t) {
656
656
  return (e) => I.measure(() => e(t));
657
657
  }
658
- function De(t) {
658
+ function Ne(t) {
659
659
  return (e) => I.mutate(() => e(t));
660
660
  }
661
661
  function Z(t) {
@@ -675,16 +675,16 @@ function Z(t) {
675
675
  return (e) => [{ ...e, keyframes: [] }];
676
676
  return null;
677
677
  }
678
- function Nt(t, e, n) {
678
+ function Gt(t, e, n) {
679
679
  return t.map((s, r) => {
680
680
  const i = {
681
681
  fill: s.fill,
682
682
  easing: Q(s.easing),
683
683
  iterations: s.iterations === 0 ? 1 / 0 : s.iterations || 1,
684
684
  composite: s.composite,
685
- direction: Dt(s)
685
+ direction: Nt(s)
686
686
  };
687
- return Ge(e) ? (i.duration = s.duration, i.delay = s.delay || 0) : window.ViewTimeline && e?.trigger === "view-progress" ? i.duration = "auto" : (i.duration = 99.99, i.delay = 0.01), {
687
+ return De(e) ? (i.duration = s.duration, i.delay = s.delay || 0) : window.ViewTimeline && e?.trigger === "view-progress" ? i.duration = "auto" : (i.duration = 99.99, i.delay = 0.01), {
688
688
  effect: s,
689
689
  options: i,
690
690
  id: n && `${n}-${r + 1}`,
@@ -692,18 +692,18 @@ function Nt(t, e, n) {
692
692
  };
693
693
  });
694
694
  }
695
- function Ge(t) {
695
+ function De(t) {
696
696
  return !t || t.trigger !== "pointer-move" && t.trigger !== "view-progress";
697
697
  }
698
698
  function Oe(t, e, n, s, r) {
699
699
  if (t) {
700
- if (Ge(s) && (e.duration = e.duration || 1, r?.reducedMotion))
700
+ if (De(s) && (e.duration = e.duration || 1, r?.reducedMotion))
701
701
  if (e.iterations === 1 || e.iterations == null)
702
702
  e = { ...e, duration: 1 };
703
703
  else
704
704
  return [];
705
705
  let i;
706
- return n instanceof HTMLElement && (i = { measure: ze(n), mutate: De(n) }), t.web ? t.web(e, i, r) : t(e, i, r);
706
+ return n instanceof HTMLElement && (i = { measure: ze(n), mutate: Ne(n) }), t.web ? t.web(e, i, r) : t(e, i, r);
707
707
  }
708
708
  return [];
709
709
  }
@@ -735,7 +735,7 @@ function ve(t, e, n, s, r) {
735
735
  );
736
736
  if (!c || c.length === 0)
737
737
  return null;
738
- const l = Nt(c, n, e.effectId);
738
+ const l = Gt(c, n, e.effectId);
739
739
  let f;
740
740
  const a = n?.trigger === "view-progress";
741
741
  a && window.ViewTimeline && (f = new ViewTimeline({
@@ -755,7 +755,7 @@ function ve(t, e, n, s, r) {
755
755
  if (a)
756
756
  if (f)
757
757
  I.mutate(() => {
758
- const { start: b, end: S } = Gt(h);
758
+ const { start: b, end: S } = Dt(h);
759
759
  w.rangeStart = b, w.rangeEnd = S, w.play();
760
760
  });
761
761
  else {
@@ -778,7 +778,7 @@ function ve(t, e, n, s, r) {
778
778
  }
779
779
  return d && (w.id = d), w;
780
780
  });
781
- return new N(u, {
781
+ return new G(u, {
782
782
  ...e,
783
783
  trigger: { ...n || {} },
784
784
  // make sure the group is ready after all animation targets are measured and mutated
@@ -788,7 +788,7 @@ function ve(t, e, n, s, r) {
788
788
  function Wt(t, e, n) {
789
789
  const s = Z(e), r = t instanceof HTMLElement ? t : L(t);
790
790
  if (s && s.prepare && r) {
791
- const i = { measure: ze(r), mutate: De(r) };
791
+ const i = { measure: ze(r), mutate: Ne(r) };
792
792
  s.prepare(e, i);
793
793
  }
794
794
  n && I.mutate(n);
@@ -804,16 +804,16 @@ function Vt(t, e) {
804
804
  o.includes(l) && c.push(
805
805
  i?.find((f) => f.animationName === l)
806
806
  );
807
- }), c?.length ? new N(c) : null;
807
+ }), c?.length ? new G(c) : null;
808
808
  }
809
809
  function jt(t, e) {
810
810
  const s = (typeof t == "string" ? L(t) : t)?.getAnimations().filter((r) => {
811
811
  const i = r.id || r.animationName;
812
812
  return i ? i.startsWith(e) : !0;
813
813
  });
814
- return s?.length ? new N(s) : null;
814
+ return s?.length ? new G(s) : null;
815
815
  }
816
- function Ne(t, e, n, s = {}) {
816
+ function Ge(t, e, n, s = {}) {
817
817
  const { disabled: r, allowActiveEvent: i, ...o } = s, c = ve(t, e, n, o);
818
818
  if (!c)
819
819
  return null;
@@ -911,7 +911,7 @@ function We(t, e) {
911
911
  void 0,
912
912
  e?.reducedMotion
913
913
  );
914
- c instanceof N && n.push(c);
914
+ c instanceof G && n.push(c);
915
915
  }
916
916
  }
917
917
  return n;
@@ -1036,7 +1036,7 @@ function Zt(t) {
1036
1036
  const e = t.trim().split(/\s+/), n = e[0], s = e.length > 1 ? e[1] : e[0], r = (i) => i.startsWith("-") ? i.slice(1) : parseFloat(i) ? `-${i}` : i;
1037
1037
  return `${r(n)} 0px ${r(s)}`;
1038
1038
  }
1039
- const D = {}, k = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), R = /* @__PURE__ */ new WeakMap();
1039
+ const N = {}, k = /* @__PURE__ */ new WeakMap(), ee = /* @__PURE__ */ new WeakSet(), R = /* @__PURE__ */ new WeakMap();
1040
1040
  let Ve = {}, H = null;
1041
1041
  function en(t) {
1042
1042
  Ve = t;
@@ -1056,8 +1056,8 @@ function Ce() {
1056
1056
  }
1057
1057
  function Ye(t, e = !1) {
1058
1058
  const n = JSON.stringify({ ...t, isSafeMode: e });
1059
- if (D[n])
1060
- return D[n];
1059
+ if (N[n])
1060
+ return N[n];
1061
1061
  const s = t.threshold ?? Jt, r = e ? Xt : {
1062
1062
  root: null,
1063
1063
  rootMargin: t.inset ? Zt(t.inset) : "0px",
@@ -1082,7 +1082,7 @@ function Ye(t, e = !1) {
1082
1082
  (c.isIntersecting || !f) && je(l, c.isIntersecting);
1083
1083
  });
1084
1084
  }, r);
1085
- return D[n] = i, i;
1085
+ return N[n] = i, i;
1086
1086
  }
1087
1087
  function tn(t, e, n, s = {}, { reducedMotion: r, selectorCondition: i, animation: o } = {}) {
1088
1088
  const c = { ...Ve, ...s }, l = n.triggerType || "once", f = o || ne(
@@ -1129,7 +1129,7 @@ function nn(t) {
1129
1129
  W(k, t);
1130
1130
  }
1131
1131
  function sn() {
1132
- H = null, Object.keys(D).forEach((t) => delete D[t]);
1132
+ H = null, Object.keys(N).forEach((t) => delete N[t]);
1133
1133
  }
1134
1134
  const Ae = {
1135
1135
  add: tn,
@@ -1502,7 +1502,7 @@ function Sn(t, e, n, s, { reducedMotion: r }) {
1502
1502
  });
1503
1503
  });
1504
1504
  } else {
1505
- const f = Ne(e, o, i);
1505
+ const f = Ge(e, o, i);
1506
1506
  if (f) {
1507
1507
  const a = Array.isArray(f) ? f : [f], u = new wn({
1508
1508
  viewSource: t,
@@ -1794,14 +1794,14 @@ let Qe = () => ({});
1794
1794
  function zn(t) {
1795
1795
  Qe = t;
1796
1796
  }
1797
- function Dn(t, e, n, s = {}, { reducedMotion: r }) {
1797
+ function Nn(t, e, n, s = {}, { reducedMotion: r }) {
1798
1798
  if (r)
1799
1799
  return;
1800
1800
  const i = {
1801
1801
  trigger: "pointer-move",
1802
1802
  element: t,
1803
1803
  axis: s.axis ?? "y"
1804
- }, o = Ne(e, P(n), i);
1804
+ }, o = Ge(e, P(n), i);
1805
1805
  if (o) {
1806
1806
  const c = Array.isArray(o) ? o : [o], l = new Hn({
1807
1807
  root: s.hitArea === "self" ? t : void 0,
@@ -1817,12 +1817,12 @@ function Dn(t, e, n, s = {}, { reducedMotion: r }) {
1817
1817
  });
1818
1818
  }
1819
1819
  }
1820
- function Gn(t) {
1820
+ function Dn(t) {
1821
1821
  W(ue, t);
1822
1822
  }
1823
- const Nn = {
1824
- add: Dn,
1825
- remove: Gn,
1823
+ const Gn = {
1824
+ add: Nn,
1825
+ remove: Dn,
1826
1826
  registerOptionsGetter: zn
1827
1827
  }, de = /* @__PURE__ */ new WeakMap();
1828
1828
  function Wn(t, e, n, s, { reducedMotion: r, selectorCondition: i, animation: o }) {
@@ -2034,7 +2034,7 @@ const _ = {
2034
2034
  pageVisible: Ae,
2035
2035
  animationEnd: jn,
2036
2036
  viewProgress: In,
2037
- pointerMove: Nn,
2037
+ pointerMove: Gn,
2038
2038
  activate: {
2039
2039
  add: K("activate"),
2040
2040
  remove: z.remove
@@ -2187,7 +2187,7 @@ class E {
2187
2187
  }
2188
2188
  }
2189
2189
  let rs = 0;
2190
- function G(t, {
2190
+ function D(t, {
2191
2191
  asCombinator: e = !1,
2192
2192
  addItemFilter: n = !1,
2193
2193
  useFirstChild: s = !1
@@ -2235,7 +2235,7 @@ function os(t, e = !1) {
2235
2235
  sequences: u
2236
2236
  };
2237
2237
  s[i].triggers.push(h), s[i].selectors.add(
2238
- G(h, { useFirstChild: e })
2238
+ D(h, { useFirstChild: e })
2239
2239
  );
2240
2240
  const g = h.listContainer;
2241
2241
  a.forEach((d) => {
@@ -2252,7 +2252,7 @@ function os(t, e = !1) {
2252
2252
  if (d.interactionId = y, s[i].interactionIds.add(y), m === i)
2253
2253
  return;
2254
2254
  const v = ce(s, m);
2255
- v.effects[y] || (v.effects[y] = [], v.interactionIds.add(y)), v.effects[y].push({ ...f, effect: d }), v.selectors.add(G(d, { useFirstChild: e }));
2255
+ v.effects[y] || (v.effects[y] = [], v.interactionIds.add(y)), v.effects[y].push({ ...f, effect: d }), v.selectors.add(D(d, { useFirstChild: e }));
2256
2256
  }), u?.forEach((d) => {
2257
2257
  if (!d || Pe(d)) return;
2258
2258
  const m = d, p = m.sequenceId || x(), y = m.effects;
@@ -2260,15 +2260,17 @@ function os(t, e = !1) {
2260
2260
  v.effectId || (v.effectId = x());
2261
2261
  let w = v.key;
2262
2262
  if (!w && v.effectId) {
2263
- const b = t.effects[v.effectId];
2264
- b && (w = b.key);
2263
+ const S = t.effects[v.effectId];
2264
+ S && (w = S.key);
2265
2265
  }
2266
- if (w = w || i, w !== i) {
2267
- const b = ce(s, w), S = `${w}::seq::${p}::${o}`;
2268
- b.sequences[S] || (b.sequences[S] = [], b.interactionIds.add(S)), b.sequences[S].push({
2266
+ w = w || i;
2267
+ const b = D(v, { useFirstChild: e });
2268
+ if (b && s[i].selectors.add(b), w !== i) {
2269
+ const S = ce(s, w), T = `${w}::seq::${p}::${o}`;
2270
+ S.sequences[T] || (S.sequences[T] = [], S.interactionIds.add(T)), S.sequences[T].push({
2269
2271
  ...f,
2270
2272
  sequence: m
2271
- }), b.selectors.add(G(v, { useFirstChild: e }));
2273
+ }), S.selectors.add(b);
2272
2274
  }
2273
2275
  }
2274
2276
  });
@@ -2614,7 +2616,7 @@ function Fe(t, e, n, s, r, i, o, c) {
2614
2616
  effectId: r.effectId,
2615
2617
  transition: r.transition,
2616
2618
  properties: r.transitionProperties,
2617
- childSelector: G(r, {
2619
+ childSelector: D(r, {
2618
2620
  asCombinator: !0,
2619
2621
  addItemFilter: !0,
2620
2622
  useFirstChild: c
@@ -2708,8 +2710,10 @@ class hs {
2708
2710
  }
2709
2711
  disconnect({ removeFromCache: e = !1 } = {}) {
2710
2712
  if ((this.key || this.element.dataset.interactKey) && ds(this, e), this.sheet) {
2711
- const s = document.adoptedStyleSheets.indexOf(this.sheet);
2712
- document.adoptedStyleSheets.splice(s, 1);
2713
+ const s = this.element?.getRootNode(), r = s.host ? s : document;
2714
+ r.adoptedStyleSheets.indexOf(this.sheet) !== -1 && (r.adoptedStyleSheets = r.adoptedStyleSheets.filter(
2715
+ (o) => o !== this.sheet
2716
+ ));
2713
2717
  }
2714
2718
  this._observers = /* @__PURE__ */ new WeakMap(), this.sheet = null, this.connected = !1;
2715
2719
  }
@@ -2717,16 +2721,17 @@ class hs {
2717
2721
  this.disconnect(), this.connect();
2718
2722
  }
2719
2723
  renderStyle(e) {
2724
+ const n = this.element?.getRootNode(), s = n.host ? n : document;
2720
2725
  if (!this.sheet)
2721
2726
  this.sheet = new CSSStyleSheet(), this.sheet.replaceSync(e.join(`
2722
- `)), document.adoptedStyleSheets.push(this.sheet);
2727
+ `)), s.adoptedStyleSheets = [...s.adoptedStyleSheets || [], this.sheet];
2723
2728
  else {
2724
- let n = this.sheet.cssRules.length;
2725
- for (const s of e)
2729
+ let r = this.sheet.cssRules.length;
2730
+ for (const i of e)
2726
2731
  try {
2727
- this.sheet.insertRule(s, n), n++;
2728
- } catch (r) {
2729
- console.error(r);
2732
+ this.sheet.insertRule(i, r), r++;
2733
+ } catch (o) {
2734
+ console.error(o);
2730
2735
  }
2731
2736
  }
2732
2737
  }
@@ -2773,7 +2778,7 @@ function vs(t) {
2773
2778
  }
2774
2779
  const ms = (t, e, n, s) => {
2775
2780
  let i = `[data-interact-key="${t.replace(/"/g, "'")}"]`;
2776
- const o = G(e, { asCombinator: !0, useFirstChild: s });
2781
+ const o = D(e, { asCombinator: !0, useFirstChild: s });
2777
2782
  return o && (i = `${i} ${o}`), n && (i = U(i, n)), i;
2778
2783
  };
2779
2784
  function ys(t, e = !1) {
@@ -2831,4 +2836,4 @@ export {
2831
2836
  ys as g,
2832
2837
  vs as r
2833
2838
  };
2834
- //# sourceMappingURL=index-CJl_iRUI.mjs.map
2839
+ //# sourceMappingURL=index-HeFaJMEX.mjs.map