@cliquify.me/animations 6.0.9 → 6.0.11
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/dist/Animated.d.ts +1 -0
- package/dist/index.es.js +178 -177
- package/dist/index.umd.js +1 -1
- package/package.json +3 -3
package/dist/Animated.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export interface AnimatedProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
frame: number;
|
|
19
|
+
isTransition?: boolean;
|
|
19
20
|
}
|
|
20
21
|
export declare const BoxAnim: React.FC<AnimatedProps>;
|
|
21
22
|
export declare const combine: (...animations: (Animation | Animation[] | undefined)[]) => Animation[];
|
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { interpolate as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
+
import M, { useMemo as I } from "react";
|
|
3
|
+
import { interpolate as R } from "remotion";
|
|
4
|
+
const A = () => ({
|
|
5
5
|
scale: (t) => ({ transform: `scale(${t})` }),
|
|
6
6
|
opacity: (t) => ({ opacity: t }),
|
|
7
7
|
translateX: (t) => ({ transform: `translateX(${t}px)` }),
|
|
@@ -25,259 +25,260 @@ const E = () => ({
|
|
|
25
25
|
transform: `translateY(${t}px)`,
|
|
26
26
|
overflow: "hidden"
|
|
27
27
|
})
|
|
28
|
-
}),
|
|
28
|
+
}), j = (t, a = 0) => {
|
|
29
29
|
const e = [], s = t / 5;
|
|
30
30
|
for (let l = 0; l < 6; l += 1)
|
|
31
|
-
e.push(l * s +
|
|
31
|
+
e.push(l * s + a);
|
|
32
32
|
return e;
|
|
33
|
-
},
|
|
34
|
-
const { from: l, to:
|
|
35
|
-
if (isNaN(f) || isNaN(
|
|
33
|
+
}, C = (t, a, e, s = !1) => {
|
|
34
|
+
const { from: l, to: o, ease: c } = a, r = a.durationInFrames || 30, f = Number(l), i = Number(o), n = Math.max(1, Number(r));
|
|
35
|
+
if (isNaN(f) || isNaN(i))
|
|
36
36
|
return console.error("Invalid animation values:", {
|
|
37
37
|
from: l,
|
|
38
|
-
to:
|
|
39
|
-
animationDurationInFrames:
|
|
40
|
-
property:
|
|
38
|
+
to: o,
|
|
39
|
+
animationDurationInFrames: r,
|
|
40
|
+
property: a.property
|
|
41
41
|
}), f;
|
|
42
|
-
|
|
43
|
-
`durationInFrames is undefined for animation: ${
|
|
42
|
+
r === void 0 && console.warn(
|
|
43
|
+
`durationInFrames is undefined for animation: ${a.property}. Using 1 frame as default.`
|
|
44
44
|
);
|
|
45
|
-
const d = s ? [e -
|
|
46
|
-
if (
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
e -
|
|
50
|
-
) :
|
|
51
|
-
return
|
|
45
|
+
const d = s ? [e - r, e] : [0, n];
|
|
46
|
+
if (a.property.includes("shake")) {
|
|
47
|
+
const u = s ? j(
|
|
48
|
+
n,
|
|
49
|
+
e - r
|
|
50
|
+
) : j(n);
|
|
51
|
+
return R(
|
|
52
52
|
t,
|
|
53
|
-
|
|
54
|
-
[0, f,
|
|
53
|
+
u,
|
|
54
|
+
[0, f, i, f, i, 0],
|
|
55
55
|
{
|
|
56
56
|
extrapolateLeft: "clamp",
|
|
57
57
|
extrapolateRight: "clamp",
|
|
58
|
-
easing:
|
|
58
|
+
easing: c
|
|
59
59
|
}
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return R(t, d, [f, i], {
|
|
63
63
|
extrapolateLeft: "clamp",
|
|
64
64
|
extrapolateRight: "clamp",
|
|
65
|
-
easing:
|
|
65
|
+
easing: c
|
|
66
66
|
});
|
|
67
|
-
},
|
|
68
|
-
const l =
|
|
69
|
-
if (!s && l >
|
|
70
|
-
const
|
|
67
|
+
}, E = (t, a, e, s) => {
|
|
68
|
+
const l = a - (t.delay || 0) * (s ? -1 : 1) + (s ? 1 : 0), { property: o, durationInFrames: c } = t;
|
|
69
|
+
if (!s && l > c) return {};
|
|
70
|
+
const r = C(
|
|
71
71
|
l,
|
|
72
72
|
t,
|
|
73
73
|
e,
|
|
74
74
|
s
|
|
75
|
-
), f =
|
|
76
|
-
return (f[
|
|
77
|
-
},
|
|
75
|
+
), f = A();
|
|
76
|
+
return (f[o] || f.default)(r);
|
|
77
|
+
}, F = (t, a, e, s = !1, l = !1) => M.useMemo(() => {
|
|
78
78
|
if (t.length === 0) return {};
|
|
79
|
-
const
|
|
80
|
-
(
|
|
79
|
+
const o = t.filter(
|
|
80
|
+
(c) => c.from !== void 0 && c.to !== void 0
|
|
81
81
|
);
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const d =
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
Object.keys(
|
|
89
|
-
|
|
90
|
-
[
|
|
91
|
-
} :
|
|
82
|
+
if (o.length !== t.length && console.error("Some animations are invalid and will be ignored"), l) {
|
|
83
|
+
const c = [], r = {};
|
|
84
|
+
o.reverse().forEach((n) => {
|
|
85
|
+
const d = E(n, e, a, !1);
|
|
86
|
+
if (n.persist === !0 && e - (n.delay || 0) >= n.durationInFrames) {
|
|
87
|
+
const v = n.to, g = A(), p = (g[n.property] || g.default)(v);
|
|
88
|
+
Object.keys(p).forEach(($) => {
|
|
89
|
+
$ === "transform" ? r[$] = r[$] ? {
|
|
90
|
+
[$]: `${r[$][$]} ${p[$]}`
|
|
91
|
+
} : p : r[$] = p;
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
c.push(d);
|
|
95
95
|
});
|
|
96
|
-
const
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
}),
|
|
96
|
+
const i = { ...c.reduce(
|
|
97
|
+
(n, d) => (Object.keys(d).forEach((u) => {
|
|
98
|
+
u === "transform" ? n[u] = n[u] ? `${n[u]} ${d[u]}` : d[u] : n[u] = d[u];
|
|
99
|
+
}), n),
|
|
100
100
|
{}
|
|
101
101
|
) };
|
|
102
|
-
return Object.keys(
|
|
103
|
-
const d =
|
|
104
|
-
|
|
105
|
-
}),
|
|
102
|
+
return Object.keys(r).forEach((n) => {
|
|
103
|
+
const d = r[n];
|
|
104
|
+
n === "transform" && d.transform ? i.transform = i.transform ? `${i.transform} ${d.transform}` : d.transform : d[n] !== void 0 && (i[n] = d[n]);
|
|
105
|
+
}), i;
|
|
106
106
|
} else
|
|
107
|
-
return
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
}),
|
|
107
|
+
return o.map((r) => E(r, e, a, s)).reduce(
|
|
108
|
+
(r, f) => (Object.keys(f).forEach((i) => {
|
|
109
|
+
i === "transform" ? r[i] = r[i] ? `${r[i]} ${f[i]}` : f[i] : r[i] = f[i];
|
|
110
|
+
}), r),
|
|
111
111
|
{}
|
|
112
112
|
);
|
|
113
|
-
}, [t, e,
|
|
114
|
-
const
|
|
113
|
+
}, [t, e, a, s]), X = (t) => t ? Array.isArray(t) ? t : [t] : [], _ = (...t) => {
|
|
114
|
+
const a = [];
|
|
115
115
|
return t.forEach((e) => {
|
|
116
|
-
Array.isArray(e) ?
|
|
117
|
-
}),
|
|
118
|
-
(
|
|
116
|
+
Array.isArray(e) ? a.push(...e) : e && a.push(e);
|
|
117
|
+
}), a.filter((e) => e !== void 0).reduce((e, s) => e.find(
|
|
118
|
+
(o) => o.property === s.property
|
|
119
119
|
) ? e.map(
|
|
120
|
-
(
|
|
121
|
-
...
|
|
122
|
-
from: Math.min(
|
|
123
|
-
to: Math.max(
|
|
120
|
+
(o) => o.property === s.property ? {
|
|
121
|
+
...o,
|
|
122
|
+
from: Math.min(o.from, s.from),
|
|
123
|
+
to: Math.max(o.to, s.to),
|
|
124
124
|
durationInFrames: Math.max(
|
|
125
|
-
|
|
125
|
+
o.durationInFrames,
|
|
126
126
|
s.durationInFrames
|
|
127
127
|
),
|
|
128
|
-
delay: Math.min(
|
|
129
|
-
ease: (
|
|
128
|
+
delay: Math.min(o.delay || 0, s.delay || 0),
|
|
129
|
+
ease: (c) => (o.ease(c) + s.ease(c)) / 2
|
|
130
130
|
// Average the easing functions
|
|
131
|
-
} :
|
|
131
|
+
} : o
|
|
132
132
|
) : [...e, s], []);
|
|
133
|
-
},
|
|
133
|
+
}, z = ({
|
|
134
134
|
animationIn: t,
|
|
135
|
-
animationOut:
|
|
135
|
+
animationOut: a,
|
|
136
136
|
durationInFrames: e,
|
|
137
137
|
children: s,
|
|
138
138
|
style: l = {},
|
|
139
|
-
frame:
|
|
139
|
+
frame: o,
|
|
140
|
+
isTransition: c = !1
|
|
140
141
|
}) => {
|
|
141
|
-
var
|
|
142
|
-
const
|
|
143
|
-
|
|
142
|
+
var Y;
|
|
143
|
+
const r = F(
|
|
144
|
+
X(t),
|
|
144
145
|
e,
|
|
145
|
-
|
|
146
|
+
o,
|
|
146
147
|
!1
|
|
147
|
-
),
|
|
148
|
-
|
|
148
|
+
), f = F(
|
|
149
|
+
X(a),
|
|
149
150
|
e,
|
|
150
|
-
|
|
151
|
+
o,
|
|
151
152
|
!0
|
|
152
|
-
),
|
|
153
|
-
const
|
|
154
|
-
(
|
|
153
|
+
), i = M.useMemo(() => {
|
|
154
|
+
const h = Object.keys(r).length > 0, m = t == null ? void 0 : t.reduce(
|
|
155
|
+
(w, S) => Math.min(w, S.delay || 0),
|
|
155
156
|
1 / 0
|
|
156
|
-
),
|
|
157
|
-
return
|
|
158
|
-
}, [
|
|
159
|
-
const
|
|
160
|
-
(
|
|
161
|
-
const
|
|
162
|
-
return Math.max(
|
|
157
|
+
), b = o - (m || 0);
|
|
158
|
+
return h && b < 0 ? { visibility: c ? "visible" : "hidden" } : r;
|
|
159
|
+
}, [r, o, t]), n = M.useMemo(() => {
|
|
160
|
+
const h = (a == null ? void 0 : a.length) > 0, m = a == null ? void 0 : a.reduce(
|
|
161
|
+
(b, w) => {
|
|
162
|
+
const S = w.delay || 0;
|
|
163
|
+
return Math.max(b, S);
|
|
163
164
|
},
|
|
164
165
|
0
|
|
165
166
|
);
|
|
166
|
-
return
|
|
167
|
-
}, [
|
|
168
|
-
const
|
|
169
|
-
...
|
|
167
|
+
return h && o > e - m ? { visibility: c ? "visible" : "hidden" } : f;
|
|
168
|
+
}, [f, o, a]), u = ((l == null ? void 0 : l.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), v = u ? parseFloat(u[1]) : 0, g = -v, p = M.useMemo(() => {
|
|
169
|
+
const h = {
|
|
170
|
+
...i
|
|
170
171
|
// , ...timedStyle
|
|
171
172
|
};
|
|
172
|
-
return Object.entries(
|
|
173
|
-
|
|
174
|
-
}),
|
|
175
|
-
}, [
|
|
176
|
-
if ((
|
|
177
|
-
const
|
|
178
|
-
|
|
173
|
+
return Object.entries(n).forEach(([m, b]) => {
|
|
174
|
+
m === "transform" ? h[m] = `${h[m] || ""} ${b || ""}`.trim() : m in h && typeof h[m] == "number" && typeof b == "number" ? h[m] = h[m] * b : h[m] = b;
|
|
175
|
+
}), h;
|
|
176
|
+
}, [i, n]);
|
|
177
|
+
if ((Y = p.transform) != null && Y.includes("rotate")) {
|
|
178
|
+
const h = p.transform;
|
|
179
|
+
p.transform = h.replace(
|
|
179
180
|
/rotate\(([^)]+)deg\)/,
|
|
180
|
-
(
|
|
181
|
+
(m, b) => `rotate(${parseFloat(b) - g}deg)`
|
|
181
182
|
);
|
|
182
183
|
}
|
|
183
|
-
const
|
|
184
|
-
const
|
|
185
|
-
return `${
|
|
186
|
-
}, [
|
|
187
|
-
let
|
|
188
|
-
return
|
|
189
|
-
...
|
|
190
|
-
transform:
|
|
184
|
+
const $ = I(() => {
|
|
185
|
+
const h = p.transform || "", { translateX: m, translateY: b, scale: w, rotation: S, rotateY: V } = H(h);
|
|
186
|
+
return `${m} ${b} ${w} ${S || `rotate(${v}deg)`} ${V}`.trim();
|
|
187
|
+
}, [p, v]);
|
|
188
|
+
let y = r;
|
|
189
|
+
return v > 0 && y.transform && y.transform.includes("translateX") && (y = {
|
|
190
|
+
...y,
|
|
191
|
+
transform: y.transform.replace(
|
|
191
192
|
/translateX\(([^)]+)\)/g,
|
|
192
|
-
(
|
|
193
|
+
(h, m) => `translateX(${parseFloat(m)}px)`
|
|
193
194
|
)
|
|
194
|
-
}), /* @__PURE__ */
|
|
195
|
+
}), /* @__PURE__ */ x(
|
|
195
196
|
"div",
|
|
196
197
|
{
|
|
197
198
|
style: {
|
|
198
|
-
overflow:
|
|
199
|
+
overflow: p.overflow || "visible",
|
|
199
200
|
pointerEvents: "none",
|
|
200
|
-
...
|
|
201
|
-
transform: (
|
|
202
|
-
background: Object.keys(
|
|
201
|
+
...y,
|
|
202
|
+
transform: (y.transform || "") + ` -rotate(${g}deg) scale(1)`,
|
|
203
|
+
background: Object.keys(p).length === 0 ? "transparent" : p.backgroundColor,
|
|
203
204
|
display: "flex",
|
|
204
205
|
justifyContent: "center"
|
|
205
206
|
},
|
|
206
|
-
children: /* @__PURE__ */
|
|
207
|
+
children: /* @__PURE__ */ x(
|
|
207
208
|
"div",
|
|
208
209
|
{
|
|
209
210
|
style: {
|
|
210
211
|
...l,
|
|
211
|
-
...
|
|
212
|
-
rotate: `${
|
|
212
|
+
...p,
|
|
213
|
+
rotate: `${g}deg`,
|
|
213
214
|
overflow: "visible",
|
|
214
|
-
transform:
|
|
215
|
+
transform: $,
|
|
215
216
|
pointerEvents: "none",
|
|
216
|
-
background: Object.keys(
|
|
217
|
+
background: Object.keys(p).length === 0 ? "transparent" : p.backgroundColor
|
|
217
218
|
},
|
|
218
219
|
children: s
|
|
219
220
|
}
|
|
220
221
|
)
|
|
221
222
|
}
|
|
222
223
|
);
|
|
223
|
-
},
|
|
224
|
-
let
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
|
|
224
|
+
}, H = (t) => {
|
|
225
|
+
let a = "", e = "", s = "scale(1)", l = "", o = "";
|
|
226
|
+
const c = t.match(/translateX\([^)]+\)/);
|
|
227
|
+
c && (a = c[0]);
|
|
228
|
+
const r = t.match(/translateY\([^)]+\)/);
|
|
229
|
+
r && (e = r[0]);
|
|
229
230
|
const f = t.match(/scale\([^)]+\)/);
|
|
230
231
|
f && (s = f[0]);
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
const
|
|
234
|
-
return
|
|
235
|
-
},
|
|
232
|
+
const i = t.match(/rotate\([^)]+\)/);
|
|
233
|
+
i && (l = i[0]);
|
|
234
|
+
const n = t.match(/rotateY\([^)]+\)/);
|
|
235
|
+
return n && (o = n[0]), { translateX: a, translateY: e, scale: s, rotation: l, rotateY: o };
|
|
236
|
+
}, L = ({
|
|
236
237
|
animationTimed: t,
|
|
237
|
-
durationInFrames:
|
|
238
|
+
durationInFrames: a,
|
|
238
239
|
children: e,
|
|
239
240
|
style: s = {},
|
|
240
241
|
frame: l
|
|
241
242
|
}) => {
|
|
242
|
-
var
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
var u;
|
|
244
|
+
const o = F(
|
|
245
|
+
X(t),
|
|
246
|
+
a,
|
|
246
247
|
l,
|
|
247
248
|
!1,
|
|
248
249
|
!0
|
|
249
|
-
),
|
|
250
|
-
...
|
|
251
|
-
}), [
|
|
252
|
-
if ((
|
|
253
|
-
const
|
|
254
|
-
|
|
250
|
+
), r = ((s == null ? void 0 : s.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), f = r ? parseFloat(r[1]) : 0, i = -f, n = M.useMemo(() => ({
|
|
251
|
+
...o
|
|
252
|
+
}), [o]);
|
|
253
|
+
if ((u = n.transform) != null && u.includes("rotate")) {
|
|
254
|
+
const v = n.transform;
|
|
255
|
+
n.transform = v.replace(
|
|
255
256
|
/rotate\(([^)]+)deg\)/,
|
|
256
|
-
(
|
|
257
|
+
(g, p) => `rotate(${parseFloat(p) - i}deg)`
|
|
257
258
|
);
|
|
258
259
|
}
|
|
259
|
-
let d =
|
|
260
|
+
let d = n;
|
|
260
261
|
return f > 0 && d.transform && d.transform.includes("translateX") && (d = {
|
|
261
262
|
...d,
|
|
262
263
|
transform: d.transform.replace(
|
|
263
264
|
/translateX\(([^)]+)\)/g,
|
|
264
|
-
(
|
|
265
|
+
(v, g) => `translateX(${parseFloat(g)}px)`
|
|
265
266
|
)
|
|
266
|
-
}), /* @__PURE__ */
|
|
267
|
+
}), /* @__PURE__ */ x(
|
|
267
268
|
"div",
|
|
268
269
|
{
|
|
269
270
|
style: {
|
|
270
|
-
overflow:
|
|
271
|
+
overflow: n.overflow || "visible",
|
|
271
272
|
pointerEvents: "none",
|
|
272
273
|
height: s.height,
|
|
273
274
|
width: s.width,
|
|
274
275
|
...d
|
|
275
276
|
},
|
|
276
|
-
children: /* @__PURE__ */
|
|
277
|
+
children: /* @__PURE__ */ x(
|
|
277
278
|
"div",
|
|
278
279
|
{
|
|
279
280
|
style: {
|
|
280
|
-
...
|
|
281
|
+
...n,
|
|
281
282
|
overflow: "visible",
|
|
282
283
|
pointerEvents: "none",
|
|
283
284
|
height: "100%",
|
|
@@ -291,40 +292,40 @@ const E = () => ({
|
|
|
291
292
|
)
|
|
292
293
|
}
|
|
293
294
|
);
|
|
294
|
-
},
|
|
295
|
+
}, W = ({
|
|
295
296
|
children: t,
|
|
296
|
-
frame:
|
|
297
|
+
frame: a,
|
|
297
298
|
item: e,
|
|
298
299
|
keyframeAnimations: s
|
|
299
300
|
}) => {
|
|
300
|
-
var
|
|
301
|
+
var u, v;
|
|
301
302
|
const l = s == null ? void 0 : s.find(
|
|
302
|
-
(
|
|
303
|
-
),
|
|
304
|
-
let
|
|
305
|
-
if ((
|
|
306
|
-
|
|
307
|
-
else if ((
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
d =
|
|
311
|
-
} else (
|
|
312
|
-
return /* @__PURE__ */
|
|
303
|
+
(g) => g.property.includes("maskReveal")
|
|
304
|
+
), o = ((u = e.details.crop) == null ? void 0 : u.width) || e.details.width, c = ((v = e.details.crop) == null ? void 0 : v.height) || e.details.height;
|
|
305
|
+
let r = 1, f = c, i = 0, n = 0, d = o;
|
|
306
|
+
if ((a || 0) - e.display.from >= 0 && (l == null ? void 0 : l.property) === "maskRevealIn")
|
|
307
|
+
r = Math.min((a || 0) / l.durationInFrames, 1), f = c - c * (1 - r);
|
|
308
|
+
else if ((a || 0) - e.display.from >= 0 && (l == null ? void 0 : l.property) === "maskRevealCenterIn") {
|
|
309
|
+
r = Math.min((a || 0) / l.durationInFrames, 1);
|
|
310
|
+
const g = o / 2, p = c / 2;
|
|
311
|
+
d = o, f = c * r, i = g - d / 2, n = p - f / 2;
|
|
312
|
+
} else (a || 0) - e.display.from >= 0 && (l == null ? void 0 : l.property) === "maskRevealCornerIn" && (r = Math.min((a || 0) / l.durationInFrames, 1), d = o * r, f = c * r, i = o - d, n = 0);
|
|
313
|
+
return /* @__PURE__ */ x(
|
|
313
314
|
"div",
|
|
314
315
|
{
|
|
315
316
|
style: {
|
|
316
|
-
width:
|
|
317
|
-
height:
|
|
317
|
+
width: o,
|
|
318
|
+
height: c,
|
|
318
319
|
position: "relative",
|
|
319
320
|
overflow: "hidden"
|
|
320
321
|
},
|
|
321
|
-
children: /* @__PURE__ */
|
|
322
|
+
children: /* @__PURE__ */ x(
|
|
322
323
|
"div",
|
|
323
324
|
{
|
|
324
325
|
style: {
|
|
325
326
|
position: "absolute",
|
|
326
|
-
left:
|
|
327
|
-
top:
|
|
327
|
+
left: i,
|
|
328
|
+
top: n,
|
|
328
329
|
width: d,
|
|
329
330
|
height: f,
|
|
330
331
|
overflow: "hidden"
|
|
@@ -336,11 +337,11 @@ const E = () => ({
|
|
|
336
337
|
);
|
|
337
338
|
};
|
|
338
339
|
export {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
340
|
+
z as BoxAnim,
|
|
341
|
+
L as ContentAnim,
|
|
342
|
+
W as MaskAnim,
|
|
343
|
+
_ as combine,
|
|
344
|
+
X as combineAnimations,
|
|
345
|
+
H as extractTransformations,
|
|
346
|
+
F as useAnimation
|
|
346
347
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(v,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("react/jsx-runtime"),require("react"),require("remotion")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","remotion"],S):(v=typeof globalThis<"u"?globalThis:v||self,S(v.animations={},v.jsxRuntime,v.React,v.remotion))})(this,function(v,S,x,X){"use strict";const Y=()=>({scale:t=>({transform:`scale(${t})`}),opacity:t=>({opacity:t}),translateX:t=>({transform:`translateX(${t}px)`}),translateY:t=>({transform:`translateY(${t}px)`}),rotate:t=>({transform:`rotate(${t}deg)`}),default:()=>({}),rotateY:t=>({transform:`rotateY(${t}deg)`}),shakeHorizontalIn:t=>({transform:`translateX(${t}px)`,overflow:"hidden"}),shakeVerticalIn:t=>({transform:`translateY(${t}px)`,overflow:"hidden"}),shakeHorizontalOut:t=>({transform:`translateX(${t}px)`,overflow:"hidden"}),shakeVerticalOut:t=>({transform:`translateY(${t}px)`,overflow:"hidden"})}),E=(t,s=0)=>{const e=[],a=t/5;for(let l=0;l<6;l+=1)e.push(l*a+s);return e},C=(t,s,e,a=!1)=>{const{from:l,to:n,ease:c}=s,r=s.durationInFrames||30,d=Number(l),i=Number(n),o=Math.max(1,Number(r));if(isNaN(d)||isNaN(i))return console.error("Invalid animation values:",{from:l,to:n,animationDurationInFrames:r,property:s.property}),d;r===void 0&&console.warn(`durationInFrames is undefined for animation: ${s.property}. Using 1 frame as default.`);const f=a?[e-r,e]:[0,o];if(s.property.includes("shake")){const p=a?E(o,e-r):E(o);return X.interpolate(t,p,[0,d,i,d,i,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:c})}return X.interpolate(t,f,[d,i],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:c})},V=(t,s,e,a)=>{const l=s-(t.delay||0)*(a?-1:1)+(a?1:0),{property:n,durationInFrames:c}=t;if(!a&&l>c)return{};const r=C(l,t,e,a),d=Y();return(d[n]||d.default)(r)},A=(t,s,e,a=!1,l=!1)=>x.useMemo(()=>{if(t.length===0)return{};const n=t.filter(c=>c.from!==void 0&&c.to!==void 0);if(n.length!==t.length&&console.error("Some animations are invalid and will be ignored"),l){const c=[],r={};n.reverse().forEach(o=>{const f=V(o,e,s,!1);if(o.persist===!0&&e-(o.delay||0)>=o.durationInFrames){const g=o.to,b=Y(),u=(b[o.property]||b.default)(g);Object.keys(u).forEach($=>{$==="transform"?r[$]=r[$]?{[$]:`${r[$][$]} ${u[$]}`}:u:r[$]=u})}c.push(f)});const i={...c.reduce((o,f)=>(Object.keys(f).forEach(p=>{p==="transform"?o[p]=o[p]?`${o[p]} ${f[p]}`:f[p]:o[p]=f[p]}),o),{})};return Object.keys(r).forEach(o=>{const f=r[o];o==="transform"&&f.transform?i.transform=i.transform?`${i.transform} ${f.transform}`:f.transform:f[o]!==void 0&&(i[o]=f[o])}),i}else return n.map(r=>V(r,e,s,a)).reduce((r,d)=>(Object.keys(d).forEach(i=>{i==="transform"?r[i]=r[i]?`${r[i]} ${d[i]}`:d[i]:r[i]=d[i]}),r),{})},[t,e,s,a]),F=t=>t?Array.isArray(t)?t:[t]:[],H=(...t)=>{const s=[];return t.forEach(e=>{Array.isArray(e)?s.push(...e):e&&s.push(e)}),s.filter(e=>e!==void 0).reduce((e,a)=>e.find(n=>n.property===a.property)?e.map(n=>n.property===a.property?{...n,from:Math.min(n.from,a.from),to:Math.max(n.to,a.to),durationInFrames:Math.max(n.durationInFrames,a.durationInFrames),delay:Math.min(n.delay||0,a.delay||0),ease:c=>(n.ease(c)+a.ease(c))/2}:n):[...e,a],[])},N=({animationIn:t,animationOut:s,durationInFrames:e,children:a,style:l={},frame:n,isTransition:c=!1})=>{var T;const r=A(F(t),e,n,!1),d=A(F(s),e,n,!0),i=x.useMemo(()=>{const h=Object.keys(r).length>0,m=t==null?void 0:t.reduce((M,j)=>Math.min(M,j.delay||0),1/0),y=n-(m||0);return h&&y<0?{visibility:c?"visible":"hidden"}:r},[r,n,t]),o=x.useMemo(()=>{const h=(s==null?void 0:s.length)>0,m=s==null?void 0:s.reduce((y,M)=>{const j=M.delay||0;return Math.max(y,j)},0);return h&&n>e-m?{visibility:c?"visible":"hidden"}:d},[d,n,s]),p=((l==null?void 0:l.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),g=p?parseFloat(p[1]):0,b=-g,u=x.useMemo(()=>{const h={...i};return Object.entries(o).forEach(([m,y])=>{m==="transform"?h[m]=`${h[m]||""} ${y||""}`.trim():m in h&&typeof h[m]=="number"&&typeof y=="number"?h[m]=h[m]*y:h[m]=y}),h},[i,o]);if((T=u.transform)!=null&&T.includes("rotate")){const h=u.transform;u.transform=h.replace(/rotate\(([^)]+)deg\)/,(m,y)=>`rotate(${parseFloat(y)-b}deg)`)}const $=x.useMemo(()=>{const h=u.transform||"",{translateX:m,translateY:y,scale:M,rotation:j,rotateY:_}=I(h);return`${m} ${y} ${M} ${j||`rotate(${g}deg)`} ${_}`.trim()},[u,g]);let w=r;return g>0&&w.transform&&w.transform.includes("translateX")&&(w={...w,transform:w.transform.replace(/translateX\(([^)]+)\)/g,(h,m)=>`translateX(${parseFloat(m)}px)`)}),S.jsx("div",{style:{overflow:u.overflow||"visible",pointerEvents:"none",...w,transform:(w.transform||"")+` -rotate(${b}deg) scale(1)`,background:Object.keys(u).length===0?"transparent":u.backgroundColor,display:"flex",justifyContent:"center"},children:S.jsx("div",{style:{...l,...u,rotate:`${b}deg`,overflow:"visible",transform:$,pointerEvents:"none",background:Object.keys(u).length===0?"transparent":u.backgroundColor},children:a})})},I=t=>{let s="",e="",a="scale(1)",l="",n="";const c=t.match(/translateX\([^)]+\)/);c&&(s=c[0]);const r=t.match(/translateY\([^)]+\)/);r&&(e=r[0]);const d=t.match(/scale\([^)]+\)/);d&&(a=d[0]);const i=t.match(/rotate\([^)]+\)/);i&&(l=i[0]);const o=t.match(/rotateY\([^)]+\)/);return o&&(n=o[0]),{translateX:s,translateY:e,scale:a,rotation:l,rotateY:n}},R=({animationTimed:t,durationInFrames:s,children:e,style:a={},frame:l})=>{var p;const n=A(F(t),s,l,!1,!0),r=((a==null?void 0:a.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),d=r?parseFloat(r[1]):0,i=-d,o=x.useMemo(()=>({...n}),[n]);if((p=o.transform)!=null&&p.includes("rotate")){const g=o.transform;o.transform=g.replace(/rotate\(([^)]+)deg\)/,(b,u)=>`rotate(${parseFloat(u)-i}deg)`)}let f=o;return d>0&&f.transform&&f.transform.includes("translateX")&&(f={...f,transform:f.transform.replace(/translateX\(([^)]+)\)/g,(g,b)=>`translateX(${parseFloat(b)}px)`)}),S.jsx("div",{style:{overflow:o.overflow||"visible",pointerEvents:"none",height:a.height,width:a.width,...f},children:S.jsx("div",{style:{...o,overflow:"visible",pointerEvents:"none",height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:e})})},D=({children:t,frame:s,item:e,keyframeAnimations:a})=>{var p,g;const l=a==null?void 0:a.find(b=>b.property.includes("maskReveal")),n=((p=e.details.crop)==null?void 0:p.width)||e.details.width,c=((g=e.details.crop)==null?void 0:g.height)||e.details.height;let r=1,d=c,i=0,o=0,f=n;if((s||0)-e.display.from>=0&&(l==null?void 0:l.property)==="maskRevealIn")r=Math.min((s||0)/l.durationInFrames,1),d=c-c*(1-r);else if((s||0)-e.display.from>=0&&(l==null?void 0:l.property)==="maskRevealCenterIn"){r=Math.min((s||0)/l.durationInFrames,1);const b=n/2,u=c/2;f=n,d=c*r,i=b-f/2,o=u-d/2}else(s||0)-e.display.from>=0&&(l==null?void 0:l.property)==="maskRevealCornerIn"&&(r=Math.min((s||0)/l.durationInFrames,1),f=n*r,d=c*r,i=n-f,o=0);return S.jsx("div",{style:{width:n,height:c,position:"relative",overflow:"hidden"},children:S.jsx("div",{style:{position:"absolute",left:i,top:o,width:f,height:d,overflow:"hidden"},children:t})})};v.BoxAnim=N,v.ContentAnim=R,v.MaskAnim=D,v.combine=H,v.combineAnimations=F,v.extractTransformations=I,v.useAnimation=A,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cliquify.me/animations",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"typescript": "^5.3.3",
|
|
27
27
|
"vite": "^5.2.0",
|
|
28
28
|
"vite-plugin-dts": "^3.9.1",
|
|
29
|
-
"@cliquify.me/types": "5.0.
|
|
29
|
+
"@cliquify.me/types": "5.0.8",
|
|
30
30
|
"@cliquify.me/typescript-config": "0.0.2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@designcombo/events": "^1.0.2",
|
|
40
40
|
"react": "^18.2.0",
|
|
41
41
|
"remotion": "4.0.221",
|
|
42
|
-
"@cliquify.me/types": "5.0.
|
|
42
|
+
"@cliquify.me/types": "5.0.8"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"dev": "vite",
|