@cliquify.me/animations 6.0.9 → 6.0.11

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