@bbl-digital/snorre 4.2.94 → 4.2.96

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 (112) hide show
  1. package/dist/snorre.es1019.js +14 -17
  2. package/dist/snorre.es1020.js +10 -254
  3. package/dist/snorre.es1021.js +41 -2
  4. package/dist/snorre.es1022.js +16 -79
  5. package/dist/snorre.es1023.js +11 -13
  6. package/dist/snorre.es1024.js +24 -18
  7. package/dist/snorre.es1025.js +26 -13
  8. package/dist/snorre.es1026.js +61 -15
  9. package/dist/snorre.es1027.js +6 -10
  10. package/dist/snorre.es1028.js +10 -41
  11. package/dist/snorre.es1029.js +23 -10
  12. package/dist/snorre.es1030.js +26 -25
  13. package/dist/snorre.es1031.js +2 -27
  14. package/dist/snorre.es1032.js +11 -60
  15. package/dist/snorre.es1033.js +8 -5
  16. package/dist/snorre.es1034.js +12 -9
  17. package/dist/snorre.es1035.js +28 -24
  18. package/dist/snorre.es1036.js +254 -26
  19. package/dist/snorre.es1037.js +2 -2
  20. package/dist/snorre.es1038.js +80 -11
  21. package/dist/snorre.es1039.js +13 -9
  22. package/dist/snorre.es1040.js +18 -12
  23. package/dist/snorre.es1041.js +14 -28
  24. package/dist/snorre.es1042.js +5 -4
  25. package/dist/snorre.es1043.js +4 -5
  26. package/dist/snorre.es1124.js +24 -8
  27. package/dist/snorre.es1125.js +19 -22
  28. package/dist/snorre.es1126.js +7 -65
  29. package/dist/snorre.es1127.js +6 -25
  30. package/dist/snorre.es1128.js +22 -19
  31. package/dist/snorre.es1129.js +6 -7
  32. package/dist/snorre.es1130.js +16 -6
  33. package/dist/snorre.es1131.js +8 -5
  34. package/dist/snorre.es1132.js +8 -15
  35. package/dist/snorre.es1133.js +63 -7
  36. package/dist/snorre.es1155.js +1 -1
  37. package/dist/snorre.es1157.js +1 -1
  38. package/dist/snorre.es1334.js +5 -5
  39. package/dist/snorre.es1335.js +1 -1
  40. package/dist/snorre.es1343.js +3 -3
  41. package/dist/snorre.es1344.js +4 -4
  42. package/dist/snorre.es1345.js +4 -10
  43. package/dist/snorre.es1346.js +10 -6
  44. package/dist/snorre.es1347.js +6 -6
  45. package/dist/snorre.es1348.js +6 -4
  46. package/dist/snorre.es333.js +3 -3
  47. package/dist/snorre.es334.js +1 -1
  48. package/dist/snorre.es335.js +2 -2
  49. package/dist/snorre.es466.js +1 -1
  50. package/dist/snorre.es487.js +1 -1
  51. package/dist/snorre.es488.js +1 -1
  52. package/dist/snorre.es489.js +1 -1
  53. package/dist/snorre.es500.js +54 -2
  54. package/dist/snorre.es501.js +64 -24
  55. package/dist/snorre.es502.js +2 -602
  56. package/dist/snorre.es503.js +26 -5
  57. package/dist/snorre.es504.js +602 -54
  58. package/dist/snorre.es505.js +5 -66
  59. package/dist/snorre.es550.js +1 -1
  60. package/dist/snorre.es551.js +1 -1
  61. package/dist/snorre.es573.js +22 -2
  62. package/dist/snorre.es574.js +40 -2
  63. package/dist/snorre.es575.js +2 -22
  64. package/dist/snorre.es576.js +2 -40
  65. package/dist/snorre.es612.js +1 -1
  66. package/dist/snorre.es613.js +1 -1
  67. package/dist/snorre.es617.js +5 -5
  68. package/dist/snorre.es618.js +1 -1
  69. package/dist/snorre.es623.js +1 -1
  70. package/dist/snorre.es626.js +1 -1
  71. package/dist/snorre.es636.js +2 -2
  72. package/dist/snorre.es709.js +1 -1
  73. package/dist/snorre.es730.js +1 -1
  74. package/dist/snorre.es731.js +1 -1
  75. package/dist/snorre.es732.js +2 -2
  76. package/dist/snorre.es734.js +1 -1
  77. package/dist/snorre.es836.js +3 -3
  78. package/dist/snorre.es841.js +1 -1
  79. package/dist/snorre.es842.js +6 -6
  80. package/dist/snorre.es843.js +7 -7
  81. package/dist/snorre.es844.js +1 -1
  82. package/dist/snorre.es845.js +1 -1
  83. package/dist/snorre.es846.js +2 -2
  84. package/dist/snorre.es847.js +3 -3
  85. package/dist/snorre.es850.js +28 -15
  86. package/dist/snorre.es851.js +21 -2
  87. package/dist/snorre.es852.js +2 -10
  88. package/dist/snorre.es853.js +9 -4
  89. package/dist/snorre.es854.js +5 -11
  90. package/dist/snorre.es855.js +11 -14
  91. package/dist/snorre.es856.js +12 -27
  92. package/dist/snorre.es857.js +28 -28
  93. package/dist/snorre.es859.js +5 -20
  94. package/dist/snorre.es860.js +15 -5
  95. package/dist/snorre.es868.js +1 -1
  96. package/dist/snorre.es883.js +1 -1
  97. package/dist/snorre.es931.js +3 -3
  98. package/dist/snorre.es938.js +1 -1
  99. package/dist/snorre.es941.js +2 -2
  100. package/dist/snorre.es943.js +5 -13
  101. package/dist/snorre.es944.js +21 -4
  102. package/dist/snorre.es945.js +9 -5
  103. package/dist/snorre.es946.js +7 -29
  104. package/dist/snorre.es947.js +12 -11
  105. package/dist/snorre.es948.js +4 -24
  106. package/dist/snorre.es949.js +5 -5
  107. package/dist/snorre.es950.js +29 -5
  108. package/dist/snorre.es951.js +11 -21
  109. package/dist/snorre.es952.js +25 -9
  110. package/dist/snorre.es953.js +5 -7
  111. package/package.json +25 -1
  112. package/vite.config.js +1 -2
