@cliquify.me/animations 9.0.10 → 9.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.
@@ -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 A, Fragment as H } from "react/jsx-runtime";
2
+ import I, { useMemo as W } from "react";
3
+ import { interpolate as P, Easing as X } 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 = [], i = t / 5;
87
+ for (let m = 0; m < 6; m += 1)
88
+ s.push(m * i + f);
89
+ return s;
90
+ }, q = (t, f, s, i = !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 = i ? [
105
+ s - e - n,
106
+ s - e * 0.5 - n
107
+ ] : [
108
+ n + e * 0.5,
109
+ n + e
110
+ ] : f.property === "moveTranslateY" ? l = i ? [
111
+ s - e * 0.5 - n,
112
+ s - n
113
+ ] : [
114
+ n,
115
+ n + e * 0.5
116
+ ] : l = i ? [
117
+ s - e - n,
118
+ s - n
119
+ ] : [
120
+ n,
121
+ n + e
122
+ ], f.property.includes("shake")) {
123
+ const d = i ? 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 P(
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 P(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, i) => {
144
+ var u, p, o, e;
145
+ const { property: m } = t;
146
+ if (m === "move") {
147
+ const n = Number(((u = t.details) == null ? void 0 : u.fromX) ?? t.from ?? 0), l = Number(((p = t.details) == null ? void 0 : p.toX) ?? t.to ?? 0), d = Number(((o = t.details) == null ? void 0 : o.fromY) ?? 0), x = Number(((e = t.details) == null ? void 0 : e.toY) ?? 0), S = t.delay || 0, v = t.durationInFrames || 30, Y = i ? [s - v - S, s - S] : [S, S + v], V = P(f, Y, [n, l], {
148
+ extrapolateLeft: "clamp",
149
+ extrapolateRight: "clamp",
150
+ easing: t.ease
151
+ }), M = P(f, Y, [d, x], {
152
+ extrapolateLeft: "clamp",
153
+ extrapolateRight: "clamp",
154
+ easing: t.ease
155
+ });
156
+ return {
157
+ transform: `translateX(${V}%) translateY(${M}%)`
158
+ };
159
+ }
160
+ const a = q(f, t, s, i), $ = z();
161
+ return ($[m] || $.default)(a);
162
+ }, j = (t, f, s, i = !1, m = !1) => I.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, x = z(), S = e.property === "move" ? (() => {
173
+ var V, M;
174
+ const v = Number(((V = e.details) == null ? void 0 : V.toX) ?? e.to ?? 0), Y = Number(((M = e.details) == null ? void 0 : M.toY) ?? 0);
175
+ return {
176
+ transform: `translateX(${v}%) translateY(${Y}%)`
177
+ };
178
+ })() : (x[e.property] || x.default)(d);
179
+ Object.keys(S).forEach((v) => {
180
+ v === "transform" ? u[v] = u[v] ? {
181
+ [v]: `${u[v][v]} ${S[v]}`
182
+ } : S : u[v] = S;
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, i)).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, i]), F = (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, i) => s.find(
209
+ (a) => a.property === i.property
210
+ ) ? s.map(
211
+ (a) => a.property === i.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, i.from),
214
+ to: Math.max(a.to, i.to),
136
215
  durationInFrames: Math.max(
137
216
  a.durationInFrames,
138
- f.durationInFrames
217
+ i.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, i.delay || 0),
220
+ ease: ($) => (a.ease($) + i.ease($)) / 2
142
221
  // Average the easing functions
143
222
  } : a
144
- ) : [...o, f], []);
145
- }, G = ({
223
+ ) : [...s, i], []);
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: i,
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 g;
236
+ const o = j(
237
+ F(t),
238
+ s,
158
239
  a,
159
240
  !1
160
- ), c = V(
161
- Y(l),
162
- o,
241
+ ), e = j(
242
+ F(f),
243
+ s,
244
+ a,
245
+ !0
246
+ ), n = j(
247
+ F(u),
248
+ s,
163
249
  a,
164
250
  !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),
