@cliquify.me/animations 9.0.11 → 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.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
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";
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
4
  const z = () => ({
5
5
  scale: (t) => ({ transform: `scale(${t})` }),
6
6
  growIn: (t) => ({ transform: `scale(${t})` }),
@@ -83,11 +83,11 @@ const z = () => ({
83
83
  }),
84
84
  moveTranslateY: (t) => ({ transform: `translateY(${t}%)` })
85
85
  }), Z = (t, f = 0) => {
86
- const s = [], i = t / 5;
86
+ const s = [], c = t / 5;
87
87
  for (let m = 0; m < 6; m += 1)
88
- s.push(m * i + f);
88
+ s.push(m * c + f);
89
89
  return s;
90
- }, q = (t, f, s, i = !1) => {
90
+ }, q = (t, f, s, c = !1) => {
91
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
92
  if (isNaN(p) || isNaN(o))
93
93
  return console.error("Invalid animation values:", {
@@ -101,30 +101,30 @@ const z = () => ({
101
101
  );
102
102
  const n = f.delay || 0;
103
103
  let l;
104
- if (f.property === "moveScaleIn" ? l = i ? [
104
+ if (f.property === "moveScaleIn" ? l = c ? [
105
105
  s - e - n,
106
106
  s - e * 0.5 - n
107
107
  ] : [
108
108
  n + e * 0.5,
109
109
  n + e
110
- ] : f.property === "moveTranslateY" ? l = i ? [
110
+ ] : f.property === "moveTranslateY" ? l = c ? [
111
111
  s - e * 0.5 - n,
112
112
  s - n
113
113
  ] : [
114
114
  n,
115
115
  n + e * 0.5
116
- ] : l = i ? [
116
+ ] : l = c ? [
117
117
  s - e - n,
118
118
  s - n
119
119
  ] : [
120
120
  n,
121
121
  n + e
122
122
  ], f.property.includes("shake")) {
123
- const d = i ? Z(
123
+ const d = c ? Z(
124
124
  e,
125
125
  s - e - n
126
126
  ) : Z(e, n);
127
- return P(
127
+ return B(
128
128
  t,
129
129
  d,
130
130
  [0, p, o, p, o, 0],
@@ -135,31 +135,31 @@ const z = () => ({
135
135
  }
136
136
  );
137
137
  }
138
- return P(t, l, [p, o], {
138
+ return B(t, l, [p, o], {
139
139
  extrapolateLeft: "clamp",
140
140
  extrapolateRight: "clamp",
141
141
  easing: $
142
142
  });
143
- }, U = (t, f, s, i) => {
144
- var u, p, o, e;
143
+ }, U = (t, f, s, c) => {
144
+ var u, p, o, e, n;
145
145
  const { property: m } = t;
146
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], {
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
148
  extrapolateLeft: "clamp",
149
149
  extrapolateRight: "clamp",
150
150
  easing: t.ease
151
- }), M = P(f, Y, [d, x], {
151
+ }), i = B(f, y, [S, M], {
152
152
  extrapolateLeft: "clamp",
153
153
  extrapolateRight: "clamp",
154
154
  easing: t.ease
155
- });
155
+ }), X = F / x, g = i / x;
156
156
  return {
157
- transform: `translateX(${V}%) translateY(${M}%)`
157
+ transform: `translateX(${X}px) translateY(${g}px)`
158
158
  };
159
159
  }
160
- const a = q(f, t, s, i), $ = z();
160
+ const a = q(f, t, s, c), $ = z();
161
161
  return ($[m] || $.default)(a);
162
- }, j = (t, f, s, i = !1, m = !1) => I.useMemo(() => {
162
+ }, I = (t, f, s, c = !1, m = !1) => C.useMemo(() => {
163
163
  if (t.length === 0) return {};
164
164
  const a = t.filter(
165
165
  ($) => $.from !== void 0 && $.to !== void 0
@@ -169,17 +169,17 @@ const z = () => ({
169
169
  a.reverse().forEach((e) => {
170
170
  const n = U(e, s, f, !1);
171
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);
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
175
  return {
176
- transform: `translateX(${v}%) translateY(${Y}%)`
176
+ transform: `translateX(${y}px) translateY(${F}px)`
177
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;
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;
183
183
  });
184
184
  }
185
185
  $.push(n);
@@ -195,191 +195,191 @@ const z = () => ({
195
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
196
  }), o;
197
197
  } else
198
- return a.map((u) => U(u, s, f, i)).reduce(
198
+ return a.map((u) => U(u, s, f, c)).reduce(
199
199
  (u, p) => (Object.keys(p).forEach((o) => {
200
200
  o === "transform" || o === "filter" ? u[o] = u[o] ? `${u[o]} ${p[o]}` : p[o] : u[o] = p[o];
201
201
  }), u),
202
202
  {}
203
203
  );
204
- }, [t, s, f, i]), F = (t) => t ? Array.isArray(t) ? t : [t] : [], et = (...t) => {
204
+ }, [t, s, f, c]), j = (t) => t ? Array.isArray(t) ? t : [t] : [], et = (...t) => {
205
205
  const f = [];
206
206
  return t.forEach((s) => {
207
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
208
+ }), f.filter((s) => s !== void 0).reduce((s, c) => s.find(
209
+ (a) => a.property === c.property
210
210
  ) ? s.map(
211
- (a) => a.property === i.property ? {
211
+ (a) => a.property === c.property ? {
212
212
  ...a,
213
- from: Math.min(a.from, i.from),
214
- to: Math.max(a.to, i.to),
213
+ from: Math.min(a.from, c.from),
214
+ to: Math.max(a.to, c.to),
215
215
  durationInFrames: Math.max(
216
216
  a.durationInFrames,
217
- i.durationInFrames
217
+ c.durationInFrames
218
218
  ),
219
- delay: Math.min(a.delay || 0, i.delay || 0),
220
- ease: ($) => (a.ease($) + i.ease($)) / 2
219
+ delay: Math.min(a.delay || 0, c.delay || 0),
220
+ ease: ($) => (a.ease($) + c.ease($)) / 2
221
221
  // Average the easing functions
222
222
  } : a
223
- ) : [...s, i], []);
223
+ ) : [...s, c], []);
224
224
  }, rt = ({
225
225
  animationIn: t,
226
226
  animationOut: f,
227
227
  durationInFrames: s,
228
- children: i,
228
+ children: c,
229
229
  style: m = {},
230
230
  frame: a,
231
231
  isTransition: $ = !1,
232
232
  basicCharAnimationsIn: u = [],
233
233
  basicCharAnimationsOut: p = []
234
234
  }) => {
235
- var g;
236
- const o = j(
237
- F(t),
235
+ var b;
236
+ const o = I(
237
+ j(t),
238
238
  s,
239
239
  a,
240
240
  !1
241
- ), e = j(
242
- F(f),
241
+ ), e = I(
242
+ j(f),
243
243
  s,
244
244
  a,
245
245
  !0
246
- ), n = j(
247
- F(u),
246
+ ), n = I(
247
+ j(u),
248
248
  s,
249
249
  a,
250
250
  !0
251
- ), l = j(
252
- F(p),
251
+ ), l = I(
252
+ j(p),
253
253
  s,
254
254
  a,
255
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),
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),
259
259
  1 / 0
260
- ), y = a - (b || 0);
261
- return h && y < 0 ? { visibility: $ ? "visible" : "hidden" } : o;
262
- }, [o, a, t]), x = I.useMemo(() => {
260
+ ), w = a - (v || 0);
261
+ return h && w < 0 ? { visibility: $ ? "visible" : "hidden" } : o;
262
+ }, [o, a, t]), S = C.useMemo(() => {
263
263
  if (a > s)
264
264
  return { visibility: $ ? "visible" : "hidden" };
265
- const h = F(f);
265
+ const h = j(f);
266
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);
267
+ let v = 0;
268
+ h.forEach((O) => {
269
+ const R = (O.durationInFrames || 0) + (O.delay || 0);
270
+ R > v && (v = R);
271
271
  });
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(() => {
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
275
  const h = {
276
276
  ...d
277
277
  // , ...timedStyle
278
278
  };
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;
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
281
  }), h;
282
- }, [d, x]);
283
- if ((g = M.transform) != null && g.includes("rotate")) {
284
- const h = M.transform;
285
- M.transform = h.replace(
282
+ }, [d, S]);
283
+ if ((b = y.transform) != null && b.includes("rotate")) {
284
+ const h = y.transform;
285
+ y.transform = h.replace(
286
286
  /rotate\(([^)]+)deg\)/,
287
- (b, y) => `rotate(${parseFloat(y) - V}deg)`
287
+ (v, w) => `rotate(${parseFloat(w) - V}deg)`
288
288
  );
289
289
  }
290
- const B = W(() => {
291
- const h = M.transform || "", {
292
- translateX: b,
293
- translateY: y,
294
- scale: N,
295
- rotation: O,
296
- rotateX: L,
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
297
  rotateY: r,
298
- rotateZ: R
298
+ rotateZ: E
299
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(
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(
306
306
  /translateX\(([^)]+)\)/g,
307
- (h, b) => `translateX(${parseFloat(b)}%)`
307
+ (h, v) => `translateX(${parseFloat(v)}%)`
308
308
  )
309
309
  });
310
310
  const {
311
- top: E,
312
- left: w,
313
- position: C,
314
- transform: T,
315
- ..._
311
+ top: X,
312
+ left: g,
313
+ position: T,
314
+ transform: _,
315
+ ...L
316
316
  } = m || {};
317
- return /* @__PURE__ */ A(
317
+ return /* @__PURE__ */ N(
318
318
  "div",
319
319
  {
320
320
  style: {
321
321
  width: "100%",
322
322
  height: "100%",
323
- overflow: M.overflow || n.overflow || l.overflow || "visible",
323
+ overflow: y.overflow || n.overflow || l.overflow || "visible",
324
324
  pointerEvents: "none"
325
325
  },
326
- children: /* @__PURE__ */ A(
326
+ children: /* @__PURE__ */ N(
327
327
  "div",
328
328
  {
329
329
  style: {
330
330
  width: "100%",
331
331
  height: "100%",
332
- ..._,
333
- ...M,
332
+ ...L,
333
+ ...y,
334
334
  rotate: `${V}deg`,
335
335
  overflow: "visible",
336
- transform: B,
336
+ transform: F,
337
337
  pointerEvents: "none",
338
- background: Object.keys(M).length === 0 ? "transparent" : M.backgroundColor
338
+ background: Object.keys(y).length === 0 ? "transparent" : y.backgroundColor
339
339
  },
340
- children: i
340
+ children: c
341
341
  }
342
342
  )
343
343
  }
344
344
  );
345
345
  }, G = (t) => {
346
- let f = "", s = "", i = "scale(1)", m = "", a = "", $ = "", u = "";
346
+ let f = "", s = "", c = "scale(1)", m = "", a = "", $ = "", u = "";
347
347
  const p = t.match(/translateX\([^)]+\)/g);
348
348
  p && (f = p[p.length - 1]);
349
349
  const o = t.match(/translateY\([^)]+\)/g);
350
350
  o && (s = o[o.length - 1]);
351
351
  const e = t.match(/scale\([^)]+\)/g);
352
- e && (i = e[e.length - 1]);
352
+ e && (c = e[e.length - 1]);
353
353
  const n = t.match(/rotate\([^)]+\)/g);