@@ -1,12 +1,8 @@
1
- import { makeUseVisualState as t } from "./snorre.es725.js";
2
- import { scrapeMotionValuesFromProps as e } from "./snorre.es1034.js";
3
- import { createHtmlRenderState as o } from "./snorre.es1129.js";
4
- const i = {
5
- useVisualState: t({
6
- scrapeMotionValuesFromProps: e,
7
- createRenderState: o
8
- })
9
- };
1
+ function y(t, { style: o, vars: e }, r, s) {
2
+ Object.assign(t.style, o, s && s.getProjectionStyles(r));
3
+ for (const n in e)
4
+ t.style.setProperty(n, e[n]);
5
+ }
10
6
  export {
11
- i as htmlMotionConfig
7
+ y as renderHTML
12
8
  };
@@ -1,43 +1,12 @@
1
- import { frame as n } from "./snorre.es674.js";
2
- import { makeUseVisualState as u } from "./snorre.es725.js";
3
- import { transformProps as d } from "./snorre.es656.js";
4
- import { buildSVGAttrs as l } from "./snorre.es1035.js";
5
- import { createSvgRenderState as g } from "./snorre.es1130.js";
6
- import { isSVGTag as c } from "./snorre.es1037.js";
7
- import { updateSVGDimensions as S } from "./snorre.es1038.js";
8
- import { renderSVG as V } from "./snorre.es1039.js";
9
- import { scrapeMotionValuesFromProps as h } from "./snorre.es1040.js";
10
- const p = ["x", "y", "width", "height", "cx", "cy", "r"], R = {
11
- useVisualState: u({
12
- scrapeMotionValuesFromProps: h,
13
- createRenderState: g,
14
- onUpdate: ({ props: t, prevProps: e, current: o, renderState: i, latestValues: a }) => {
15
- if (!o)
16
- return;
17
- let m = !!t.drag;
18
- if (!m) {
19
- for (const r in a)
20
- if (d.has(r)) {
21
- m = !0;
22
- break;
23
- }
24
- }
25
- if (!m)
26
- return;
27
- let f = !e;
28
- if (e)
29
- for (let r = 0; r < p.length; r++) {
30
- const s = p[r];
31
- t[s] !== e[s] && (f = !0);
32
- }
33
- f && n.read(() => {
34
- S(o, i), n.render(() => {
35
- l(i, a, c(o.tagName), t.transformTemplate), V(o, i);
36
- });
37
- });
38
- }
39
- })
40
- };
1
+ import { isForcedMotionValue as u } from "./snorre.es1129.js";
2
+ import { isMotionValue as s } from "./snorre.es606.js";
3
+ function c(n, l, e) {
4
+ var i;
5
+ const { style: t } = n, r = {};
6
+ for (const o in t)
7
+ (s(t[o]) || l.style && s(l.style[o]) || u(o, n) || ((i = e == null ? void 0 : e.getValue(o)) === null || i === void 0 ? void 0 : i.liveStyle) !== void 0) && (r[o] = t[o]);
8
+ return r;
9
+ }
41
10
  export {
42
- R as svgMotionConfig
11
+ c as scrapeMotionValuesFromProps
43
12
  };