251
+ ), l = j(
252
+ F(p),
253
+ s,
254
+ a,
255
+ !0
256
+ ), d = I.useMemo(() => {
257
+ const h = Object.keys(o).length > 0, b = t == null ? void 0 : t.reduce(
258
+ (N, O) => Math.min(N, O.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
+ ), y = a - (b || 0);
261
+ return h && y < 0 ? { visibility: $ ? "visible" : "hidden" } : o;
262
+ }, [o, a, t]), x = I.useMemo(() => {
263
+ if (a > s)
264
+ return { visibility: $ ? "visible" : "hidden" };
265
+ const h = F(f);
266
+ if (!h || h.length === 0) return {};
267
+ let b = 0;
268
+ h.forEach((N) => {
269
+ const O = (N.durationInFrames || 0) + (N.delay || 0);
270
+ O > b && (b = O);
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 y = Math.max(0, s - b);
273
+ return a < y ? {} : e;
274
+ }, [e, a, f, s, $]), v = ((m == null ? void 0 : m.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), Y = v ? parseFloat(v[1]) : 0, V = -Y, M = I.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(x).forEach(([b, y]) => {
280
+ b === "transform" ? h[b] = `${h[b] || ""} ${y || ""}`.trim() : b in h && typeof h[b] == "number" && typeof y == "number" ? h[b] = h[b] * y : h[b] = y;
281
+ }), h;
282
+ }, [d, x]);
283
+ if ((g = M.transform) != null && g.includes("rotate")) {
284
+ const h = M.transform;
285
+ M.transform = h.replace(
195
286
  /rotate\(([^)]+)deg\)/,
196
- (g, b) => `rotate(${parseFloat(b) - v}deg)`
287
+ (b, y) => `rotate(${parseFloat(y) - 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 B = W(() => {
291
+ const h = M.transform || "", {
292
+ translateX: b,
293
+ translateY: y,
294
+ scale: N,
295
+ rotation: O,
296
+ rotateX: L,
297
+ rotateY: r,
298
+ rotateZ: R
299
+ } = G(h);
300
+ return `${b} ${y} ${N} ${O || `rotate(${Y}deg)`} ${L} ${r} ${R}`.trim();
301
+ }, [M, Y]);
302
+ let c = o;
303
+ Y > 0 && c.transform && c.transform.includes("translateX") && (c = {
304
+ ...c,
305
+ transform: c.transform.replace(
215
306
  /translateX\(([^)]+)\)/g,
216
- (m, g) => `translateX(${parseFloat(g)}%)`
307
+ (h, b) => `translateX(${parseFloat(b)}%)`
217
308
  )
218
309
  });
219
310
  const {
220
311
  top: E,
221
- left: F,
222
- position: P,
223
- transform: z,
224
- ...H
225
- } = r || {};
226
- return /* @__PURE__ */ y(
312
+ left: w,
313
+ position: C,
314
+ transform: T,
315
+ ..._
316
+ } = m || {};
317
+ return /* @__PURE__ */ A(
227
318
  "div",
228
319
  {
229
320
  style: {
230
321
  width: "100%",
231
322
  height: "100%",
232
- overflow: p.overflow || "visible",
323
+ overflow: M.overflow || n.overflow || l.overflow || "visible",
233
324
  pointerEvents: "none"
234
325
  },
235
- children: /* @__PURE__ */ y(
326
+ children: /* @__PURE__ */ A(
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
+ ..._,
333
+ ...M,
334
+ rotate: `${V}deg`,
244
335
  overflow: "visible",
245
- transform: $,
336
+ transform: B,
246
337
  pointerEvents: "none",
247
- background: Object.keys(p).length === 0 ? "transparent" : p.backgroundColor
338
+ background: Object.keys(M).length === 0 ? "transparent" : M.backgroundColor
248
339
  },
249
- children: f
340
+ children: i
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 = "", i = "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 && (i = 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 x = t.match(/rotateZ\([^)]+\)/g);
360
+ return x && (u = x[x.length - 1]), { translateX: f, translateY: s, scale: i, 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: i = {},
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 = j(
370
+ F(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 = ((i == null ? void 0 : i.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), p = u ? parseFloat(u[1]) : 0, o = -p, e = I.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
+ (x, S) => `rotate(${parseFloat(S) - 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, x) => `translateX(${parseFloat(x)}%)`
300
391
  )
301
- }), /* @__PURE__ */ y(
392
+ }), /* @__PURE__ */ A(
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: i.height || "100%",
399
+ width: i.width || "100%",
400
+ ...n
310
401
  },