354
354
  n && (m = n[n.length - 1]);
355
355
  const l = t.match(/rotateX\([^)]+\)/g);
356
356
  l && (a = l[l.length - 1]);
357
357
  const d = t.match(/rotateY\([^)]+\)/g);
358
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 };
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
361
  }, st = ({
362
362
  animationTimed: t,
363
363
  durationInFrames: f,
364
364
  children: s,
365
- style: i = {},
365
+ style: c = {},
366
366
  frame: m
367
367
  }) => {
368
368
  var l;
369
- const a = j(
370
- F(t),
369
+ const a = I(
370
+ j(t),
371
371
  f,
372
372
  m,
373
373
  !1,
374
374
  !0
375
- ), u = ((i == null ? void 0 : i.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), p = u ? parseFloat(u[1]) : 0, o = -p, e = I.useMemo(() => ({
375
+ ), u = ((c == null ? void 0 : c.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), p = u ? parseFloat(u[1]) : 0, o = -p, e = C.useMemo(() => ({
376
376
  ...a
377
377
  }), [a]);
378
378
  if ((l = e.transform) != null && l.includes("rotate")) {
379
379
  const d = e.transform;
380
380
  e.transform = d.replace(
381
381
  /rotate\(([^)]+)deg\)/,
382
- (x, S) => `rotate(${parseFloat(S) - o}deg)`
382
+ (S, M) => `rotate(${parseFloat(M) - o}deg)`
383
383
  );
384
384
  }
385
385
  let n = e;
@@ -387,19 +387,19 @@ const z = () => ({
387
387
  ...n,
388
388
  transform: n.transform.replace(
389
389
  /translateX\(([^)]+)\)/g,
390
- (d, x) => `translateX(${parseFloat(x)}%)`
390
+ (d, S) => `translateX(${parseFloat(S)}%)`
391
391
  )
392
- }), /* @__PURE__ */ A(
392
+ }), /* @__PURE__ */ N(
393
393
  "div",
394
394
  {
395
395
  style: {
396
396
  overflow: e.overflow || "visible",
397
397
  pointerEvents: "none",
398
- height: i.height || "100%",
399
- width: i.width || "100%",
398
+ height: c.height || "100%",
399
+ width: c.width || "100%",
400
400
  ...n
401
401
  },
402
- children: /* @__PURE__ */ A(
402
+ children: /* @__PURE__ */ N(
403
403
  "div",
404
404
  {
405
405
  style: {
@@ -422,94 +422,68 @@ const z = () => ({
422
422
  switch (t == null ? void 0 : t.easing) {
423
423
  case "ease-in":
424
424
  case "accelerate":
425
- return X.in(X.cubic);
425
+ return A.in(A.cubic);
426
426
  case "ease-out":
427
427
  case "smooth":
428
428
  case "slowDown":
429
- return X.out(X.cubic);
429
+ return A.out(A.cubic);
430
430
  case "ease-in-out":
431
431
  case "natural":
432
432
  case "swing":
433
- return X.inOut(X.cubic);
433
+ return A.inOut(A.cubic);
434
434
  case "bounce":
435
- return X.bounce;
435
+ return A.bounce;
436
436
  case "elastic":
437
- return X.elastic(1);
437
+ return A.elastic(1);
438
438
  case "overshoot":
439
439
  case "impulse":
440
- return X.out(X.back(1.7));
440
+ return A.out(A.back(1.7));
441
441
  case "none":
442
442
  case "linear":
443
443
  default:
444
- return X.linear;
444
+ return A.linear;
445
445
  }
446
446
  }, K = ({
447
447
  children: t,
448
448
  currentWidth: f,
449
449
  currentHeight: s,
450
- frame: i,
450
+ frame: c,
451
451
  item: m,
452
452
  keyframeAnimations: a,
453
453
  durationInFrames: $
454
454
  }) => {
455
- var O, L;
455
+ var R, P;
456
456
  if (!a || !Array.isArray(a) || a.length === 0)
457
- return /* @__PURE__ */ A(H, { children: t });
457
+ return /* @__PURE__ */ N(H, { children: t });
458
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"));
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
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"));
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
464
  }, o = a.find(
465
465
  (r) => u(r) && !p(r)
466
466
  ), e = a.find(
467
467
  (r) => u(r) && p(r)
468
468
  );
469
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;
470
+ return /* @__PURE__ */ N(H, { children: t });
471
+ const n = Math.max(1, $ || 300);
472
+ let l = null, d = !1, S = 30, M = 0;
476
473
  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);
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);
488
476
  }
489
477
  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;
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;
499
481
  }
500
482
  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(
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(
513
487
  "div",
514
488
  {
515
489
  style: {
@@ -521,8 +495,8 @@ const z = () => ({
521
495
  children: t
522
496
  }
523
497
  );
524
- if (!d && o && i < v)
525
- return /* @__PURE__ */ A(
498
+ if (!d && o && c < x)
499
+ return /* @__PURE__ */ N(
526
500
  "div",
527
501
  {
528
502
  style: {
@@ -534,92 +508,72 @@ const z = () => ({
534
508
  children: t
535
509
  }
536
510
  );
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(
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(
559
516
  ${r}%
560
517
  0%
561
518
  ${r}%
562
519
  0%
563
520
  )`;
564
- } else if (C) {
565
- const r = d ? 25 * c : 25 * (1 - c);
566
- g = `inset(
521
+ } else if (T) {
522
+ const r = d ? 25 * i : 25 * (1 - i);
523
+ b = `inset(
567
524
  ${r}%
568
525
  ${r}%
569
526
  ${r}%
570
527
  ${r}%
571
528
  )`;
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)`;
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)`;
579
536
  } 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(" ");
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(" ");
588
542
  return console.log("[MaskAnim] Rendering:", {
589
- propName: E,
590
- frame: i,
591
- localFrame: S,
592
- animDuration: x,
593
- progress: M,
594
- easedProgress: c,
543
+ propName: X,
544
+ frame: c,
545
+ localFrame: M,
546
+ animDuration: S,
547
+ progress: y,
548
+ easedProgress: i,
595
549
  isOut: d,
596
- isShrinkScale: C,
597
- isCenterScale: T,
598
- isSlide: _,
599
- direction: w,
600
- clipPath: g,
550
+ isShrinkScale: T,
551
+ isCenterScale: _,
552
+ isSlide: L,
553
+ direction: g,
554
+ clipPath: b,
601
555
  translateTransform: h,
602
- isScale: b,
603
- scaleValue: y,
604
- innerTransform: N
605
- }), /* @__PURE__ */ A(
556
+ isScale: v,
557
+ scaleValue: w,
558
+ innerTransform: O
559
+ }), /* @__PURE__ */ N(
606
560
  "div",
607
561
  {
608
562
  style: {
609
563
  width: f !== void 0 ? f : "100%",
610
564
  height: s !== void 0 ? s : "100%",
611
565
  position: "relative",
612
- clipPath: g,
613
- WebkitClipPath: g,
566
+ clipPath: b,
567
+ WebkitClipPath: b,
614
568
  overflow: "hidden"
615
569
  },
616
- children: /* @__PURE__ */ A(
570
+ children: /* @__PURE__ */ N(
617
571
  "div",
618
572
  {
619
573
  style: {
620
574
  width: "100%",
621
575
  height: "100%",
622
- transform: N,
576
+ transform: O,
623
577
  transformOrigin: "center"
624
578
  },
625
579
  children: t
@@ -633,7 +587,7 @@ export {
633
587
  st as ContentAnim,
634
588
  ot as MaskAnim,
635
589
  et as combine,
636
- F as combineAnimations,
590
+ j as combineAnimations,
637
591
  G as extractTransformations,
638
- j as useAnimation
592
+ I as useAnimation
639
593
  };
package/dist/index.umd.js CHANGED
@@ -1,11 +1,11 @@
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(
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
2
  ${r}%
3
3
  0%
4
4
  ${r}%
5
5
  0%
6
- )`}else if(P){const r=d?25*c:25*(1-c);m=`inset(
6
+ )`}else if(_){const r=d?25*i:25*(1-i);b=`inset(
7
7
  ${r}%
8
8
  ${r}%
9
9
  ${r}%
10
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"})});
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,6 @@
1
1
  import { default as React } from 'react';
2
2
 
3
- export declare const MaskWrapper: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames, }: {
3
+ export declare const MaskWrapper: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames }: {
4
4
  children: React.ReactNode;
5
5
  currentWidth?: number;
6
6
  currentHeight?: number;
@@ -9,7 +9,7 @@ export declare const MaskWrapper: ({ children, currentWidth: _currentWidth, curr
9
9
  keyframeAnimations: any;
10
10
  durationInFrames?: number;
11
11
  }) => React.JSX.Element;
12
- export declare const MaskAnim: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames, }: {
12
+ export declare const MaskAnim: ({ children, currentWidth: _currentWidth, currentHeight: _currentHeight, frame, item: _item, keyframeAnimations, durationInFrames: itemDurationInFrames }: {
13
13
  children: React.ReactNode;
14
14
  currentWidth?: number;
15
15
  currentHeight?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cliquify.me/animations",
3
- "version": "9.0.11",
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.10",
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.10"
41
+ "@cliquify.me/types": "8.0.11"
42
42
  },
43
43
  "scripts": {
44
44
  "dev": "vite",