@cliquify.me/animations 8.0.0 → 8.0.1

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