311
- children: /* @__PURE__ */ y(
402
+ children: /* @__PURE__ */ A(
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,229 @@ 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 X.in(X.cubic);
334
426
  case "ease-out":
335
- return w.out(w.cubic);
427
+ case "smooth":
428
+ case "slowDown":
429
+ return X.out(X.cubic);
336
430
  case "ease-in-out":
337
- return w.inOut(w.cubic);
431
+ case "natural":
432
+ case "swing":
433
+ return X.inOut(X.cubic);
434
+ case "bounce":
435
+ return X.bounce;
436
+ case "elastic":
437
+ return X.elastic(1);
438
+ case "overshoot":
439
+ case "impulse":
440
+ return X.out(X.back(1.7));
441
+ case "none":
338
442
  case "linear":
339
443
  default:
340
- return w.linear;
444
+ return X.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: i,
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 O, L;
456
+ if (!a || !Array.isArray(a) || a.length === 0)
457
+ return /* @__PURE__ */ A(H, { children: t });
458
+ const u = (r) => {
459
+ var R, D;
460
+ return !!((R = r == null ? void 0 : r.property) != null && R.includes("maskReveal") || (D = r == null ? void 0 : r.id) != null && D.includes("maskReveal"));
461
+ }, p = (r) => {
462
+ var R, D;
463
+ return !!((r == null ? void 0 : r.type) === "exit" || (R = r == null ? void 0 : r.property) != null && R.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__ */ A(H, { children: t });
471
+ const n = Math.max(
472
+ 1,
473
+ $ || 300
474
+ );
475
+ let l = null, d = !1, x = 30, S = 0;
476
+ if (e) {
477
+ const r = Math.max(
478
+ 1,
479
+ Number(e.durationInFrames || 30)
480
+ ), R = Math.max(
481
+ 0,
482
+ Number(e.delay || 0)
483
+ ), D = Math.max(
484
+ 0,
485
+ n - r - R
486
+ );
487
+ i >= D && (l = e, d = !0, x = r, S = i - D);
488
+ }
489
+ if (!l && o) {
490
+ l = o, d = !1, x = Math.max(
491
+ 1,
492
+ Number(o.durationInFrames || 30)
493
+ );
494
+ const r = Math.max(
495
+ 0,
496
+ Number(o.delay || 0)
497
+ );
498
+ S = i - r;
499
+ }
500
+ if (!l)
501
+ return /* @__PURE__ */ A(H, { children: t });
502
+ const v = o ? Math.max(
503
+ 0,
504
+ Number(o.delay || 0)
505
+ ) : 0, Y = o ? Math.max(
506
+ 1,
507
+ Number(
508
+ o.durationInFrames || 30
509
+ )
510
+ ) : 30;
511
+ if (!d && o && i >= v + Y)
512
+ return /* @__PURE__ */ A(
513
+ "div",
514
+ {
515
+ style: {
516
+ width: "100%",
517
+ height: "100%",
518
+ position: "relative",
519
+ overflow: "visible"
520
+ },
521
+ children: t
522
+ }
523
+ );
524
+ if (!d && o && i < v)
525
+ return /* @__PURE__ */ A(
526
+ "div",
527
+ {
528
+ style: {
529
+ width: "100%",
530
+ height: "100%",
531
+ position: "relative",
532
+ visibility: "hidden"
533
+ },
534
+ children: t
535
+ }
536
+ );
537
+ const V = Math.max(
538
+ 0,
539
+ S
540
+ ), M = Math.min(
541
+ Math.max(
542
+ 0,
543
+ V / x
544
+ ),
545
+ 1
546
+ ), B = J(l), c = Math.max(
547
+ 0,
548
+ Math.min(
549
+ 1,
550
+ B(M)
551
+ )
552
+ ), E = String(
553
+ l.property || l.id || ""
554
+ ), w = ((O = l.details) == null ? void 0 : O.direction) || "up", C = E.includes("ShrinkScale"), T = E.includes("CenterScale"), _ = E.includes("Slide") || E.includes("slide");
555
+ let g, h = "";
556
+ if (T) {
557
+ const r = d ? 50 * c : 50 * (1 - c);
558
+ g = `inset(
559
+ ${r}%
560
+ 0%
561
+ ${r}%
562
+ 0%
563
+ )`;
564
+ } else if (C) {
565
+ const r = d ? 25 * c : 25 * (1 - c);
566
+ g = `inset(
567
+ ${r}%
568
+ ${r}%
569
+ ${r}%
570
+ ${r}%
571
+ )`;
572
+ } else if (_)
573
+ g = "inset(0% 0% 0% 0%)", d ? w === "down" ? h = `translateY(${100 * c}%)` : w === "left" ? h = `translateX(${-100 * c}%)` : w === "right" ? h = `translateX(${100 * c}%)` : h = `translateY(${-100 * c}%)` : w === "down" ? h = `translateY(${-100 * (1 - c)}%)` : w === "left" ? h = `translateX(${100 * (1 - c)}%)` : w === "right" ? h = `translateX(${-100 * (1 - c)}%)` : h = `translateY(${100 * (1 - c)}%)`;
574
+ else if (E.includes("Center"))
575
+ g = `circle(${d ? 150 * (1 - c) : 150 * c}% at 50% 50%)`;
576
+ else if (E.includes("Corner")) {
577
+ const r = d ? c : 1 - c;
578
+ w === "down" ? g = `inset(0 ${100 * r}% ${100 * r}% 0)` : w === "up" ? g = `inset(${100 * r}% ${100 * r}% 0 0)` : w === "left" ? g = `inset(0 0 ${100 * r}% ${100 * r}%)` : w === "right" ? g = `inset(${100 * r}% 0 0 ${100 * r}%)` : g = `inset(0 ${100 * r}% ${100 * r}% 0)`;
579
+ } else
580
+ d ? w === "down" ? g = `inset(${100 * c}% 0 0 0)` : w === "left" ? g = `inset(0 ${100 * c}% 0 0)` : w === "right" ? g = `inset(0 0 0 ${100 * c}%)` : g = `inset(0 0 ${100 * c}% 0)` : w === "down" ? g = `inset(0 0 ${100 * (1 - c)}% 0)` : w === "left" ? g = `inset(0 0 0 ${100 * (1 - c)}%)` : w === "right" ? g = `inset(0 ${100 * (1 - c)}% 0 0)` : g = `inset(${100 * (1 - c)}% 0 0 0)`;
581
+ const b = !!((L = l == null ? void 0 : l.details) != null && L.scale || l != null && l.scale);
582
+ let y = 1;
583
+ T || C ? y = d ? 1 + 0.5 * c : 1.5 - 0.5 * c : b && (y = d ? 1 - 0.2 * c : 0.8 + 0.2 * c);
584
+ const N = [
585
+ h,
586
+ `scale(${y})`
587
+ ].filter(Boolean).join(" ");
588
+ return console.log("[MaskAnim] Rendering:", {
589
+ propName: E,
590
+ frame: i,
591
+ localFrame: S,
592
+ animDuration: x,
593
+ progress: M,
594
+ easedProgress: c,
595
+ isOut: d,
596
+ isShrinkScale: C,
597
+ isCenterScale: T,
598
+ isSlide: _,
599
+ direction: w,
600
+ clipPath: g,
601
+ translateTransform: h,
602
+ isScale: b,
603
+ scaleValue: y,
604
+ innerTransform: N
605
+ }), /* @__PURE__ */ A(
354
606
  "div",
355
607
  {
356
608
  style: {
357
- width: a,
358
- height: h,
609
+ width: f !== void 0 ? f : "100%",
610
+ height: s !== void 0 ? s : "100%",
359
611
  position: "relative",
360
- overflow: c < 1 ? "hidden" : "visible"
612
+ clipPath: g,
613
+ WebkitClipPath: g,
614
+ overflow: "hidden"
361
615
  },
362
- children: /* @__PURE__ */ y(
616
+ children: /* @__PURE__ */ A(
363
617
  "div",
364
618
  {
365
619
  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
620
+ width: "100%",
621
+ height: "100%",
622
+ transform: N,
623
+ transformOrigin: "center"
373
624
  },
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
- )
625
+ children: t
388
626
  }
389
627
  )
390
628
  }
391
629
  );
392
- };
630
+ }, ot = K;
393
631
  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
632
+ rt as BoxAnim,
633
+ st as ContentAnim,
634
+ ot as MaskAnim,
635
+ et as combine,
636
+ F as combineAnimations,
637
+ G as extractTransformations,
638
+ j as useAnimation
401
639
  };
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(X,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):(X=typeof globalThis<"u"?globalThis:X||self,S(X.animations={},X.jsxRuntime,X.React,X.remotion))})(this,function(X,S,C,A){"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=[],i=t/5;for(let $=0;$<6;$+=1)s.push($*i+f);return s},z=(t,f,s,i=!1)=>{const{from:$,to:a,ease:g}=f,u=f.durationInFrames||30,p=Number($),n=Number(a),e=Math.max(1,Number(u));if(isNaN(p)||isNaN(n))return console.error("Invalid animation values:",{from:$,to:a,animationDurationInFrames:u,property:f.property}),p;u===void 0&&console.warn(`durationInFrames is undefined for animation: ${f.property}. Using 1 frame as default.`);const o=f.delay||0;let l;if(f.property==="moveScaleIn"?l=i?[s-e-o,s-e*.5-o]:[o+e*.5,o+e]:f.property==="moveTranslateY"?l=i?[s-e*.5-o,s-o]:[o,o+e*.5]:l=i?[s-e-o,s-o]:[o,o+e],f.property.includes("shake")){const d=i?q(e,s-e-o):q(e,o);return A.interpolate(t,d,[0,p,n,p,n,0],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:g})}return A.interpolate(t,l,[p,n],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:g})},U=(t,f,s,i)=>{var u,p,n,e;const{property:$}=t;if($==="move"){const o=Number(((u=t.details)==null?void 0:u.fromX)??t.from??0),l=Number(((p=t.details)==null?void 0:p.toX)??t.to??0),d=Number(((n=t.details)==null?void 0:n.fromY)??0),x=Number(((e=t.details)==null?void 0:e.toY)??0),w=t.delay||0,v=t.durationInFrames||30,E=i?[s-v-w,s-w]:[w,w+v],O=A.interpolate(f,E,[o,l],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:t.ease}),Y=A.interpolate(f,E,[d,x],{extrapolateLeft:"clamp",extrapolateRight:"clamp",easing:t.ease});return{transform:`translateX(${O}%) translateY(${Y}%)`}}const a=z(f,t,s,i),g=Z();return(g[$]||g.default)(a)},I=(t,f,s,i=!1,$=!1)=>C.useMemo(()=>{if(t.length===0)return{};const a=t.filter(g=>g.from!==void 0&&g.to!==void 0);if(a.length!==t.length&&console.error("Some animations are invalid and will be ignored"),$){const g=[],u={};a.reverse().forEach(e=>{const o=U(e,s,f,!1);if(e.persist===!0&&s-(e.delay||0)>=e.durationInFrames){const d=e.to,x=Z(),w=e.property==="move"?(()=>{var O,Y;const v=Number(((O=e.details)==null?void 0:O.toX)??e.to??0),E=Number(((Y=e.details)==null?void 0:Y.toY)??0);return{transform:`translateX(${v}%) translateY(${E}%)`}})():(x[e.property]||x.default)(d);Object.keys(w).forEach(v=>{v==="transform"?u[v]=u[v]?{[v]:`${u[v][v]} ${w[v]}`}:w:u[v]=w})}g.push(o)});const n={...g.reduce((e,o)=>(Object.keys(o).forEach(l=>{l==="transform"||l==="filter"?e[l]=e[l]?`${e[l]} ${o[l]}`:o[l]:e[l]=o[l]}),e),{})};return Object.keys(u).forEach(e=>{const o=u[e];(e==="transform"||e==="filter")&&o[e]?n[e]=n[e]?`${n[e]} ${o[e]}`:String(o[e]):o[e]!==void 0&&(n[e]=o[e])}),n}else return a.map(u=>U(u,s,f,i)).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,i]),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,i)=>s.find(a=>a.property===i.property)?s.map(a=>a.property===i.property?{...a,from:Math.min(a.from,i.from),to:Math.max(a.to,i.to),durationInFrames:Math.max(a.durationInFrames,i.durationInFrames),delay:Math.min(a.delay||0,i.delay||0),ease:g=>(a.ease(g)+i.ease(g))/2}:a):[...s,i],[])},J=({animationIn:t,animationOut:f,durationInFrames:s,children:i,style:$={},frame:a,isTransition:g=!1,basicCharAnimationsIn:u=[],basicCharAnimationsOut:p=[]})=>{var m;const n=I(T(t),s,a,!1),e=I(T(f),s,a,!0),o=I(T(u),s,a,!0),l=I(T(p),s,a,!0),d=C.useMemo(()=>{const h=Object.keys(n).length>0,b=t==null?void 0:t.reduce((N,V)=>Math.min(N,V.delay||0),1/0),M=a-(b||0);return h&&M<0?{visibility:g?"visible":"hidden"}:n},[n,a,t]),x=C.useMemo(()=>{if(a>s)return{visibility:g?"visible":"hidden"};const h=T(f);if(!h||h.length===0)return{};let b=0;h.forEach(N=>{const V=(N.durationInFrames||0)+(N.delay||0);V>b&&(b=V)});const M=Math.max(0,s-b);return a<M?{}:e},[e,a,f,s,g]),v=(($==null?void 0:$.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),E=v?parseFloat(v[1]):0,O=-E,Y=C.useMemo(()=>{const h={...d};return Object.entries(x).forEach(([b,M])=>{b==="transform"?h[b]=`${h[b]||""} ${M||""}`.trim():b in h&&typeof h[b]=="number"&&typeof M=="number"?h[b]=h[b]*M:h[b]=M}),h},[d,x]);if((m=Y.transform)!=null&&m.includes("rotate")){const h=Y.transform;Y.transform=h.replace(/rotate\(([^)]+)deg\)/,(b,M)=>`rotate(${parseFloat(M)-O}deg)`)}const H=C.useMemo(()=>{const h=Y.transform||"",{translateX:b,translateY:M,scale:N,rotation:V,rotateX:L,rotateY:r,rotateZ:F}=W(h);return`${b} ${M} ${N} ${V||`rotate(${E}deg)`} ${L} ${r} ${F}`.trim()},[Y,E]);let c=n;E>0&&c.transform&&c.transform.includes("translateX")&&(c={...c,transform:c.transform.replace(/translateX\(([^)]+)\)/g,(h,b)=>`translateX(${parseFloat(b)}%)`)});const{top:j,left:y,position:P,transform:_,...B}=$||{};return S.jsx("div",{style:{width:"100%",height:"100%",overflow:Y.overflow||o.overflow||l.overflow||"visible",pointerEvents:"none"},children:S.jsx("div",{style:{width:"100%",height:"100%",...B,...Y,rotate:`${O}deg`,overflow:"visible",transform:H,pointerEvents:"none",background:Object.keys(Y).length===0?"transparent":Y.backgroundColor},children:i})})},W=t=>{let f="",s="",i="scale(1)",$="",a="",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&&(i=e[e.length-1]);const o=t.match(/rotate\([^)]+\)/g);o&&($=o[o.length-1]);const l=t.match(/rotateX\([^)]+\)/g);l&&(a=l[l.length-1]);const d=t.match(/rotateY\([^)]+\)/g);d&&(g=d[d.length-1]);const x=t.match(/rotateZ\([^)]+\)/g);return x&&(u=x[x.length-1]),{translateX:f,translateY:s,scale:i,rotation:$,rotateX:a,rotateY:g,rotateZ:u}},K=({animationTimed:t,durationInFrames:f,children:s,style:i={},frame:$})=>{var l;const a=I(T(t),f,$,!1,!0),u=((i==null?void 0:i.transform)||"").match(/rotate\((-?[\d.]+)deg\)/),p=u?parseFloat(u[1]):0,n=-p,e=C.useMemo(()=>({...a}),[a]);if((l=e.transform)!=null&&l.includes("rotate")){const d=e.transform;e.transform=d.replace(/rotate\(([^)]+)deg\)/,(x,w)=>`rotate(${parseFloat(w)-n}deg)`)}let o=e;return p>0&&o.transform&&o.transform.includes("translateX")&&(o={...o,transform:o.transform.replace(/translateX\(([^)]+)\)/g,(d,x)=>`translateX(${parseFloat(x)}%)`)}),S.jsx("div",{style:{overflow:e.overflow||"visible",pointerEvents:"none",height:i.height||"100%",width:i.width||"100%",...o},children:S.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 A.Easing.in(A.Easing.cubic);case"ease-out":case"smooth":case"slowDown":return A.Easing.out(A.Easing.cubic);case"ease-in-out":case"natural":case"swing":return A.Easing.inOut(A.Easing.cubic);case"bounce":return A.Easing.bounce;case"elastic":return A.Easing.elastic(1);case"overshoot":case"impulse":return A.Easing.out(A.Easing.back(1.7));case"none":case"linear":default:return A.Easing.linear}},R=({children:t,currentWidth:f,currentHeight:s,frame:i,item:$,keyframeAnimations:a,durationInFrames:g})=>{var V,L;if(!a||!Array.isArray(a)||a.length===0)return S.jsx(S.Fragment,{children:t});const u=r=>{var F,D;return!!((F=r==null?void 0:r.property)!=null&&F.includes("maskReveal")||(D=r==null?void 0:r.id)!=null&&D.includes("maskReveal"))},p=r=>{var F,D;return!!((r==null?void 0:r.type)==="exit"||(F=r==null?void 0:r.property)!=null&&F.includes("Out")||(D=r==null?void 0:r.id)!=null&&D.includes("Out"))},n=a.find(r=>u(r)&&!p(r)),e=a.find(r=>u(r)&&p(r));if(!n&&!e)return S.jsx(S.Fragment,{children:t});const o=Math.max(1,g||300);let l=null,d=!1,x=30,w=0;if(e){const r=Math.max(1,Number(e.durationInFrames||30)),F=Math.max(0,Number(e.delay||0)),D=Math.max(0,o-r-F);i>=D&&(l=e,d=!0,x=r,w=i-D)}if(!l&&n){l=n,d=!1,x=Math.max(1,Number(n.durationInFrames||30));const r=Math.max(0,Number(n.delay||0));w=i-r}if(!l)return S.jsx(S.Fragment,{children:t});const v=n?Math.max(0,Number(n.delay||0)):0,E=n?Math.max(1,Number(n.durationInFrames||30)):30;if(!d&&n&&i>=v+E)return S.jsx("div",{style:{width:"100%",height:"100%",position:"relative",overflow:"visible"},children:t});if(!d&&n&&i<v)return S.jsx("div",{style:{width:"100%",height:"100%",position:"relative",visibility:"hidden"},children:t});const O=Math.max(0,w),Y=Math.min(Math.max(0,O/x),1),H=Q(l),c=Math.max(0,Math.min(1,H(Y))),j=String(l.property||l.id||""),y=((V=l.details)==null?void 0:V.direction)||"up",P=j.includes("ShrinkScale"),_=j.includes("CenterScale"),B=j.includes("Slide")||j.includes("slide");let m,h="";if(_){const r=d?50*c:50*(1-c);m=`inset(
2
+ ${r}%
3
+ 0%
4
+ ${r}%
5
+ 0%
6
+ )`}else if(P){const r=d?25*c:25*(1-c);m=`inset(
7
+ ${r}%
8
+ ${r}%
9
+ ${r}%
10
+ ${r}%
11
+ )`}else if(B)m="inset(0% 0% 0% 0%)",d?y==="down"?h=`translateY(${100*c}%)`:y==="left"?h=`translateX(${-100*c}%)`:y==="right"?h=`translateX(${100*c}%)`:h=`translateY(${-100*c}%)`:y==="down"?h=`translateY(${-100*(1-c)}%)`:y==="left"?h=`translateX(${100*(1-c)}%)`:y==="right"?h=`translateX(${-100*(1-c)}%)`:h=`translateY(${100*(1-c)}%)`;else if(j.includes("Center"))m=`circle(${d?150*(1-c):150*c}% at 50% 50%)`;else if(j.includes("Corner")){const r=d?c:1-c;y==="down"?m=`inset(0 ${100*r}% ${100*r}% 0)`:y==="up"?m=`inset(${100*r}% ${100*r}% 0 0)`:y==="left"?m=`inset(0 0 ${100*r}% ${100*r}%)`:y==="right"?m=`inset(${100*r}% 0 0 ${100*r}%)`:m=`inset(0 ${100*r}% ${100*r}% 0)`}else d?y==="down"?m=`inset(${100*c}% 0 0 0)`:y==="left"?m=`inset(0 ${100*c}% 0 0)`:y==="right"?m=`inset(0 0 0 ${100*c}%)`:m=`inset(0 0 ${100*c}% 0)`:y==="down"?m=`inset(0 0 ${100*(1-c)}% 0)`:y==="left"?m=`inset(0 0 0 ${100*(1-c)}%)`:y==="right"?m=`inset(0 ${100*(1-c)}% 0 0)`:m=`inset(${100*(1-c)}% 0 0 0)`;const b=!!((L=l==null?void 0:l.details)!=null&&L.scale||l!=null&&l.scale);let M=1;_||P?M=d?1+.5*c:1.5-.5*c:b&&(M=d?1-.2*c:.8+.2*c);const N=[h,`scale(${M})`].filter(Boolean).join(" ");return console.log("[MaskAnim] Rendering:",{propName:j,frame:i,localFrame:w,animDuration:x,progress:Y,easedProgress:c,isOut:d,isShrinkScale:P,isCenterScale:_,isSlide:B,direction:y,clipPath:m,translateTransform:h,isScale:b,scaleValue:M,innerTransform:N}),S.jsx("div",{style:{width:f!==void 0?f:"100%",height:s!==void 0?s:"100%",position:"relative",clipPath:m,WebkitClipPath:m,overflow:"hidden"},children:S.jsx("div",{style:{width:"100%",height:"100%",transform:N,transformOrigin:"center"},children:t})})};X.BoxAnim=J,X.ContentAnim=K,X.MaskAnim=R,X.combine=G,X.combineAnimations=T,X.extractTransformations=W,X.useAnimation=I,Object.defineProperty(X,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.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": "8.0.9",
29
+ "@cliquify.me/types": "8.0.10",
30
30
  "@cliquify.me/typescript-config": "0.0.2"
31
31
  },
32
32
  "dependencies": {
@@ -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.10"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "vite",