@cliquify.me/animations 9.0.10 → 9.0.12

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,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { ICompositionAnimation } from '@cliquify.me/types';
2
3
 
3
4
  export interface Animation {
4
5
  property: keyof React.CSSProperties | string;
@@ -18,6 +19,8 @@ export interface AnimatedProps {
18
19
  style?: React.CSSProperties;
19
20
  frame: number;
20
21
  isTransition?: boolean;
22
+ basicCharAnimationsIn?: ICompositionAnimation[];
23
+ basicCharAnimationsOut?: ICompositionAnimation[];
21
24
  }
22
25
  export declare const BoxAnim: React.FC<AnimatedProps>;
23
26
  export declare const combine: (...animations: (Animation | Animation[] | undefined)[]) => Animation[];
package/dist/index.es.js CHANGED
@@ -1,16 +1,37 @@
1
- import { jsx as y } from "react/jsx-runtime";
2
- import X, { useMemo as D } from "react";
3
- import { interpolate as O, Easing as w } from "remotion";
4
- const _ = () => ({
1
+ import { jsx as N, Fragment as H } from "react/jsx-runtime";
2
+ import C, { useMemo as W } from "react";
3
+ import { interpolate as B, Easing as A } from "remotion";
4
+ const z = () => ({
5
5
  scale: (t) => ({ transform: `scale(${t})` }),
6
+ growIn: (t) => ({ transform: `scale(${t})` }),
7
+ shrinkIn: (t) => ({ transform: `scale(${t})` }),
8
+ shrinkOut: (t) => ({ transform: `scale(${t})` }),
6
9
  opacity: (t) => ({ opacity: t }),
7
10
  translateX: (t) => ({ transform: `translateX(${t}%)` }),
8
11
  translateY: (t) => ({ transform: `translateY(${t}%)` }),
9
12
  rotate: (t) => ({ transform: `rotate(${t}deg)` }),
13
+ spin: (t) => ({ transform: `rotate(${t}deg)` }),
14
+ spinIn: (t) => ({ transform: `rotate(${t}deg)` }),
15
+ twistIn: (t) => ({ transform: `rotate(${t}deg)` }),
16
+ twistOut: (t) => ({ transform: `rotate(${t}deg)` }),
17
+ moveScaleIn: (t) => ({
18
+ transform: `scale(${t})`
19
+ }),
20
+ spinOut: (t) => ({ transform: `rotate(${t}deg)` }),
10
21
  default: () => ({}),
11
22
  rotateY: (t) => ({ transform: `rotateY(${t}deg)` }),
12
23
  rotateX: (t) => ({ transform: `rotateX(${t}deg)` }),
13
24
  blur: (t) => ({ filter: `blur(${t}px)` }),
25
+ blurIn: (t) => ({ filter: `blur(${t}px)` }),
26
+ blurOut: (t) => ({ filter: `blur(${t}px)` }),
27
+ blurV2In: (t) => ({ filter: `blur(${t}px)` }),
28
+ blurSlide: (t) => ({
29
+ filter: `blur(${t}px)`,
30
+ transform: `translateY(${t * 5}%)`
31
+ }),
32
+ blurSlideV2In: (t) => ({
33
+ filter: `blur(${t}px)`
34
+ }),
14
35
  brightness: (t) => ({ filter: `brightness(${t}%)` }),
15
36
  contrast: (t) => ({ filter: `contrast(${t}%)` }),
16
37
  grayscale: (t) => ({ filter: `grayscale(${t}%)` }),
@@ -43,276 +64,345 @@ const _ = () => ({
43
64
  }),
44
65
  shakeVerticalOut: (t) => ({
45
66
  transform: `translateY(${t}px)`
46
- })
47
- }), A = (t, l = 0) => {
48
- const o = [], f = t / 5;
49
- for (let r = 0; r < 6; r += 1)
50
- o.push(r * f + l);
51
- return o;
52
- }, Z = (t, l, o, f = !1) => {
53
- const { from: r, to: a, ease: h } = l, n = l.durationInFrames || 30, c = Number(r), i = Number(a), e = Math.max(1, Number(n));
54
- if (isNaN(c) || isNaN(i))
67
+ }),
68
+ maskUpIn: (t) => ({
69
+ transform: `translateY(${t}px)`,
70
+ overflow: "hidden"
71
+ }),
72
+ maskUpOut: (t) => ({
73
+ transform: `translateY(${t}px)`,
74
+ overflow: "hidden"
75
+ }),
76
+ maskDownIn: (t) => ({
77
+ transform: `translateY(${t}px)`,
78
+ overflow: "hidden"
79
+ }),
80
+ maskDownOut: (t) => ({
81
+ transform: `translateY(${t}px)`,
82
+ overflow: "hidden"
83
+ }),
84
+ moveTranslateY: (t) => ({ transform: `translateY(${t}%)` })
85
+ }), Z = (t, f = 0) => {
86
+ const s = [], c = t / 5;
87
+ for (let m = 0; m < 6; m += 1)
88
+ s.push(m * c + f);
89
+ return s;
90
+ }, q = (t, f, s, c = !1) => {
91
+ const { from: m, to: a, ease: $ } = f, u = f.durationInFrames || 30, p = Number(m), o = Number(a), e = Math.max(1, Number(u));
92
+ if (isNaN(p) || isNaN(o))
55
93
  return console.error("Invalid animation values:", {
56
- from: r,
94
+ from: m,
57
95
  to: a,
58
- animationDurationInFrames: n,
59
- property: l.property
60
- }), c;
61
- n === void 0 && console.warn(
62
- `durationInFrames is undefined for animation: ${l.property}. Using 1 frame as default.`
96
+ animationDurationInFrames: u,
97
+ property: f.property
98
+ }), p;
99
+ u === void 0 && console.warn(
100
+ `durationInFrames is undefined for animation: ${f.property}. Using 1 frame as default.`
63
101
  );
