@nil-/xit 0.2.2 → 0.2.3

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.
@@ -1,142 +0,0 @@
1
- const M = (t) => t;
2
- function m(t) {
3
- const e = t - 1;
4
- return e * e * e + 1;
5
- }
6
- function C(t) {
7
- return t < 0.5 ? 4 * t * t * t : 0.5 * Math.pow(2 * t - 2, 3) + 1;
8
- }
9
- function w(t) {
10
- const e = typeof t == "string" && t.match(/^\s*(-?[\d.]+)([^\s]*)\s*$/);
11
- return e ? [parseFloat(e[1]), e[2] || "px"] : [
12
- /** @type {number} */
13
- t,
14
- "px"
15
- ];
16
- }
17
- function W(t, { delay: e = 0, duration: a = 400, easing: r = C, amount: p = 5, opacity: n = 0 } = {}) {
18
- const c = getComputedStyle(t), s = +c.opacity, d = c.filter === "none" ? "" : c.filter, i = s * (1 - n), [o, y] = w(p);
19
- return {
20
- delay: e,
21
- duration: a,
22
- easing: r,
23
- css: (f, u) => `opacity: ${s - i * u}; filter: ${d} blur(${u * o}${y});`
24
- };
25
- }
26
- function q(t, { delay: e = 0, duration: a = 400, easing: r = M } = {}) {
27
- const p = +getComputedStyle(t).opacity;
28
- return {
29
- delay: e,
30
- duration: a,
31
- easing: r,
32
- css: (n) => `opacity: ${n * p}`
33
- };
34
- }
35
- function B(t, { delay: e = 0, duration: a = 400, easing: r = m, x: p = 0, y: n = 0, opacity: c = 0 } = {}) {
36
- const s = getComputedStyle(t), d = +s.opacity, i = s.transform === "none" ? "" : s.transform, o = d * (1 - c), [y, f] = w(p), [u, _] = w(n);
37
- return {
38
- delay: e,
39
- duration: a,
40
- easing: r,
41
- css: ($, h) => `
42
- transform: ${i} translate(${(1 - $) * y}${f}, ${(1 - $) * u}${_});
43
- opacity: ${d - o * h}`
44
- };
45
- }
46
- function L(t, { delay: e = 0, duration: a = 400, easing: r = m, axis: p = "y" } = {}) {
47
- const n = getComputedStyle(t), c = +n.opacity, s = p === "y" ? "height" : "width", d = parseFloat(n[s]), i = p === "y" ? ["top", "bottom"] : ["left", "right"], o = i.map(
48
- (l) => (
49
- /** @type {'Left' | 'Right' | 'Top' | 'Bottom'} */
50
- `${l[0].toUpperCase()}${l.slice(1)}`
51
- )
52
- ), y = parseFloat(n[`padding${o[0]}`]), f = parseFloat(n[`padding${o[1]}`]), u = parseFloat(n[`margin${o[0]}`]), _ = parseFloat(n[`margin${o[1]}`]), $ = parseFloat(
53
- n[`border${o[0]}Width`]
54
- ), h = parseFloat(
55
- n[`border${o[1]}Width`]
56
- );
57
- return {
58
- delay: e,
59
- duration: a,
60
- easing: r,
61
- css: (l) => `overflow: hidden;opacity: ${Math.min(l * 20, 1) * c};${s}: ${l * d}px;padding-${i[0]}: ${l * y}px;padding-${i[1]}: ${l * f}px;margin-${i[0]}: ${l * u}px;margin-${i[1]}: ${l * _}px;border-${i[0]}-width: ${l * $}px;border-${i[1]}-width: ${l * h}px;min-${s}: 0`
62
- };
63
- }
64
- function R(t, { delay: e = 0, duration: a = 400, easing: r = m, start: p = 0, opacity: n = 0 } = {}) {
65
- const c = getComputedStyle(t), s = +c.opacity, d = c.transform === "none" ? "" : c.transform, i = 1 - p, o = s * (1 - n);
66
- return {
67
- delay: e,
68
- duration: a,
69
- easing: r,
70
- css: (y, f) => `
71
- transform: ${d} scale(${1 - i * f});
72
- opacity: ${s - o * f}
73
- `
74
- };
75
- }
76
- function z(t, { delay: e = 0, speed: a, duration: r, easing: p = C } = {}) {
77
- let n = t.getTotalLength();
78
- const c = getComputedStyle(t);
79
- return c.strokeLinecap !== "butt" && (n += parseInt(c.strokeWidth)), r === void 0 ? a === void 0 ? r = 800 : r = n / a : typeof r == "function" && (r = r(n)), {
80
- delay: e,
81
- duration: r,
82
- easing: p,
83
- css: (s, d) => `
84
- stroke-dasharray: ${n};
85
- stroke-dashoffset: ${d * n};
86
- `
87
- };
88
- }
89
- function v(t, e) {
90
- for (const a in e) t[a] = e[a];
91
- return (
92
- /** @type {T & S} */
93
- t
94
- );
95
- }
96
- function I({ fallback: t, ...e }) {
97
- const a = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
98
- function p(c, s, d) {
99
- const {
100
- delay: i = 0,
101
- duration: o = (
102
- /** @param {number} d */
103
- (g) => Math.sqrt(g) * 30
104
- ),
105
- easing: y = m
106
- } = v(v({}, e), d), f = c.getBoundingClientRect(), u = s.getBoundingClientRect(), _ = f.left - u.left, $ = f.top - u.top, h = f.width / u.width, l = f.height / u.height, k = Math.sqrt(_ * _ + $ * $), x = getComputedStyle(s), F = x.transform === "none" ? "" : x.transform, S = +x.opacity;
107
- return {
108
- delay: i,
109
- duration: typeof o == "function" ? o(k) : o,
110
- easing: y,
111
- css: (g, b) => `
112
- opacity: ${g * S};
113
- transform-origin: top left;
114
- transform: ${F} translate(${b * _}px,${b * $}px) scale(${g + (1 - g) * h}, ${g + (1 - g) * l});
115
- `
116
- };
117
- }
118
- function n(c, s, d) {
119
- return (i, o) => (c.set(o.key, i), () => {
120
- if (s.has(o.key)) {
121
- const y = s.get(o.key);
122
- return s.delete(o.key), p(
123
- /** @type {Element} */
124
- y,
125
- i,
126
- o
127
- );
128
- }
129
- return c.delete(o.key), t && t(i, o, d);
130
- });
131
- }
132
- return [n(r, a, !1), n(a, r, !0)];
133
- }
134
- export {
135
- W as blur,
136
- I as crossfade,
137
- z as draw,
138
- q as fade,
139
- B as fly,
140
- R as scale,
141
- L as slide
142
- };