@@ -1,13 +1,26 @@
1
- import { convertBoundingBoxToBox as s, transformBoxPoints as f } from "./snorre.es1125.js";
2
- import { translateAxis as n } from "./snorre.es1053.js";
3
- function x(o, t) {
4
- return s(f(o.getBoundingClientRect(), t));
5
- }
6
- function c(o, t, i) {
7
- const r = x(o, i), { scroll: e } = t;
8
- return e && (n(r.x, e.offset.x), n(r.y, e.offset.y)), r;
1
+ import { buildHTMLStyles as b } from "./snorre.es1025.js";
2
+ import { buildSVGPath as p } from "./snorre.es1130.js";
3
+ import { calcSVGTransformOrigin as v } from "./snorre.es1131.js";
4
+ function S(f, {
5
+ attrX: o,
6
+ attrY: s,
7
+ attrScale: m,
8
+ originX: i,
9
+ originY: e,
10
+ pathLength: u,
11
+ pathSpacing: l = 1,
12
+ pathOffset: t = 0,
13
+ // This is object creation, which we try to avoid per-frame.
14
+ ...y
15
+ }, x, c) {
16
+ if (b(f, y, c), x) {
17
+ f.style.viewBox && (f.attrs.viewBox = f.style.viewBox);
18
+ return;
19
+ }
20
+ f.attrs = f.style, f.style = {};
21
+ const { attrs: n, style: r, dimensions: d } = f;
22
+ n.transform && (d && (r.transform = n.transform), delete n.transform), d && (i !== void 0 || e !== void 0 || r.transform) && (r.transformOrigin = v(d, i !== void 0 ? i : 0.5, e !== void 0 ? e : 0.5)), o !== void 0 && (n.x = o), s !== void 0 && (n.y = s), m !== void 0 && (n.scale = m), u !== void 0 && p(n, u, l, t, !1);
9
23
  }
10
24
  export {
11
- c as measurePageBox,
12
- x as measureViewportBox
25
+ S as buildSVGAttrs
13
26
  };
@@ -1,27 +1,28 @@
1
- import { VisualElement as r } from "./snorre.es658.js";
2
- import { DOMKeyframesResolver as o } from "./snorre.es617.js";
3
- import { isMotionValue as s } from "./snorre.es606.js";
4
- class a extends r {
5
- constructor() {
6
- super(...arguments), this.KeyframeResolver = o;
7
- }
8
- sortInstanceNodePosition(e, t) {
9
- return e.compareDocumentPosition(t) & 2 ? 1 : -1;
10
- }
11
- getBaseTargetFromProps(e, t) {
12
- return e.style ? e.style[t] : void 0;
13
- }
14
- removeValueFromRenderState(e, { vars: t, style: i }) {
15
- delete t[e], delete i[e];
16
- }
17
- handleChildMotionValue() {
18
- this.childSubscription && (this.childSubscription(), delete this.childSubscription);
19
- const { children: e } = this.props;
20
- s(e) && (this.childSubscription = e.on("change", (t) => {
21
- this.current && (this.current.textContent = `${t}`);
22
- }));
23
- }
24
- }
1
+ const e = /* @__PURE__ */ new Set([
2
+ "baseFrequency",
3
+ "diffuseConstant",
4
+ "kernelMatrix",
5
+ "kernelUnitLength",
6
+ "keySplines",
7
+ "keyTimes",
8
+ "limitingConeAngle",
9
+ "markerHeight",
10
+ "markerWidth",
11
+ "numOctaves",
12
+ "targetX",
13
+ "targetY",
14
+ "surfaceScale",
15
+ "specularConstant",
16
+ "specularExponent",
17
+ "stdDeviation",
18
+ "tableValues",
19
+ "viewBox",
20
+ "gradientTransform",
21
+ "pathLength",
22
+ "startOffset",
23
+ "textLength",
24
+ "lengthAdjust"
25
+ ]);
25
26
  export {
26
- a as DOMVisualElement
27
+ e as camelCaseAttributes
27
28
  };
@@ -1,29 +1,4 @@
1
- import { isCSSVariableName as p } from "./snorre.es652.js";
2
- import { getValueAsType as u } from "./snorre.es654.js";
3
- import { numberValueTypes as c } from "./snorre.es655.js";
4
- import { buildTransform as g } from "./snorre.es653.js";
5
- import { transformProps as y } from "./snorre.es656.js";
6
- function S(f, i, e) {
7
- const { style: o, vars: l, transformOrigin: t } = f;
8
- let m = !1, a = !1;
9
- for (const r in i) {
10
- const n = i[r];
11
- if (y.has(r)) {
12
- m = !0;
13
- continue;
14
- } else if (p(r)) {
15
- l[r] = n;
16
- continue;
17
- } else {
18
- const s = u(n, c[r]);
19
- r.startsWith("origin") ? (a = !0, t[r] = s) : o[r] = s;
20
- }
21
- }
22
- if (i.transform || (m || e ? o.transform = g(i, f.transform, e) : o.transform && (o.transform = "none")), a) {
23
- const { originX: r = "50%", originY: n = "50%", originZ: s = 0 } = t;
24
- o.transformOrigin = `${r} ${n} ${s}`;
25
- }
26
- }
1
+ const s = (o) => typeof o == "string" && o.toLowerCase() === "svg";
27
2
  export {
28
- S as buildHTMLStyles
3
+ s as isSVGTag
29
4
  };
@@ -1,64 +1,15 @@
1
- const e = (t) => t * 180 / Math.PI, c = (t) => {
2
- const a = e(Math.atan2(t[1], t[0]));
3
- return l(a);
4
- }, f = {
5
- x: 4,
6
- y: 5,
7
- translateX: 4,
8
- translateY: 5,
9
- scaleX: 0,
10
- scaleY: 3,
11
- scale: (t) => (Math.abs(t[0]) + Math.abs(t[3])) / 2,
12
- rotate: c,
13
- rotateZ: c,
14
- skewX: (t) => e(Math.atan(t[1])),
15
- skewY: (t) => e(Math.atan(t[2])),
16
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[2])) / 2
17
- }, l = (t) => (t = t % 360, t < 0 && (t += 360), t), h = c, M = (t) => Math.sqrt(t[0] * t[0] + t[1] * t[1]), i = (t) => Math.sqrt(t[4] * t[4] + t[5] * t[5]), x = {
18
- x: 12,
19
- y: 13,
20
- z: 14,
21
- translateX: 12,
22
- translateY: 13,
23
- translateZ: 14,
24
- scaleX: M,
25
- scaleY: i,
26
- scale: (t) => (M(t) + i(t)) / 2,
27
- rotateX: (t) => l(e(Math.atan2(t[6], t[5]))),
28
- rotateY: (t) => l(e(Math.atan2(-t[2], t[0]))),
29
- rotateZ: h,
30
- rotate: h,
31
- skewX: (t) => e(Math.atan(t[4])),
32
- skewY: (t) => e(Math.atan(t[1])),
33
- skew: (t) => (Math.abs(t[1]) + Math.abs(t[4])) / 2
34
- };
35
- function m(t) {
36
- return t.includes("scale") ? 1 : 0;
37
- }
38
- function b(t, a) {
39
- if (!t || t === "none")
40
- return m(a);
41
- const s = t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);
42
- let n, r;
43
- if (s)
44
- n = x, r = s;
45
- else {
46
- const d = t.match(/^matrix\(([-\d.e\s,]+)\)$/u);
47
- n = f, r = d;
1
+ function e(i, o) {
2
+ try {
3
+ o.dimensions = typeof i.getBBox == "function" ? i.getBBox() : i.getBoundingClientRect();
4
+ } catch {
5
+ o.dimensions = {
6
+ x: 0,
7
+ y: 0,
8
+ width: 0,
9
+ height: 0
10
+ };
48
11
  }
49
- if (!r)
50
- return m(a);
51
- const o = n[a], u = r[1].split(",").map(p);
52
- return typeof o == "function" ? o(u) : u[o];
53
- }
54
- const X = (t, a) => {
55
- const { transform: s = "none" } = getComputedStyle(t);
56
- return b(s, a);
57
- };
58
- function p(t) {
59
- return parseFloat(t.trim());
60
12
  }
61
13
  export {
62
- b as parseValueFromTransform,
63
- X as readTransformValue
14
+ e as updateSVGDimensions
64
15
  };
@@ -1,8 +1,11 @@
1
- function y(t, { style: o, vars: e }, r, s) {
2
- Object.assign(t.style, o, s && s.getProjectionStyles(r));
3
- for (const n in e)
4
- t.style.setProperty(n, e[n]);
1
+ import { camelToDash as i } from "./snorre.es689.js";
2
+ import { renderHTML as m } from "./snorre.es1027.js";
3
+ import { camelCaseAttributes as e } from "./snorre.es1030.js";
4
+ function c(o, t, f, s) {
5
+ m(o, t, void 0, s);
6
+ for (const r in t.attrs)
7
+ o.setAttribute(e.has(r) ? r : i(r), t.attrs[r]);
5
8
  }
6
9
  export {
7
- y as renderHTML
10
+ c as renderSVG
8
11
  };
@@ -1,12 +1,15 @@
1
- import { isForcedMotionValue as u } from "./snorre.es1131.js";
2
- import { isMotionValue as s } from "./snorre.es606.js";
3
- function c(n, l, e) {
4
- var i;
5
- const { style: t } = n, r = {};
6
- for (const o in t)
7
- (s(t[o]) || l.style && s(l.style[o]) || u(o, n) || ((i = e == null ? void 0 : e.getValue(o)) === null || i === void 0 ? void 0 : i.liveStyle) !== void 0) && (r[o] = t[o]);
8
- return r;
1
+ import { isMotionValue as n } from "./snorre.es606.js";
2
+ import { transformPropOrder as i } from "./snorre.es656.js";
3
+ import { scrapeMotionValuesFromProps as m } from "./snorre.es1028.js";
4
+ function l(r, t, s) {
5
+ const e = m(r, t, s);
6
+ for (const o in r)
7
+ if (n(r[o]) || n(t[o])) {
8
+ const a = i.indexOf(o) !== -1 ? "attr" + o.charAt(0).toUpperCase() + o.substring(1) : o;
9
+ e[a] = r[o];
10
+ }
11
+ return e;
9
12
  }
10
13
  export {
11
- c as scrapeMotionValuesFromProps
14
+ l as scrapeMotionValuesFromProps
12
15
  };
@@ -1,26 +1,30 @@
1
- import { buildHTMLStyles as b } from "./snorre.es1031.js";
2
- import { buildSVGPath as p } from "./snorre.es1132.js";
3
- import { calcSVGTransformOrigin as v } from "./snorre.es1133.js";
4
- function S(f, {
5
- attrX: o,
6
- attrY: s,
7
- attrScale: m,
8
- originX: i,
9
- originY: e,
10
- pathLength: u,
11
- pathSpacing: l = 1,
12
- pathOffset: t = 0,
13
- // This is object creation, which we try to avoid per-frame.
14
- ...y
15
- }, x, c) {
16
- if (b(f, y, c), x) {
17
- f.style.viewBox && (f.attrs.viewBox = f.style.viewBox);
18
- return;
19
- }
20
- f.attrs = f.style, f.style = {};
21
- const { attrs: n, style: r, dimensions: d } = f;
22
- n.transform && (d && (r.transform = n.transform), delete n.transform), d && (i !== void 0 || e !== void 0 || r.transform) && (r.transformOrigin = v(d, i !== void 0 ? i : 0.5, e !== void 0 ? e : 0.5)), o !== void 0 && (n.x = o), s !== void 0 && (n.y = s), m !== void 0 && (n.scale = m), u !== void 0 && p(n, u, l, t, !1);
23
- }
1
+ const e = [
2
+ "animate",
3
+ "circle",
4
+ "defs",
5
+ "desc",
6
+ "ellipse",
7
+ "g",
8
+ "image",
9
+ "line",
10
+ "filter",
11
+ "marker",
12
+ "mask",
13
+ "metadata",
14
+ "path",
15
+ "pattern",
16
+ "polygon",
17
+ "polyline",
18
+ "rect",
19
+ "stop",
20
+ "switch",
21
+ "symbol",
22
+ "svg",
23
+ "text",
24
+ "tspan",
25
+ "use",
26
+ "view"
27
+ ];
24
28
  export {
25
- S as buildSVGAttrs
29
+ e as lowercaseSVGElements
26
30
  };
@@ -1,28 +1,256 @@
1
- const e = /* @__PURE__ */ new Set([
2
- "baseFrequency",
3
- "diffuseConstant",
4
- "kernelMatrix",
5
- "kernelUnitLength",
6
- "keySplines",
7
- "keyTimes",
8
- "limitingConeAngle",
9
- "markerHeight",
10
- "markerWidth",
11
- "numOctaves",
12
- "targetX",
13
- "targetY",
14
- "surfaceScale",
15
- "specularConstant",
16
- "specularExponent",
17
- "stdDeviation",
18
- "tableValues",
19
- "viewBox",
20
- "gradientTransform",
21
- "pathLength",
22
- "startOffset",
23
- "textLength",
24
- "lengthAdjust"
25
- ]);
1
+ import { invariant as L } from "./snorre.es624.js";
2
+ import { setDragLock as M } from "./snorre.es1132.js";
3
+ import { animateMotionValue as S } from "./snorre.es864.js";
4
+ import { addDomEvent as B } from "./snorre.es728.js";
5
+ import { addPointerEvent as k } from "./snorre.es727.js";
6
+ import { extractEventInfo as j } from "./snorre.es729.js";
7
+ import { convertBoxToBoundingBox as T, convertBoundingBoxToBox as w } from "./snorre.es1128.js";
8
+ import { calcLength as b } from "./snorre.es723.js";
9
+ import { createBox as R } from "./snorre.es660.js";
10
+ import { eachAxis as u } from "./snorre.es1058.js";
11
+ import { measurePageBox as W } from "./snorre.es1023.js";
12
+ import { getContextWindow as _ } from "./snorre.es1037.js";
13
+ import { isRefObject as D } from "./snorre.es866.js";
14
+ import { mixNumber as V } from "./snorre.es714.js";
15
+ import { percent as O } from "./snorre.es683.js";
16
+ import { addValueToWillChange as x } from "./snorre.es862.js";
17
+ import { PanSession as U } from "./snorre.es1038.js";
18
+ import { applyConstraints as z, calcRelativeConstraints as I, resolveDragElastic as F, calcViewportConstraints as K, defaultElastic as N, rebaseAxisConstraints as $, calcOrigin as q } from "./snorre.es1133.js";
19
+ import { frame as C } from "./snorre.es674.js";
20
+ const G = /* @__PURE__ */ new WeakMap();
21
+ class ft {
22
+ constructor(t) {
23
+ this.openDragLock = null, this.isDragging = !1, this.currentDirection = null, this.originPoint = { x: 0, y: 0 }, this.constraints = !1, this.hasMutatedConstraints = !1, this.elastic = R(), this.visualElement = t;
24
+ }
25
+ start(t, { snapToCursor: s = !1 } = {}) {
26
+ const { presenceContext: i } = this.visualElement;
27
+ if (i && i.isPresent === !1)
28
+ return;
29
+ const n = (o) => {
30
+ const { dragSnapToOrigin: a } = this.getProps();
31
+ a ? this.pauseAnimation() : this.stopAnimation(), s && this.snapToCursor(j(o).point);
32
+ }, r = (o, a) => {
33
+ const { drag: f, dragPropagation: d, onDragStart: g } = this.getProps();
34
+ if (f && !d && (this.openDragLock && this.openDragLock(), this.openDragLock = M(f), !this.openDragLock))
35
+ return;
36
+ this.isDragging = !0, this.currentDirection = null, this.resolveConstraints(), this.visualElement.projection && (this.visualElement.projection.isAnimationBlocked = !0, this.visualElement.projection.target = void 0), u((m) => {
37
+ let E = this.getAxisMotionValue(m).get() || 0;
38
+ if (O.test(E)) {
39
+ const { projection: A } = this.visualElement;
40
+ if (A && A.layout) {
41
+ const y = A.layout.layoutBox[m];
42
+ y && (E = b(y) * (parseFloat(E) / 100));
43
+ }
44
+ }
45
+ this.originPoint[m] = E;
46
+ }), g && C.postRender(() => g(o, a)), x(this.visualElement, "transform");
47
+ const { animationState: v } = this.visualElement;
48
+ v && v.setActive("whileDrag", !0);
49
+ }, e = (o, a) => {
50
+ const { dragPropagation: f, dragDirectionLock: d, onDirectionLock: g, onDrag: v } = this.getProps();
51
+ if (!f && !this.openDragLock)
52
+ return;
53
+ const { offset: m } = a;
54
+ if (d && this.currentDirection === null) {
55
+ this.currentDirection = H(m), this.currentDirection !== null && g && g(this.currentDirection);
56
+ return;
57
+ }
58
+ this.updateAxis("x", a.point, m), this.updateAxis("y", a.point, m), this.visualElement.render(), v && v(o, a);
59
+ }, l = (o, a) => this.stop(o, a), c = () => u((o) => {
60
+ var a;
61
+ return this.getAnimationState(o) === "paused" && ((a = this.getAxisMotionValue(o).animation) === null || a === void 0 ? void 0 : a.play());
62
+ }), { dragSnapToOrigin: h } = this.getProps();
63
+ this.panSession = new U(t, {
64
+ onSessionStart: n,
65
+ onStart: r,
66
+ onMove: e,
67
+ onSessionEnd: l,
68
+ resumeAnimation: c
69
+ }, {
70
+ transformPagePoint: this.visualElement.getTransformPagePoint(),
71
+ dragSnapToOrigin: h,
72
+ contextWindow: _(this.visualElement)
73
+ });
74
+ }
75
+ stop(t, s) {
76
+ const i = this.isDragging;
77
+ if (this.cancel(), !i)
78
+ return;
79
+ const { velocity: n } = s;
80
+ this.startAnimation(n);
81
+ const { onDragEnd: r } = this.getProps();
82
+ r && C.postRender(() => r(t, s));
83
+ }
84
+ cancel() {
85
+ this.isDragging = !1;
86
+ const { projection: t, animationState: s } = this.visualElement;
87
+ t && (t.isAnimationBlocked = !1), this.panSession && this.panSession.end(), this.panSession = void 0;
88
+ const { dragPropagation: i } = this.getProps();
89
+ !i && this.openDragLock && (this.openDragLock(), this.openDragLock = null), s && s.setActive("whileDrag", !1);
90
+ }
91
+ updateAxis(t, s, i) {
92
+ const { drag: n } = this.getProps();
93
+ if (!i || !P(t, n, this.currentDirection))
94
+ return;
95
+ const r = this.getAxisMotionValue(t);
96
+ let e = this.originPoint[t] + i[t];
97
+ this.constraints && this.constraints[t] && (e = z(e, this.constraints[t], this.elastic[t])), r.set(e);
98
+ }
99
+ resolveConstraints() {
100
+ var t;
101
+ const { dragConstraints: s, dragElastic: i } = this.getProps(), n = this.visualElement.projection && !this.visualElement.projection.layout ? this.visualElement.projection.measure(!1) : (t = this.visualElement.projection) === null || t === void 0 ? void 0 : t.layout, r = this.constraints;
102
+ s && D(s) ? this.constraints || (this.constraints = this.resolveRefConstraints()) : s && n ? this.constraints = I(n.layoutBox, s) : this.constraints = !1, this.elastic = F(i), r !== this.constraints && n && this.constraints && !this.hasMutatedConstraints && u((e) => {
103
+ this.constraints !== !1 && this.getAxisMotionValue(e) && (this.constraints[e] = $(n.layoutBox[e], this.constraints[e]));
104
+ });
105
+ }
106
+ resolveRefConstraints() {
107
+ const { dragConstraints: t, onMeasureDragConstraints: s } = this.getProps();
108
+ if (!t || !D(t))
109
+ return !1;
110
+ const i = t.current;
111
+ L(i !== null, "If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.");
112
+ const { projection: n } = this.visualElement;
113
+ if (!n || !n.layout)
114
+ return !1;
115
+ const r = W(i, n.root, this.visualElement.getTransformPagePoint());
116
+ let e = K(n.layout.layoutBox, r);
117
+ if (s) {
118
+ const l = s(T(e));
119
+ this.hasMutatedConstraints = !!l, l && (e = w(l));
120
+ }
121
+ return e;
122
+ }
123
+ startAnimation(t) {
124
+ const { drag: s, dragMomentum: i, dragElastic: n, dragTransition: r, dragSnapToOrigin: e, onDragTransitionEnd: l } = this.getProps(), c = this.constraints || {}, h = u((o) => {
125
+ if (!P(o, s, this.currentDirection))
126
+ return;
127
+ let a = c && c[o] || {};
128
+ e && (a = { min: 0, max: 0 });
129
+ const f = n ? 200 : 1e6, d = n ? 40 : 1e7, g = {
130
+ type: "inertia",
131
+ velocity: i ? t[o] : 0,
132
+ bounceStiffness: f,
133
+ bounceDamping: d,
134
+ timeConstant: 750,
135
+ restDelta: 1,
136
+ restSpeed: 10,
137
+ ...r,
138
+ ...a
139
+ };
140
+ return this.startAxisValueAnimation(o, g);
141
+ });
142
+ return Promise.all(h).then(l);
143
+ }
144
+ startAxisValueAnimation(t, s) {
145
+ const i = this.getAxisMotionValue(t);
146
+ return x(this.visualElement, t), i.start(S(t, i, 0, s, this.visualElement, !1));
147
+ }
148
+ stopAnimation() {
149
+ u((t) => this.getAxisMotionValue(t).stop());
150
+ }
151
+ pauseAnimation() {
152
+ u((t) => {
153
+ var s;
154
+ return (s = this.getAxisMotionValue(t).animation) === null || s === void 0 ? void 0 : s.pause();
155
+ });
156
+ }
157
+ getAnimationState(t) {
158
+ var s;
159
+ return (s = this.getAxisMotionValue(t).animation) === null || s === void 0 ? void 0 : s.state;
160
+ }
161
+ /**
162
+ * Drag works differently depending on which props are provided.
163
+ *
164
+ * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.
165
+ * - Otherwise, we apply the delta to the x/y motion values.
166
+ */
167
+ getAxisMotionValue(t) {
168
+ const s = `_drag${t.toUpperCase()}`, i = this.visualElement.getProps(), n = i[s];
169
+ return n || this.visualElement.getValue(t, (i.initial ? i.initial[t] : void 0) || 0);
170
+ }
171
+ snapToCursor(t) {
172
+ u((s) => {
173
+ const { drag: i } = this.getProps();
174
+ if (!P(s, i, this.currentDirection))
175
+ return;
176
+ const { projection: n } = this.visualElement, r = this.getAxisMotionValue(s);
177
+ if (n && n.layout) {
178
+ const { min: e, max: l } = n.layout.layoutBox[s];
179
+ r.set(t[s] - V(e, l, 0.5));
180
+ }
181
+ });
182
+ }
183
+ /**
184
+ * When the viewport resizes we want to check if the measured constraints
185
+ * have changed and, if so, reposition the element within those new constraints
186
+ * relative to where it was before the resize.
187
+ */
188
+ scalePositionWithinConstraints() {
189
+ if (!this.visualElement.current)
190
+ return;
191
+ const { drag: t, dragConstraints: s } = this.getProps(), { projection: i } = this.visualElement;
192
+ if (!D(s) || !i || !this.constraints)
193
+ return;
194
+ this.stopAnimation();
195
+ const n = { x: 0, y: 0 };
196
+ u((e) => {
197
+ const l = this.getAxisMotionValue(e);
198
+ if (l && this.constraints !== !1) {
199
+ const c = l.get();
200
+ n[e] = q({ min: c, max: c }, this.constraints[e]);
201
+ }
202
+ });
203
+ const { transformTemplate: r } = this.visualElement.getProps();
204
+ this.visualElement.current.style.transform = r ? r({}, "") : "none", i.root && i.root.updateScroll(), i.updateLayout(), this.resolveConstraints(), u((e) => {
205
+ if (!P(e, t, null))
206
+ return;
207
+ const l = this.getAxisMotionValue(e), { min: c, max: h } = this.constraints[e];
208
+ l.set(V(c, h, n[e]));
209
+ });
210
+ }
211
+ addListeners() {
212
+ if (!this.visualElement.current)
213
+ return;
214
+ G.set(this.visualElement, this);
215
+ const t = this.visualElement.current, s = k(t, "pointerdown", (c) => {
216
+ const { drag: h, dragListener: o = !0 } = this.getProps();
217
+ h && o && this.start(c);
218
+ }), i = () => {
219
+ const { dragConstraints: c } = this.getProps();
220
+ D(c) && c.current && (this.constraints = this.resolveRefConstraints());
221
+ }, { projection: n } = this.visualElement, r = n.addEventListener("measure", i);
222
+ n && !n.layout && (n.root && n.root.updateScroll(), n.updateLayout()), C.read(i);
223
+ const e = B(window, "resize", () => this.scalePositionWithinConstraints()), l = n.addEventListener("didUpdate", ({ delta: c, hasLayoutChanged: h }) => {
224
+ this.isDragging && h && (u((o) => {
225
+ const a = this.getAxisMotionValue(o);
226
+ a && (this.originPoint[o] += c[o].translate, a.set(a.get() + c[o].translate));
227
+ }), this.visualElement.render());
228
+ });
229
+ return () => {
230
+ e(), s(), r(), l && l();
231
+ };
232
+ }
233
+ getProps() {
234
+ const t = this.visualElement.getProps(), { drag: s = !1, dragDirectionLock: i = !1, dragPropagation: n = !1, dragConstraints: r = !1, dragElastic: e = N, dragMomentum: l = !0 } = t;
235
+ return {
236
+ ...t,
237
+ drag: s,
238
+ dragDirectionLock: i,
239
+ dragPropagation: n,
240
+ dragConstraints: r,
241
+ dragElastic: e,
242
+ dragMomentum: l
243
+ };
244
+ }
245
+ }
246
+ function P(p, t, s) {
247
+ return (t === !0 || t === p) && (s === null || s === p);
248
+ }
249
+ function H(p, t = 10) {
250
+ let s = null;
251
+ return Math.abs(p.y) > t ? s = "y" : Math.abs(p.x) > t && (s = "x"), s;
252
+ }
26
253
  export {
27
- e as camelCaseAttributes
254
+ ft as VisualElementDragControls,
255
+ G as elementDragControls
28
256
  };