64
- const s = l.delay || 0, u = f ? [o - e - s, o - s] : [s, s + e];
65
- if (l.property.includes("shake")) {
66
- const d = f ? A(
102
+ const n = f.delay || 0;
103
+ let l;
104
+ if (f.property === "moveScaleIn" ? l = c ? [
105
+ s - e - n,
106
+ s - e * 0.5 - n
107
+ ] : [
108
+ n + e * 0.5,
109
+ n + e
110
+ ] : f.property === "moveTranslateY" ? l = c ? [
111
+ s - e * 0.5 - n,
112
+ s - n
113
+ ] : [
114
+ n,
115
+ n + e * 0.5
116
+ ] : l = c ? [
117
+ s - e - n,
118
+ s - n
119
+ ] : [
120
+ n,
121
+ n + e
122
+ ], f.property.includes("shake")) {
123
+ const d = c ? Z(
67
124
  e,
68
- o - e - s
69
- ) : A(e, s);
70
- return O(
125
+ s - e - n
126
+ ) : Z(e, n);
127
+ return B(
71
128
  t,
72
129
  d,
73
- [0, c, i, c, i, 0],
130
+ [0, p, o, p, o, 0],
74
131
  {
75
132
  extrapolateLeft: "clamp",
76
133
  extrapolateRight: "clamp",
77
- easing: h
134
+ easing: $
78
135
  }
79
136
  );
80
137
  }
81
- return O(t, u, [c, i], {
138
+ return B(t, l, [p, o], {
82
139
  extrapolateLeft: "clamp",
83
140
  extrapolateRight: "clamp",
84
- easing: h
141
+ easing: $
85
142
  });
86
- }, I = (t, l, o, f) => {
87
- const { property: r } = t, a = Z(l, t, o, f), h = _();
88
- return (h[r] || h.default)(a);
89
- }, V = (t, l, o, f = !1, r = !1) => X.useMemo(() => {
143
+ }, U = (t, f, s, c) => {
144
+ var u, p, o, e, n;
145
+ const { property: m } = t;
146
+ if (m === "move") {
147
+ const l = Number(((u = t.details) == null ? void 0 : u.fromX) ?? t.from ?? 0), d = Number(((p = t.details) == null ? void 0 : p.toX) ?? t.to ?? 0), S = Number(((o = t.details) == null ? void 0 : o.fromY) ?? 0), M = Number(((e = t.details) == null ? void 0 : e.toY) ?? 0), x = Number(((n = t.details) == null ? void 0 : n.scale) || 1) || 1, Y = t.delay || 0, V = t.durationInFrames || 30, y = c ? [s - V - Y, s - Y] : [Y, Y + V], F = B(f, y, [l, d], {
148
+ extrapolateLeft: "clamp",
149
+ extrapolateRight: "clamp",
150
+ easing: t.ease
151
+ }), i = B(f, y, [S, M], {
152
+ extrapolateLeft: "clamp",
153
+ extrapolateRight: "clamp",
154
+ easing: t.ease
155
+ }), X = F / x, g = i / x;
156
+ return {
157
+ transform: `translateX(${X}px) translateY(${g}px)`
158
+ };
159
+ }
160
+ const a = q(f, t, s, c), $ = z();
161
+ return ($[m] || $.default)(a);
162
+ }, I = (t, f, s, c = !1, m = !1) => C.useMemo(() => {
90
163
  if (t.length === 0) return {};
91
164
  const a = t.filter(
92
- (h) => h.from !== void 0 && h.to !== void 0
165
+ ($) => $.from !== void 0 && $.to !== void 0
93
166
  );
94
- if (a.length !== t.length && console.error("Some animations are invalid and will be ignored"), r) {
95
- const h = [], n = {};
167
+ if (a.length !== t.length && console.error("Some animations are invalid and will be ignored"), m) {
168
+ const $ = [], u = {};
96
169
  a.reverse().forEach((e) => {
97
- const s = I(e, o, l, !1);
98
- if (e.persist === !0 && o - (e.delay || 0) >= e.durationInFrames) {
99
- const d = e.to, v = _(), p = (v[e.property] || v.default)(d);
100
- Object.keys(p).forEach(($) => {
101
- $ === "transform" ? n[$] = n[$] ? {
102
- [$]: `${n[$][$]} ${p[$]}`
103
- } : p : n[$] = p;
170
+ const n = U(e, s, f, !1);
171
+ if (e.persist === !0 && s - (e.delay || 0) >= e.durationInFrames) {
172
+ const d = e.to, S = z(), M = e.property === "move" ? (() => {
173
+ var i, X, g;
174
+ const x = Number(((i = e.details) == null ? void 0 : i.toX) ?? e.to ?? 0), Y = Number(((X = e.details) == null ? void 0 : X.toY) ?? 0), V = Number(((g = e.details) == null ? void 0 : g.scale) || 1) || 1, y = x / V, F = Y / V;
175
+ return {
176
+ transform: `translateX(${y}px) translateY(${F}px)`
177
+ };
178
+ })() : (S[e.property] || S.default)(d);
179
+ Object.keys(M).forEach((x) => {
180
+ x === "transform" ? u[x] = u[x] ? {
181
+ [x]: `${u[x][x]} ${M[x]}`
182
+ } : M : u[x] = M;
104
183
  });
105
184
  }
106
- h.push(s);
185
+ $.push(n);
107
186
  });
108
- const i = { ...h.reduce(
109
- (e, s) => (Object.keys(s).forEach((u) => {
110
- u === "transform" || u === "filter" ? e[u] = e[u] ? `${e[u]} ${s[u]}` : s[u] : e[u] = s[u];
187
+ const o = { ...$.reduce(
188
+ (e, n) => (Object.keys(n).forEach((l) => {
189
+ l === "transform" || l === "filter" ? e[l] = e[l] ? `${e[l]} ${n[l]}` : n[l] : e[l] = n[l];
111
190
  }), e),
112
191
  {}
113
192
  ) };
114
- return Object.keys(n).forEach((e) => {
115
- const s = n[e];
116
- (e === "transform" || e === "filter") && s[e] ? i[e] = i[e] ? `${i[e]} ${s[e]}` : String(s[e]) : s[e] !== void 0 && (i[e] = s[e]);
117
- }), i;
193
+ return Object.keys(u).forEach((e) => {
194
+ const n = u[e];
195
+ (e === "transform" || e === "filter") && n[e] ? o[e] = o[e] ? `${o[e]} ${n[e]}` : String(n[e]) : n[e] !== void 0 && (o[e] = n[e]);
196
+ }), o;
118
197
  } else
119
- return a.map((n) => I(n, o, l, f)).reduce(
120
- (n, c) => (Object.keys(c).forEach((i) => {
121
- i === "transform" || i === "filter" ? n[i] = n[i] ? `${n[i]} ${c[i]}` : c[i] : n[i] = c[i];
122
- }), n),
198
+ return a.map((u) => U(u, s, f, c)).reduce(
199
+ (u, p) => (Object.keys(p).forEach((o) => {
200
+ o === "transform" || o === "filter" ? u[o] = u[o] ? `${u[o]} ${p[o]}` : p[o] : u[o] = p[o];
201
+ }), u),
123
202
  {}
124
203
  );
125
- }, [t, o, l, f]), Y = (t) => t ? Array.isArray(t) ? t : [t] : [], q = (...t) => {
126
- const l = [];
127
- return t.forEach((o) => {
128
- Array.isArray(o) ? l.push(...o) : o && l.push(o);
129
- }), l.filter((o) => o !== void 0).reduce((o, f) => o.find(
130
- (a) => a.property === f.property
131
- ) ? o.map(
132
- (a) => a.property === f.property ? {
204
+ }, [t, s, f, c]), j = (t) => t ? Array.isArray(t) ? t : [t] : [], et = (...t) => {
205
+ const f = [];
206
+ return t.forEach((s) => {
207
+ Array.isArray(s) ? f.push(...s) : s && f.push(s);
208
+ }), f.filter((s) => s !== void 0).reduce((s, c) => s.find(
209
+ (a) => a.property === c.property
210
+ ) ? s.map(
211
+ (a) => a.property === c.property ? {
133
212
  ...a,
134
- from: Math.min(a.from, f.from),
135
- to: Math.max(a.to, f.to),
213
+ from: Math.min(a.from, c.from),
214
+ to: Math.max(a.to, c.to),
136
215
  durationInFrames: Math.max(
137
216
  a.durationInFrames,
138
- f.durationInFrames
217
+ c.durationInFrames
139
218
  ),
140
- delay: Math.min(a.delay || 0, f.delay || 0),
141
- ease: (h) => (a.ease(h) + f.ease(h)) / 2
219
+ delay: Math.min(a.delay || 0, c.delay || 0),
220
+ ease: ($) => (a.ease($) + c.ease($)) / 2
142
221
  // Average the easing functions
143
222
  } : a
144
- ) : [...o, f], []);
145
- }, G = ({
223
+ ) : [...s, c], []);
224
+ }, rt = ({
146
225
  animationIn: t,
147
- animationOut: l,
148
- durationInFrames: o,
149
- children: f,
150
- style: r = {},
226
+ animationOut: f,
227
+ durationInFrames: s,
228
+ children: c,
229
+ style: m = {},
151
230
  frame: a,
152
- isTransition: h = !1
231
+ isTransition: $ = !1,
232
+ basicCharAnimationsIn: u = [],
233
+ basicCharAnimationsOut: p = []
153
234
  }) => {
154
- var j;
155
- const n = V(
156
- Y(t),
157
- o,
235
+ var b;
236
+ const o = I(
237
+ j(t),
238
+ s,
158
239
  a,
159
240
  !1
160
- ), c = V(
161
- Y(l),
162
- o,
241
+ ), e = I(
242
+ j(f),
243
+ s,
244
+ a,
245
+ !0
246
+ ), n = I(
247
+ j(u),
248
+ s,
249
+ a,
250
+ !0
251
+ ), l = I(
252
+ j(p),
253
+ s,
163
254
  a,
164
255
  !0
165
- ), i = X.useMemo(() => {
166
- const m = Object.keys(n).length > 0, g = t == null ? void 0 : t.reduce(
167
- (S, M) => Math.min(S, M.delay || 0),
256
+ ), d = C.useMemo(() => {
257
+ const h = Object.keys(o).length > 0, v = t == null ? void 0 : t.reduce(
258
+ (O, R) => Math.min(O, R.delay || 0),
168
259
  1 / 0
169
- ), b = a - (g || 0);
170
- return m && b < 0 ? { visibility: h ? "visible" : "hidden" } : n;
171
- }, [n, a, t]), e = X.useMemo(() => {
172
- if (a > o)
173
- return { visibility: h ? "visible" : "hidden" };
174
- const m = Y(l);
175
- if (!m || m.length === 0) return {};
176
- let g = 0;
177
- m.forEach((S) => {
178
- const M = (S.durationInFrames || 0) + (S.delay || 0);
179
- M > g && (g = M);
260
+ ), w = a - (v || 0);
261
+ return h && w < 0 ? { visibility: $ ? "visible" : "hidden" } : o;
262
+ }, [o, a, t]), S = C.useMemo(() => {
263
+ if (a > s)
264
+ return { visibility: $ ? "visible" : "hidden" };
265
+ const h = j(f);
266
+ if (!h || h.length === 0) return {};
267
+ let v = 0;
268
+ h.forEach((O) => {
269
+ const R = (O.durationInFrames || 0) + (O.delay || 0);
270
+ R > v && (v = R);
180
271
  });
181
- const b = Math.max(0, o - g);
182
- return a < b ? {} : c;
183
- }, [c, a, l, o, h]), u = ((r == null ? void 0 : r.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), d = u ? parseFloat(u[1]) : 0, v = -d, p = X.useMemo(() => {
184
- const m = {
185
- ...i
272
+ const w = Math.max(0, s - v);
273
+ return a < w ? {} : e;
274
+ }, [e, a, f, s, $]), x = ((m == null ? void 0 : m.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), Y = x ? parseFloat(x[1]) : 0, V = -Y, y = C.useMemo(() => {
275
+ const h = {
276
+ ...d
186
277
  // , ...timedStyle
187
278
  };
188
- return Object.entries(e).forEach(([g, b]) => {
189
- g === "transform" ? m[g] = `${m[g] || ""} ${b || ""}`.trim() : g in m && typeof m[g] == "number" && typeof b == "number" ? m[g] = m[g] * b : m[g] = b;
190
- }), m;
191
- }, [i, e]);
192
- if ((j = p.transform) != null && j.includes("rotate")) {
193
- const m = p.transform;
194
- p.transform = m.replace(
279
+ return Object.entries(S).forEach(([v, w]) => {
280
+ v === "transform" ? h[v] = `${h[v] || ""} ${w || ""}`.trim() : v in h && typeof h[v] == "number" && typeof w == "number" ? h[v] = h[v] * w : h[v] = w;
281
+ }), h;
282
+ }, [d, S]);
283
+ if ((b = y.transform) != null && b.includes("rotate")) {
284
+ const h = y.transform;
285
+ y.transform = h.replace(
195
286
  /rotate\(([^)]+)deg\)/,
196
- (g, b) => `rotate(${parseFloat(b) - v}deg)`
287
+ (v, w) => `rotate(${parseFloat(w) - V}deg)`
197
288
  );
198
289
  }
199
- const $ = D(() => {
200
- const m = p.transform || "", {
201
- translateX: g,
202
- translateY: b,
203
- scale: S,
204
- rotation: M,
205
- rotateX: N,
206
- rotateY: T,
207
- rotateZ: C
208
- } = L(m);
209
- return `${g} ${b} ${S} ${M || `rotate(${d}deg)`} ${N} ${T} ${C}`.trim();
210
- }, [p, d]);
211
- let x = n;
212
- d > 0 && x.transform && x.transform.includes("translateX") && (x = {
213
- ...x,
214
- transform: x.transform.replace(
290
+ const F = W(() => {
291
+ const h = y.transform || "", {
292
+ translateX: v,
293
+ translateY: w,
294
+ scale: O,
295
+ rotation: R,
296
+ rotateX: P,
297
+ rotateY: r,
298
+ rotateZ: E
299
+ } = G(h);
300
+ return `${v} ${w} ${O} ${R || `rotate(${Y}deg)`} ${P} ${r} ${E}`.trim();
301
+ }, [y, Y]);
302
+ let i = o;
303
+ Y > 0 && i.transform && i.transform.includes("translateX") && (i = {
304
+ ...i,
305
+ transform: i.transform.replace(
215
306
  /translateX\(([^)]+)\)/g,
216
- (m, g) => `translateX(${parseFloat(g)}%)`
307
+ (h, v) => `translateX(${parseFloat(v)}%)`
217
308
  )
218
309
  });
219
310
  const {
220
- top: E,
221
- left: F,
222
- position: P,
223
- transform: z,
224
- ...H
225
- } = r || {};
226
- return /* @__PURE__ */ y(
311
+ top: X,
312
+ left: g,
313
+ position: T,
314
+ transform: _,
315
+ ...L
316
+ } = m || {};
317
+ return /* @__PURE__ */ N(
227
318
  "div",
228
319
  {
229
320
  style: {
230
321
  width: "100%",
231
322
  height: "100%",
232
- overflow: p.overflow || "visible",
323
+ overflow: y.overflow || n.overflow || l.overflow || "visible",
233
324
  pointerEvents: "none"
234
325
  },
235
- children: /* @__PURE__ */ y(
326
+ children: /* @__PURE__ */ N(
236
327
  "div",
237
328
  {
238
329
  style: {
239
330
  width: "100%",
240
331
  height: "100%",
241
- ...H,
242
- ...p,
243
- rotate: `${v}deg`,
332
+ ...L,
333
+ ...y,
334
+ rotate: `${V}deg`,
244
335
  overflow: "visible",
245
- transform: $,
336
+ transform: F,
246
337
  pointerEvents: "none",
247
- background: Object.keys(p).length === 0 ? "transparent" : p.backgroundColor
338
+ background: Object.keys(y).length === 0 ? "transparent" : y.backgroundColor
248
339
  },
249
- children: f
340
+ children: c
250
341
  }
251
342
  )
252
343
  }
253
344
  );
254
- }, L = (t) => {
255
- let l = "", o = "", f = "scale(1)", r = "", a = "", h = "", n = "";
256
- const c = t.match(/translateX\([^)]+\)/g);
257
- c && (l = c[c.length - 1]);
258
- const i = t.match(/translateY\([^)]+\)/g);
259
- i && (o = i[i.length - 1]);
345
+ }, G = (t) => {
346
+ let f = "", s = "", c = "scale(1)", m = "", a = "", $ = "", u = "";
347
+ const p = t.match(/translateX\([^)]+\)/g);
348
+ p && (f = p[p.length - 1]);
349
+ const o = t.match(/translateY\([^)]+\)/g);
350
+ o && (s = o[o.length - 1]);
260
351
  const e = t.match(/scale\([^)]+\)/g);
261
- e && (f = e[e.length - 1]);
262
- const s = t.match(/rotate\([^)]+\)/g);
263
- s && (r = s[s.length - 1]);
264
- const u = t.match(/rotateX\([^)]+\)/g);
265
- u && (a = u[u.length - 1]);
352
+ e && (c = e[e.length - 1]);
353
+ const n = t.match(/rotate\([^)]+\)/g);
354
+ n && (m = n[n.length - 1]);
355
+ const l = t.match(/rotateX\([^)]+\)/g);
356
+ l && (a = l[l.length - 1]);
266
357
  const d = t.match(/rotateY\([^)]+\)/g);
267
- d && (h = d[d.length - 1]);
268
- const v = t.match(/rotateZ\([^)]+\)/g);
269
- return v && (n = v[v.length - 1]), { translateX: l, translateY: o, scale: f, rotation: r, rotateX: a, rotateY: h, rotateZ: n };
270
- }, J = ({
358
+ d && ($ = d[d.length - 1]);
359
+ const S = t.match(/rotateZ\([^)]+\)/g);
360
+ return S && (u = S[S.length - 1]), { translateX: f, translateY: s, scale: c, rotation: m, rotateX: a, rotateY: $, rotateZ: u };
361
+ }, st = ({
271
362
  animationTimed: t,
272
- durationInFrames: l,
273
- children: o,
274
- style: f = {},
275
- frame: r
363
+ durationInFrames: f,
364
+ children: s,
365
+ style: c = {},
366
+ frame: m
276
367
  }) => {
277
- var u;
278
- const a = V(
279
- Y(t),
280
- l,
281
- r,
368
+ var l;
369
+ const a = I(
370
+ j(t),
371
+ f,
372
+ m,
282
373
  !1,
283
374
  !0
284
- ), n = ((f == null ? void 0 : f.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), c = n ? parseFloat(n[1]) : 0, i = -c, e = X.useMemo(() => ({
375
+ ), u = ((c == null ? void 0 : c.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), p = u ? parseFloat(u[1]) : 0, o = -p, e = C.useMemo(() => ({
285
376
  ...a
286
377
  }), [a]);
287
- if ((u = e.transform) != null && u.includes("rotate")) {
378
+ if ((l = e.transform) != null && l.includes("rotate")) {
288
379
  const d = e.transform;
289
380
  e.transform = d.replace(
290
381
  /rotate\(([^)]+)deg\)/,
291
- (v, p) => `rotate(${parseFloat(p) - i}deg)`
382
+ (S, M) => `rotate(${parseFloat(M) - o}deg)`
292
383
  );
293
384
  }
294
- let s = e;
295
- return c > 0 && s.transform && s.transform.includes("translateX") && (s = {
296
- ...s,
297
- transform: s.transform.replace(
385
+ let n = e;
386
+ return p > 0 && n.transform && n.transform.includes("translateX") && (n = {
387
+ ...n,
388
+ transform: n.transform.replace(
298
389
  /translateX\(([^)]+)\)/g,
299
- (d, v) => `translateX(${parseFloat(v)}px)`
390
+ (d, S) => `translateX(${parseFloat(S)}%)`
300
391
  )
301
- }), /* @__PURE__ */ y(
392
+ }), /* @__PURE__ */ N(
302
393
  "div",
303
394
  {
304
395
  style: {
305
396
  overflow: e.overflow || "visible",
306
397
  pointerEvents: "none",
307
- height: f.height,
308
- width: f.width,
309
- ...s
398
+ height: c.height || "100%",
399
+ width: c.width || "100%",
400
+ ...n
310
401
  },
311
- children: /* @__PURE__ */ y(
402
+ children: /* @__PURE__ */ N(
312
403
  "div",
313
404
  {
314
405
  style: {
315
- ...e,
316
406
  overflow: "visible",
317
407
  pointerEvents: "none",
318
408
  height: "100%",
@@ -321,81 +411,183 @@ const _ = () => ({
321
411
  alignItems: "center",
322
412
  justifyContent: "center"
323
413
  },
324
- children: o
414
+ children: s
325
415
  }
326
416
  )
327
417
  }
328
418
  );
329
- }, R = (t) => {
330
- if (typeof (t == null ? void 0 : t.ease) == "function") return t.ease;
419
+ }, J = (t) => {
420
+ if (typeof (t == null ? void 0 : t.ease) == "function")
421
+ return t.ease;
331
422
  switch (t == null ? void 0 : t.easing) {
332
423
  case "ease-in":
333
- return w.in(w.cubic);
424
+ case "accelerate":
425
+ return A.in(A.cubic);
334
426
  case "ease-out":
335
- return w.out(w.cubic);
427
+ case "smooth":
428
+ case "slowDown":
429
+ return A.out(A.cubic);
336
430
  case "ease-in-out":
337
- return w.inOut(w.cubic);
431
+ case "natural":
432
+ case "swing":
433
+ return A.inOut(A.cubic);
434
+ case "bounce":
435
+ return A.bounce;
436
+ case "elastic":
437
+ return A.elastic(1);
438
+ case "overshoot":
439
+ case "impulse":
440
+ return A.out(A.back(1.7));
441
+ case "none":
338
442
  case "linear":
339
443
  default:
340
- return w.linear;
444
+ return A.linear;
341
445
  }
342
446
  }, K = ({
343
447
  children: t,
344
- frame: l,
345
- item: o,
346
- keyframeAnimations: f
448
+ currentWidth: f,
449
+ currentHeight: s,
450
+ frame: c,
451
+ item: m,
452
+ keyframeAnimations: a,
453
+ durationInFrames: $
347
454
  }) => {
348
- var $, x, E;
349
- const r = f ? [...f].reverse().find((F) => F.property.includes("maskReveal")) : void 0, a = (($ = o.details.crop) == null ? void 0 : $.width) || o.details.width, h = ((x = o.details.crop) == null ? void 0 : x.height) || o.details.height;
350
- let n = 1, c = n, i = h, e = 0, s = 0, u = a, d;
351
- (l || 0) >= 0 && (r == null ? void 0 : r.property) === "maskRevealIn" ? (n = Math.min((l || 0) / r.durationInFrames, 1), c = Math.max(0, Math.min(1, R(r)(n))), i = h * c) : (l || 0) >= 0 && (r == null ? void 0 : r.property) === "maskRevealCenterIn" ? (n = Math.min((l || 0) / r.durationInFrames, 1), c = Math.max(0, Math.min(1, R(r)(n))), u = a, i = h, e = 0, s = 0, d = `circle(${Math.max(a, h) * c}px at 50% 50%)`) : (l || 0) >= 0 && (r == null ? void 0 : r.property) === "maskRevealCornerIn" && (n = Math.min((l || 0) / r.durationInFrames, 1), c = Math.max(0, Math.min(1, R(r)(n))), u = a * c, i = h * c, e = a - u, s = 0);
352
- const v = !!((E = r == null ? void 0 : r.details) != null && E.scale || r != null && r.scale), p = v ? r != null && r.property.includes("Out") ? 1 - 0.2 * c : 0.8 + 0.2 * c : 1;
353
- return /* @__PURE__ */ y(
455
+ var R, P;
456
+ if (!a || !Array.isArray(a) || a.length === 0)
457
+ return /* @__PURE__ */ N(H, { children: t });
458
+ const u = (r) => {
459
+ var E, D;
460
+ return !!((E = r == null ? void 0 : r.property) != null && E.includes("maskReveal") || (D = r == null ? void 0 : r.id) != null && D.includes("maskReveal"));
461
+ }, p = (r) => {
462
+ var E, D;
463
+ return !!((r == null ? void 0 : r.type) === "exit" || (E = r == null ? void 0 : r.property) != null && E.includes("Out") || (D = r == null ? void 0 : r.id) != null && D.includes("Out"));
464
+ }, o = a.find(
465
+ (r) => u(r) && !p(r)
466
+ ), e = a.find(
467
+ (r) => u(r) && p(r)
468
+ );
469
+ if (!o && !e)
470
+ return /* @__PURE__ */ N(H, { children: t });
471
+ const n = Math.max(1, $ || 300);
472
+ let l = null, d = !1, S = 30, M = 0;
473
+ if (e) {
474
+ const r = Math.max(1, Number(e.durationInFrames || 30)), E = Math.max(0, Number(e.delay || 0)), D = Math.max(0, n - r - E);
475
+ c >= D && (l = e, d = !0, S = r, M = c - D);
476
+ }
477
+ if (!l && o) {
478
+ l = o, d = !1, S = Math.max(1, Number(o.durationInFrames || 30));
479
+ const r = Math.max(0, Number(o.delay || 0));
480
+ M = c - r;
481
+ }
482
+ if (!l)
483
+ return /* @__PURE__ */ N(H, { children: t });
484
+ const x = o ? Math.max(0, Number(o.delay || 0)) : 0, Y = o ? Math.max(1, Number(o.durationInFrames || 30)) : 30;
485
+ if (!d && o && c >= x + Y)
486
+ return /* @__PURE__ */ N(
487
+ "div",
488
+ {
489
+ style: {
490
+ width: "100%",
491
+ height: "100%",
492
+ position: "relative",
493
+ overflow: "visible"
494
+ },
495
+ children: t
496
+ }
497
+ );
498
+ if (!d && o && c < x)
499
+ return /* @__PURE__ */ N(
500
+ "div",
501
+ {
502
+ style: {
503
+ width: "100%",
504
+ height: "100%",
505
+ position: "relative",
506
+ visibility: "hidden"
507
+ },
508
+ children: t
509
+ }
510
+ );
511
+ const V = Math.max(0, M), y = Math.min(Math.max(0, V / S), 1), F = J(l), i = Math.max(0, Math.min(1, F(y))), X = String(l.property || l.id || ""), g = ((R = l.details) == null ? void 0 : R.direction) || "up", T = X.includes("ShrinkScale"), _ = X.includes("CenterScale"), L = X.includes("Slide") || X.includes("slide");
512
+ let b, h = "";
513
+ if (_) {
514
+ const r = d ? 50 * i : 50 * (1 - i);
515
+ b = `inset(
516
+ ${r}%
517
+ 0%
518
+ ${r}%
519
+ 0%
520
+ )`;
521
+ } else if (T) {
522
+ const r = d ? 25 * i : 25 * (1 - i);
523
+ b = `inset(
524
+ ${r}%
525
+ ${r}%
526
+ ${r}%
527
+ ${r}%
528
+ )`;
529
+ } else if (L)
530
+ b = "inset(0% 0% 0% 0%)", d ? g === "down" ? h = `translateY(${100 * i}%)` : g === "left" ? h = `translateX(${-100 * i}%)` : g === "right" ? h = `translateX(${100 * i}%)` : h = `translateY(${-100 * i}%)` : g === "down" ? h = `translateY(${-100 * (1 - i)}%)` : g === "left" ? h = `translateX(${100 * (1 - i)}%)` : g === "right" ? h = `translateX(${-100 * (1 - i)}%)` : h = `translateY(${100 * (1 - i)}%)`;
531
+ else if (X.includes("Center"))
532
+ b = `circle(${d ? 150 * (1 - i) : 150 * i}% at 50% 50%)`;
533
+ else if (X.includes("Corner")) {
534
+ const r = d ? i : 1 - i;
535
+ g === "down" ? b = `inset(0 ${100 * r}% ${100 * r}% 0)` : g === "up" ? b = `inset(${100 * r}% ${100 * r}% 0 0)` : g === "left" ? b = `inset(0 0 ${100 * r}% ${100 * r}%)` : g === "right" ? b = `inset(${100 * r}% 0 0 ${100 * r}%)` : b = `inset(0 ${100 * r}% ${100 * r}% 0)`;
536
+ } else
537
+ d ? g === "down" ? b = `inset(${100 * i}% 0 0 0)` : g === "left" ? b = `inset(0 ${100 * i}% 0 0)` : g === "right" ? b = `inset(0 0 0 ${100 * i}%)` : b = `inset(0 0 ${100 * i}% 0)` : g === "down" ? b = `inset(0 0 ${100 * (1 - i)}% 0)` : g === "left" ? b = `inset(0 0 0 ${100 * (1 - i)}%)` : g === "right" ? b = `inset(0 ${100 * (1 - i)}% 0 0)` : b = `inset(${100 * (1 - i)}% 0 0 0)`;
538
+ const v = !!((P = l == null ? void 0 : l.details) != null && P.scale || l != null && l.scale);
539
+ let w = 1;
540
+ _ || T ? w = d ? 1 + 0.5 * i : 1.5 - 0.5 * i : v && (w = d ? 1 - 0.2 * i : 0.8 + 0.2 * i);
541
+ const O = [h, `scale(${w})`].filter(Boolean).join(" ");
542
+ return console.log("[MaskAnim] Rendering:", {
543
+ propName: X,
544
+ frame: c,
545
+ localFrame: M,
546
+ animDuration: S,
547
+ progress: y,
548
+ easedProgress: i,
549
+ isOut: d,
550
+ isShrinkScale: T,
551
+ isCenterScale: _,
552
+ isSlide: L,
553
+ direction: g,
554
+ clipPath: b,
555
+ translateTransform: h,
556
+ isScale: v,
557
+ scaleValue: w,
558
+ innerTransform: O
559
+ }), /* @__PURE__ */ N(
354
560
  "div",
355
561
  {
356
562
  style: {
357
- width: a,
358
- height: h,
563
+ width: f !== void 0 ? f : "100%",
564
+ height: s !== void 0 ? s : "100%",
359
565
  position: "relative",
360
- overflow: c < 1 ? "hidden" : "visible"
566
+ clipPath: b,
567
+ WebkitClipPath: b,
568
+ overflow: "hidden"
361
569
  },
362
- children: /* @__PURE__ */ y(
570
+ children: /* @__PURE__ */ N(
363
571
  "div",
364
572
  {
365
573
  style: {
366
- position: "absolute",
367
- left: e,
368
- top: s,
369
- width: u,
370
- height: i,
371
- overflow: c < 1 ? "hidden" : "visible",
372
- clipPath: d
574
+ width: "100%",
575
+ height: "100%",
576
+ transform: O,
577
+ transformOrigin: "center"
373
578
  },
374
- children: /* @__PURE__ */ y(
375
- "div",
376
- {
377
- style: {
378
- width: "100%",
379
- height: "100%",
380
- ...v ? {
381
- transform: `scale(${p})`,
382
- transformOrigin: "center"
383
- } : {}
384
- },
385
- children: t
386
- }
387
- )
579
+ children: t
388
580
  }
389
581
  )
390
582
  }
391
583
  );
392
- };
584
+ }, ot = K;
393
585
  export {
394
- G as BoxAnim,
395
- J as ContentAnim,
396
- K as MaskAnim,
397
- q as combine,
398
- Y as combineAnimations,
399
- L as extractTransformations,
400
- V as useAnimation
586
+ rt as BoxAnim,
587
+ st as ContentAnim,
588
+ ot as MaskAnim,
589
+ et as combine,
590
+ j as combineAnimations,
591
+ G as extractTransformations,
592
+ I as useAnimation
401
593
  };
package/dist/index.umd.js CHANGED
@@ -1 +1,11 @@
1
- (function(v,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react/jsx-runtime"),require("react"),require("remotion")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","remotion"],x):(v=typeof globalThis<"u"?globalThis:v||self,x(v.animations={},v.jsxRuntime,v.React,v.remotion))})(this,function(v,x,X,y){"use strict";const O=()=>({scale:t=>({transform:`scale(${t})`}),opacity:t=>({opacity:t}),translateX:t=>({transform:`translateX(${t}%)`}),translateY:t=>({transform:`translateY(${t}%)`}),rotate:t=>({transform:`rotate(${t}deg)`}),default:()=>({}),rotateY:t=>({transform:`rotateY(${t}deg)`}),rotateX:t=>({transform:`rotateX(${t}deg)`}),blur:t=>({filter:`blur(${t}px)`}),brightness:t=>({filter:`brightness(${t}%)`}),contrast:t=>({filter:`contrast(${t}%)`}),grayscale:t=>({filter:`grayscale(${t}%)`}),hue:t=>({filter:`hue-rotate(${t}deg)`}),saturation:t=>({filter:`saturate(${t}%)`}),vignette:t=>({filter:`contrast(${100+t*20}%) brightness(${100-t*20}%)`}),noise:t=>({filter:`contrast(${100+t*40}%) brightness(${100+t*20}%)`}),pixelate:t=>({filter:`contrast(${100+t*2}%)`}),chromaticAberration:t=>({filter:`hue-rotate(${t*10}deg) contrast(110%)`}),lightLeak:t=>({filter:`brightness(${100+t*50}%) saturate(${100+t*30}%)`}),duotone:t=>({filter:`sepia(${t*100}%) hue-rotate(${t*180}deg)`}),shakeHorizontalIn:t=>({transform:`translateX(${t}px)`}),shakeVerticalIn:t=>({transform:`translateY(${t}px)`}),shakeHorizontalOut:t=>({transform:`translateX(${t}px)`}),shakeVerticalOut:t=>({transform:`translateY(${t}px)`})}),T=(t,l=0)=>{const n=[],f=t/5;for(let r=0;r<6;r+=1)n.push(r*f+l);return n},N=(t,l,n,f=!1)=>{const{from:r,to:a,ease:u}=l,o=l.durationInFrames||30,c=Number(r),i=Number(a),e=Math.max(1,Number(o));if(isNaN(c)||isNaN(i))return console.error("Invalid animation values:",{from:r,to:a,animationDurationInFrames:o,property:l.property}),c;o===void 0&&console.warn(`durationInFrames is undefined for animation: ${l.property}. Using 1 frame as default.`);const s=l.delay||0,h=f?[n-e-s,n-s]:[s,s+e];if(l.property.includes("shake")){const d=f?T(e,n-e-s):T(e,s);return y.interpolate(t,d,[0,c,i,c,i,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:u})}return y.interpolate(t,h,[c,i],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:u})},I=(t,l,n,f)=>{const{property:r}=t,a=N(l,t,n,f),u=O();return(u[r]||u.default)(a)},Y=(t,l,n,f=!1,r=!1)=>X.useMemo(()=>{if(t.length===0)return{};const a=t.filter(u=>u.from!==void 0&&u.to!==void 0);if(a.length!==t.length&&console.error("Some animations are invalid and will be ignored"),r){const u=[],o={};a.reverse().forEach(e=>{const s=I(e,n,l,!1);if(e.persist===!0&&n-(e.delay||0)>=e.durationInFrames){const d=e.to,$=O(),p=($[e.property]||$.default)(d);Object.keys(p).forEach(b=>{b==="transform"?o[b]=o[b]?{[b]:`${o[b][b]} ${p[b]}`}:p:o[b]=p})}u.push(s)});const i={...u.reduce((e,s)=>(Object.keys(s).forEach(h=>{h==="transform"||h==="filter"?e[h]=e[h]?`${e[h]} ${s[h]}`:s[h]:e[h]=s[h]}),e),{})};return Object.keys(o).forEach(e=>{const s=o[e];(e==="transform"||e==="filter")&&s[e]?i[e]=i[e]?`${i[e]} ${s[e]}`:String(s[e]):s[e]!==void 0&&(i[e]=s[e])}),i}else return a.map(o=>I(o,n,l,f)).reduce((o,c)=>(Object.keys(c).forEach(i=>{i==="transform"||i==="filter"?o[i]=o[i]?`${o[i]} ${c[i]}`:c[i]:o[i]=c[i]}),o),{})},[t,n,l,f]),j=t=>t?Array.isArray(t)?t:[t]:[],C=(...t)=>{const l=[];return t.forEach(n=>{Array.isArray(n)?l.push(...n):n&&l.push(n)}),l.filter(n=>n!==void 0).reduce((n,f)=>n.find(a=>a.property===f.property)?n.map(a=>a.property===f.property?{...a,from:Math.min(a.from,f.from),to:Math.max(a.to,f.to),durationInFrames:Math.max(a.durationInFrames,f.durationInFrames),delay:Math.min(a.delay||0,f.delay||0),ease:u=>(a.ease(u)+f.ease(u))/2}:a):[...n,f],[])},D=({animationIn:t,animationOut:l,durationInFrames:n,children:f,style:r={},frame:a,isTransition:u=!1})=>{var H;const o=Y(j(t),n,a,!1),c=Y(j(l),n,a,!0),i=X.useMemo(()=>{const g=Object.keys(o).length>0,m=t==null?void 0:t.reduce((M,E)=>Math.min(M,E.delay||0),1/0),S=a-(m||0);return g&&S<0?{visibility:u?"visible":"hidden"}:o},[o,a,t]),e=X.useMemo(()=>{if(a>n)return{visibility:u?"visible":"hidden"};const g=j(l);if(!g||g.length===0)return{};let m=0;g.forEach(M=>{const E=(M.durationInFrames||0)+(M.delay||0);E>m&&(m=E)});const S=Math.max(0,n-m);return a<S?{}:c},[c,a,l,n,u]),h=((r==null?void 0:r.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),d=h?parseFloat(h[1]):0,$=-d,p=X.useMemo(()=>{const g={...i};return Object.entries(e).forEach(([m,S])=>{m==="transform"?g[m]=`${g[m]||""} ${S||""}`.trim():m in g&&typeof g[m]=="number"&&typeof S=="number"?g[m]=g[m]*S:g[m]=S}),g},[i,e]);if((H=p.transform)!=null&&H.includes("rotate")){const g=p.transform;p.transform=g.replace(/rotate\(([^)]+)deg\)/,(m,S)=>`rotate(${parseFloat(S)-$}deg)`)}const b=X.useMemo(()=>{const g=p.transform||"",{translateX:m,translateY:S,scale:M,rotation:E,rotateX:q,rotateY:B,rotateZ:L}=_(g);return`${m} ${S} ${M} ${E||`rotate(${d}deg)`} ${q} ${B} ${L}`.trim()},[p,d]);let w=o;d>0&&w.transform&&w.transform.includes("translateX")&&(w={...w,transform:w.transform.replace(/translateX\(([^)]+)\)/g,(g,m)=>`translateX(${parseFloat(m)}%)`)});const{top:F,left:V,position:z,transform:W,...Z}=r||{};return x.jsx("div",{style:{width:"100%",height:"100%",overflow:p.overflow||"visible",pointerEvents:"none"},children:x.jsx("div",{style:{width:"100%",height:"100%",...Z,...p,rotate:`${$}deg`,overflow:"visible",transform:b,pointerEvents:"none",background:Object.keys(p).length===0?"transparent":p.backgroundColor},children:f})})},_=t=>{let l="",n="",f="scale(1)",r="",a="",u="",o="";const c=t.match(/translateX\([^)]+\)/g);c&&(l=c[c.length-1]);const i=t.match(/translateY\([^)]+\)/g);i&&(n=i[i.length-1]);const e=t.match(/scale\([^)]+\)/g);e&&(f=e[e.length-1]);const s=t.match(/rotate\([^)]+\)/g);s&&(r=s[s.length-1]);const h=t.match(/rotateX\([^)]+\)/g);h&&(a=h[h.length-1]);const d=t.match(/rotateY\([^)]+\)/g);d&&(u=d[d.length-1]);const $=t.match(/rotateZ\([^)]+\)/g);return $&&(o=$[$.length-1]),{translateX:l,translateY:n,scale:f,rotation:r,rotateX:a,rotateY:u,rotateZ:o}},P=({animationTimed:t,durationInFrames:l,children:n,style:f={},frame:r})=>{var h;const a=Y(j(t),l,r,!1,!0),o=((f==null?void 0:f.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),c=o?parseFloat(o[1]):0,i=-c,e=X.useMemo(()=>({...a}),[a]);if((h=e.transform)!=null&&h.includes("rotate")){const d=e.transform;e.transform=d.replace(/rotate\(([^)]+)deg\)/,($,p)=>`rotate(${parseFloat(p)-i}deg)`)}let s=e;return c>0&&s.transform&&s.transform.includes("translateX")&&(s={...s,transform:s.transform.replace(/translateX\(([^)]+)\)/g,(d,$)=>`translateX(${parseFloat($)}px)`)}),x.jsx("div",{style:{overflow:e.overflow||"visible",pointerEvents:"none",height:f.height,width:f.width,...s},children:x.jsx("div",{style:{...e,overflow:"visible",pointerEvents:"none",height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:n})})},A=t=>{if(typeof(t==null?void 0:t.ease)=="function")return t.ease;switch(t==null?void 0:t.easing){case"ease-in":return y.Easing.in(y.Easing.cubic);case"ease-out":return y.Easing.out(y.Easing.cubic);case"ease-in-out":return y.Easing.inOut(y.Easing.cubic);case"linear":default:return y.Easing.linear}},R=({children:t,frame:l,item:n,keyframeAnimations:f})=>{var b,w,F;const r=f?[...f].reverse().find(V=>V.property.includes("maskReveal")):void 0,a=((b=n.details.crop)==null?void 0:b.width)||n.details.width,u=((w=n.details.crop)==null?void 0:w.height)||n.details.height;let o=1,c=o,i=u,e=0,s=0,h=a,d;(l||0)>=0&&(r==null?void 0:r.property)==="maskRevealIn"?(o=Math.min((l||0)/r.durationInFrames,1),c=Math.max(0,Math.min(1,A(r)(o))),i=u*c):(l||0)>=0&&(r==null?void 0:r.property)==="maskRevealCenterIn"?(o=Math.min((l||0)/r.durationInFrames,1),c=Math.max(0,Math.min(1,A(r)(o))),h=a,i=u,e=0,s=0,d=`circle(${Math.max(a,u)*c}px at 50% 50%)`):(l||0)>=0&&(r==null?void 0:r.property)==="maskRevealCornerIn"&&(o=Math.min((l||0)/r.durationInFrames,1),c=Math.max(0,Math.min(1,A(r)(o))),h=a*c,i=u*c,e=a-h,s=0);const $=!!((F=r==null?void 0:r.details)!=null&&F.scale||r!=null&&r.scale),p=$?r!=null&&r.property.includes("Out")?1-.2*c:.8+.2*c:1;return x.jsx("div",{style:{width:a,height:u,position:"relative",overflow:c<1?"hidden":"visible"},children:x.jsx("div",{style:{position:"absolute",left:e,top:s,width:h,height:i,overflow:c<1?"hidden":"visible",clipPath:d},children:x.jsx("div",{style:{width:"100%",height:"100%",...$?{transform:`scale(${p})`,transformOrigin:"center"}:{}},children:t})})})};v.BoxAnim=D,v.ContentAnim=P,v.MaskAnim=R,v.combine=C,v.combineAnimations=j,v.extractTransformations=_,v.useAnimation=Y,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(Y,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react/jsx-runtime"),require("react"),require("remotion")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","remotion"],w):(Y=typeof globalThis<"u"?globalThis:Y||self,w(Y.animations={},Y.jsxRuntime,Y.React,Y.remotion))})(this,function(Y,w,I,X){"use strict";const Z=()=>({scale:t=>({transform:`scale(${t})`}),growIn:t=>({transform:`scale(${t})`}),shrinkIn:t=>({transform:`scale(${t})`}),shrinkOut:t=>({transform:`scale(${t})`}),opacity:t=>({opacity:t}),translateX:t=>({transform:`translateX(${t}%)`}),translateY:t=>({transform:`translateY(${t}%)`}),rotate:t=>({transform:`rotate(${t}deg)`}),spin:t=>({transform:`rotate(${t}deg)`}),spinIn:t=>({transform:`rotate(${t}deg)`}),twistIn:t=>({transform:`rotate(${t}deg)`}),twistOut:t=>({transform:`rotate(${t}deg)`}),moveScaleIn:t=>({transform:`scale(${t})`}),spinOut:t=>({transform:`rotate(${t}deg)`}),default:()=>({}),rotateY:t=>({transform:`rotateY(${t}deg)`}),rotateX:t=>({transform:`rotateX(${t}deg)`}),blur:t=>({filter:`blur(${t}px)`}),blurIn:t=>({filter:`blur(${t}px)`}),blurOut:t=>({filter:`blur(${t}px)`}),blurV2In:t=>({filter:`blur(${t}px)`}),blurSlide:t=>({filter:`blur(${t}px)`,transform:`translateY(${t*5}%)`}),blurSlideV2In:t=>({filter:`blur(${t}px)`}),brightness:t=>({filter:`brightness(${t}%)`}),contrast:t=>({filter:`contrast(${t}%)`}),grayscale:t=>({filter:`grayscale(${t}%)`}),hue:t=>({filter:`hue-rotate(${t}deg)`}),saturation:t=>({filter:`saturate(${t}%)`}),vignette:t=>({filter:`contrast(${100+t*20}%) brightness(${100-t*20}%)`}),noise:t=>({filter:`contrast(${100+t*40}%) brightness(${100+t*20}%)`}),pixelate:t=>({filter:`contrast(${100+t*2}%)`}),chromaticAberration:t=>({filter:`hue-rotate(${t*10}deg) contrast(110%)`}),lightLeak:t=>({filter:`brightness(${100+t*50}%) saturate(${100+t*30}%)`}),duotone:t=>({filter:`sepia(${t*100}%) hue-rotate(${t*180}deg)`}),shakeHorizontalIn:t=>({transform:`translateX(${t}px)`}),shakeVerticalIn:t=>({transform:`translateY(${t}px)`}),shakeHorizontalOut:t=>({transform:`translateX(${t}px)`}),shakeVerticalOut:t=>({transform:`translateY(${t}px)`}),maskUpIn:t=>({transform:`translateY(${t}px)`,overflow:"hidden"}),maskUpOut:t=>({transform:`translateY(${t}px)`,overflow:"hidden"}),maskDownIn:t=>({transform:`translateY(${t}px)`,overflow:"hidden"}),maskDownOut:t=>({transform:`translateY(${t}px)`,overflow:"hidden"}),moveTranslateY:t=>({transform:`translateY(${t}%)`})}),q=(t,f=0)=>{const s=[],c=t/5;for(let $=0;$<6;$+=1)s.push($*c+f);return s},z=(t,f,s,c=!1)=>{const{from:$,to:o,ease:g}=f,u=f.durationInFrames||30,p=Number($),n=Number(o),e=Math.max(1,Number(u));if(isNaN(p)||isNaN(n))return console.error("Invalid animation values:",{from:$,to:o,animationDurationInFrames:u,property:f.property}),p;u===void 0&&console.warn(`durationInFrames is undefined for animation: ${f.property}. Using 1 frame as default.`);const a=f.delay||0;let l;if(f.property==="moveScaleIn"?l=c?[s-e-a,s-e*.5-a]:[a+e*.5,a+e]:f.property==="moveTranslateY"?l=c?[s-e*.5-a,s-a]:[a,a+e*.5]:l=c?[s-e-a,s-a]:[a,a+e],f.property.includes("shake")){const d=c?q(e,s-e-a):q(e,a);return X.interpolate(t,d,[0,p,n,p,n,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:g})}return X.interpolate(t,l,[p,n],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:g})},U=(t,f,s,c)=>{var u,p,n,e,a;const{property:$}=t;if($==="move"){const l=Number(((u=t.details)==null?void 0:u.fromX)??t.from??0),d=Number(((p=t.details)==null?void 0:p.toX)??t.to??0),S=Number(((n=t.details)==null?void 0:n.fromY)??0),A=Number(((e=t.details)==null?void 0:e.toY)??0),x=Number(((a=t.details)==null?void 0:a.scale)||1)||1,E=t.delay||0,O=t.durationInFrames||30,M=c?[s-O-E,s-E]:[E,E+O],C=X.interpolate(f,M,[l,d],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:t.ease}),i=X.interpolate(f,M,[S,A],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:t.ease}),N=C/x,m=i/x;return{transform:`translateX(${N}px) translateY(${m}px)`}}const o=z(f,t,s,c),g=Z();return(g[$]||g.default)(o)},P=(t,f,s,c=!1,$=!1)=>I.useMemo(()=>{if(t.length===0)return{};const o=t.filter(g=>g.from!==void 0&&g.to!==void 0);if(o.length!==t.length&&console.error("Some animations are invalid and will be ignored"),$){const g=[],u={};o.reverse().forEach(e=>{const a=U(e,s,f,!1);if(e.persist===!0&&s-(e.delay||0)>=e.durationInFrames){const d=e.to,S=Z(),A=e.property==="move"?(()=>{var i,N,m;const x=Number(((i=e.details)==null?void 0:i.toX)??e.to??0),E=Number(((N=e.details)==null?void 0:N.toY)??0),O=Number(((m=e.details)==null?void 0:m.scale)||1)||1,M=x/O,C=E/O;return{transform:`translateX(${M}px) translateY(${C}px)`}})():(S[e.property]||S.default)(d);Object.keys(A).forEach(x=>{x==="transform"?u[x]=u[x]?{[x]:`${u[x][x]} ${A[x]}`}:A:u[x]=A})}g.push(a)});const n={...g.reduce((e,a)=>(Object.keys(a).forEach(l=>{l==="transform"||l==="filter"?e[l]=e[l]?`${e[l]} ${a[l]}`:a[l]:e[l]=a[l]}),e),{})};return Object.keys(u).forEach(e=>{const a=u[e];(e==="transform"||e==="filter")&&a[e]?n[e]=n[e]?`${n[e]} ${a[e]}`:String(a[e]):a[e]!==void 0&&(n[e]=a[e])}),n}else return o.map(u=>U(u,s,f,c)).reduce((u,p)=>(Object.keys(p).forEach(n=>{n==="transform"||n==="filter"?u[n]=u[n]?`${u[n]} ${p[n]}`:p[n]:u[n]=p[n]}),u),{})},[t,s,f,c]),T=t=>t?Array.isArray(t)?t:[t]:[],G=(...t)=>{const f=[];return t.forEach(s=>{Array.isArray(s)?f.push(...s):s&&f.push(s)}),f.filter(s=>s!==void 0).reduce((s,c)=>s.find(o=>o.property===c.property)?s.map(o=>o.property===c.property?{...o,from:Math.min(o.from,c.from),to:Math.max(o.to,c.to),durationInFrames:Math.max(o.durationInFrames,c.durationInFrames),delay:Math.min(o.delay||0,c.delay||0),ease:g=>(o.ease(g)+c.ease(g))/2}:o):[...s,c],[])},J=({animationIn:t,animationOut:f,durationInFrames:s,children:c,style:$={},frame:o,isTransition:g=!1,basicCharAnimationsIn:u=[],basicCharAnimationsOut:p=[]})=>{var b;const n=P(T(t),s,o,!1),e=P(T(f),s,o,!0),a=P(T(u),s,o,!0),l=P(T(p),s,o,!0),d=I.useMemo(()=>{const h=Object.keys(n).length>0,v=t==null?void 0:t.reduce((V,F)=>Math.min(V,F.delay||0),1/0),y=o-(v||0);return h&&y<0?{visibility:g?"visible":"hidden"}:n},[n,o,t]),S=I.useMemo(()=>{if(o>s)return{visibility:g?"visible":"hidden"};const h=T(f);if(!h||h.length===0)return{};let v=0;h.forEach(V=>{const F=(V.durationInFrames||0)+(V.delay||0);F>v&&(v=F)});const y=Math.max(0,s-v);return o<y?{}:e},[e,o,f,s,g]),x=(($==null?void 0:$.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),E=x?parseFloat(x[1]):0,O=-E,M=I.useMemo(()=>{const h={...d};return Object.entries(S).forEach(([v,y])=>{v==="transform"?h[v]=`${h[v]||""} ${y||""}`.trim():v in h&&typeof h[v]=="number"&&typeof y=="number"?h[v]=h[v]*y:h[v]=y}),h},[d,S]);if((b=M.transform)!=null&&b.includes("rotate")){const h=M.transform;M.transform=h.replace(/rotate\(([^)]+)deg\)/,(v,y)=>`rotate(${parseFloat(y)-O}deg)`)}const C=I.useMemo(()=>{const h=M.transform||"",{translateX:v,translateY:y,scale:V,rotation:F,rotateX:H,rotateY:r,rotateZ:j}=W(h);return`${v} ${y} ${V} ${F||`rotate(${E}deg)`} ${H} ${r} ${j}`.trim()},[M,E]);let i=n;E>0&&i.transform&&i.transform.includes("translateX")&&(i={...i,transform:i.transform.replace(/translateX\(([^)]+)\)/g,(h,v)=>`translateX(${parseFloat(v)}%)`)});const{top:N,left:m,position:_,transform:B,...L}=$||{};return w.jsx("div",{style:{width:"100%",height:"100%",overflow:M.overflow||a.overflow||l.overflow||"visible",pointerEvents:"none"},children:w.jsx("div",{style:{width:"100%",height:"100%",...L,...M,rotate:`${O}deg`,overflow:"visible",transform:C,pointerEvents:"none",background:Object.keys(M).length===0?"transparent":M.backgroundColor},children:c})})},W=t=>{let f="",s="",c="scale(1)",$="",o="",g="",u="";const p=t.match(/translateX\([^)]+\)/g);p&&(f=p[p.length-1]);const n=t.match(/translateY\([^)]+\)/g);n&&(s=n[n.length-1]);const e=t.match(/scale\([^)]+\)/g);e&&(c=e[e.length-1]);const a=t.match(/rotate\([^)]+\)/g);a&&($=a[a.length-1]);const l=t.match(/rotateX\([^)]+\)/g);l&&(o=l[l.length-1]);const d=t.match(/rotateY\([^)]+\)/g);d&&(g=d[d.length-1]);const S=t.match(/rotateZ\([^)]+\)/g);return S&&(u=S[S.length-1]),{translateX:f,translateY:s,scale:c,rotation:$,rotateX:o,rotateY:g,rotateZ:u}},K=({animationTimed:t,durationInFrames:f,children:s,style:c={},frame:$})=>{var l;const o=P(T(t),f,$,!1,!0),u=((c==null?void 0:c.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),p=u?parseFloat(u[1]):0,n=-p,e=I.useMemo(()=>({...o}),[o]);if((l=e.transform)!=null&&l.includes("rotate")){const d=e.transform;e.transform=d.replace(/rotate\(([^)]+)deg\)/,(S,A)=>`rotate(${parseFloat(A)-n}deg)`)}let a=e;return p>0&&a.transform&&a.transform.includes("translateX")&&(a={...a,transform:a.transform.replace(/translateX\(([^)]+)\)/g,(d,S)=>`translateX(${parseFloat(S)}%)`)}),w.jsx("div",{style:{overflow:e.overflow||"visible",pointerEvents:"none",height:c.height||"100%",width:c.width||"100%",...a},children:w.jsx("div",{style:{overflow:"visible",pointerEvents:"none",height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:s})})},Q=t=>{if(typeof(t==null?void 0:t.ease)=="function")return t.ease;switch(t==null?void 0:t.easing){case"ease-in":case"accelerate":return X.Easing.in(X.Easing.cubic);case"ease-out":case"smooth":case"slowDown":return X.Easing.out(X.Easing.cubic);case"ease-in-out":case"natural":case"swing":return X.Easing.inOut(X.Easing.cubic);case"bounce":return X.Easing.bounce;case"elastic":return X.Easing.elastic(1);case"overshoot":case"impulse":return X.Easing.out(X.Easing.back(1.7));case"none":case"linear":default:return X.Easing.linear}},R=({children:t,currentWidth:f,currentHeight:s,frame:c,item:$,keyframeAnimations:o,durationInFrames:g})=>{var F,H;if(!o||!Array.isArray(o)||o.length===0)return w.jsx(w.Fragment,{children:t});const u=r=>{var j,D;return!!((j=r==null?void 0:r.property)!=null&&j.includes("maskReveal")||(D=r==null?void 0:r.id)!=null&&D.includes("maskReveal"))},p=r=>{var j,D;return!!((r==null?void 0:r.type)==="exit"||(j=r==null?void 0:r.property)!=null&&j.includes("Out")||(D=r==null?void 0:r.id)!=null&&D.includes("Out"))},n=o.find(r=>u(r)&&!p(r)),e=o.find(r=>u(r)&&p(r));if(!n&&!e)return w.jsx(w.Fragment,{children:t});const a=Math.max(1,g||300);let l=null,d=!1,S=30,A=0;if(e){const r=Math.max(1,Number(e.durationInFrames||30)),j=Math.max(0,Number(e.delay||0)),D=Math.max(0,a-r-j);c>=D&&(l=e,d=!0,S=r,A=c-D)}if(!l&&n){l=n,d=!1,S=Math.max(1,Number(n.durationInFrames||30));const r=Math.max(0,Number(n.delay||0));A=c-r}if(!l)return w.jsx(w.Fragment,{children:t});const x=n?Math.max(0,Number(n.delay||0)):0,E=n?Math.max(1,Number(n.durationInFrames||30)):30;if(!d&&n&&c>=x+E)return w.jsx("div",{style:{width:"100%",height:"100%",position:"relative",overflow:"visible"},children:t});if(!d&&n&&c<x)return w.jsx("div",{style:{width:"100%",height:"100%",position:"relative",visibility:"hidden"},children:t});const O=Math.max(0,A),M=Math.min(Math.max(0,O/S),1),C=Q(l),i=Math.max(0,Math.min(1,C(M))),N=String(l.property||l.id||""),m=((F=l.details)==null?void 0:F.direction)||"up",_=N.includes("ShrinkScale"),B=N.includes("CenterScale"),L=N.includes("Slide")||N.includes("slide");let b,h="";if(B){const r=d?50*i:50*(1-i);b=`inset(
2
+ ${r}%
3
+ 0%
4
+ ${r}%
5
+ 0%
6
+ )`}else if(_){const r=d?25*i:25*(1-i);b=`inset(
7
+ ${r}%
8
+ ${r}%
9
+ ${r}%
10
+ ${r}%
11
+ )`}else if(L)b="inset(0% 0% 0% 0%)",d?m==="down"?h=`translateY(${100*i}%)`:m==="left"?h=`translateX(${-100*i}%)`:m==="right"?h=`translateX(${100*i}%)`:h=`translateY(${-100*i}%)`:m==="down"?h=`translateY(${-100*(1-i)}%)`:m==="left"?h=`translateX(${100*(1-i)}%)`:m==="right"?h=`translateX(${-100*(1-i)}%)`:h=`translateY(${100*(1-i)}%)`;else if(N.includes("Center"))b=`circle(${d?150*(1-i):150*i}% at 50% 50%)`;else if(N.includes("Corner")){const r=d?i:1-i;m==="down"?b=`inset(0 ${100*r}% ${100*r}% 0)`:m==="up"?b=`inset(${100*r}% ${100*r}% 0 0)`:m==="left"?b=`inset(0 0 ${100*r}% ${100*r}%)`:m==="right"?b=`inset(${100*r}% 0 0 ${100*r}%)`:b=`inset(0 ${100*r}% ${100*r}% 0)`}else d?m==="down"?b=`inset(${100*i}% 0 0 0)`:m==="left"?b=`inset(0 ${100*i}% 0 0)`:m==="right"?b=`inset(0 0 0 ${100*i}%)`:b=`inset(0 0 ${100*i}% 0)`:m==="down"?b=`inset(0 0 ${100*(1-i)}% 0)`:m==="left"?b=`inset(0 0 0 ${100*(1-i)}%)`:m==="right"?b=`inset(0 ${100*(1-i)}% 0 0)`:b=`inset(${100*(1-i)}% 0 0 0)`;const v=!!((H=l==null?void 0:l.details)!=null&&H.scale||l!=null&&l.scale);let y=1;B||_?y=d?1+.5*i:1.5-.5*i:v&&(y=d?1-.2*i:.8+.2*i);const V=[h,`scale(${y})`].filter(Boolean).join(" ");return console.log("[MaskAnim] Rendering:",{propName:N,frame:c,localFrame:A,animDuration:S,progress:M,easedProgress:i,isOut:d,isShrinkScale:_,isCenterScale:B,isSlide:L,direction:m,clipPath:b,translateTransform:h,isScale:v,scaleValue:y,innerTransform:V}),w.jsx("div",{style:{width:f!==void 0?f:"100%",height:s!==void 0?s:"100%",position:"relative",clipPath:b,WebkitClipPath:b,overflow:"hidden"},children:w.jsx("div",{style:{width:"100%",height:"100%",transform:V,transformOrigin:"center"},children:t})})};Y.BoxAnim=J,Y.ContentAnim=K,Y.MaskAnim=R,Y.combine=G,Y.combineAnimations=T,Y.extractTransformations=W,Y.useAnimation=P,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
package/dist/mask.d.ts CHANGED
@@ -1,6 +1,20 @@
1
- export declare const MaskAnim: ({ children, frame, item, keyframeAnimations }: {
1
+ import { default as React } from 'react';
2
+
3
+ export declare const MaskWrapper: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames }: {
2
4
  children: React.ReactNode;
5
+ currentWidth?: number;
6
+ currentHeight?: number;
3
7
  frame: number;
4
- item: any;
8
+ item?: any;
5
9
  keyframeAnimations: any;
6
- }) => import("react").JSX.Element;
10
+ durationInFrames?: number;
11
+ }) => React.JSX.Element;
12
+ export declare const MaskAnim: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames }: {
13
+ children: React.ReactNode;
14
+ currentWidth?: number;
15
+ currentHeight?: number;
16
+ frame: number;
17
+ item?: any;
18
+ keyframeAnimations: any;
19
+ durationInFrames?: number;
20
+ }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliquify.me/animations",
3
- "version": "9.0.10",
3
+ "version": "9.0.12",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,8 +26,8 @@
26
26
  "typescript": "^5.3.3",
27
27
  "vite": "^5.2.0",
28
28
  "vite-plugin-dts": "^3.9.1",
29
- "@cliquify.me/types": "8.0.9",
30
- "@cliquify.me/typescript-config": "0.0.2"
29
+ "@cliquify.me/typescript-config": "0.0.2",
30
+ "@cliquify.me/types": "8.0.11"
31
31
  },
32
32
  "dependencies": {
33
33
  "remotion": "4.0.506",
@@ -38,7 +38,7 @@
38
38
  "@designcombo/events": "^1.0.2",
39
39
  "react": "^18.2.0 || ^19.0.0",
40
40
  "remotion": "4.0.506",
41
- "@cliquify.me/types": "8.0.9"
41
+ "@cliquify.me/types": "8.0.11"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "vite",