@cliquify.me/animations 6.0.0

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/LICENSE ADDED
@@ -0,0 +1,46 @@
1
+ DESIGNCOMBO COMMERCIAL LICENSE
2
+ Copyright (c) 2024 Layerhub LLC
3
+
4
+ This is a commercial license agreement between Layerhub LLC ("Licensor") and the purchaser ("Licensee") of the DesignCombo software package.
5
+
6
+ 1. GRANT OF LICENSE
7
+ Subject to the terms and conditions of this Agreement, Licensor grants Licensee a non-exclusive, non-transferable license to:
8
+ a) Use the DesignCombo software package for commercial and non-commercial purposes
9
+ b) Modify the source code to suit Licensee's specific needs
10
+ c) Deploy the modified version in production environments
11
+
12
+ 2. SUBSCRIPTION TERMS
13
+ a) The license is granted for a specified subscription period (e.g., 12 months)
14
+ b) During the subscription period, Licensee will receive:
15
+ - Access to the source code
16
+ - Regular updates and improvements
17
+ - Technical support
18
+ c) After the subscription period ends:
19
+ - Licensee may continue using the last version received during the subscription
20
+ - Licensee may continue using any modifications made to that version
21
+ - Licensee will no longer receive updates or technical support
22
+ - Licensee may renew the subscription to receive updates and support
23
+
24
+ 3. RESTRICTIONS
25
+ Licensee may not:
26
+ a) Redistribute, resell, or sublicense the original or modified software
27
+ b) Remove or alter any copyright notices or proprietary markings
28
+ c) Use the software to create a competing product
29
+ d) Transfer the license to another party
30
+
31
+ 4. INTELLECTUAL PROPERTY
32
+ The original DesignCombo software and all its components remain the exclusive property of Layerhub.
33
+ Licensee retains rights to their specific modifications, but not to the underlying software.
34
+
35
+ 5. WARRANTY
36
+ The software is provided "as is" without warranty of any kind. Layerhub is not liable for any damages arising from the use of the software.
37
+
38
+ 6. TERMINATION
39
+ This license is effective until terminated. Layerhub may terminate this license if Licensee fails to comply with any of its terms and conditions.
40
+
41
+ 7. GOVERNING LAW
42
+ This Agreement shall be governed by and construed in accordance with the laws of the jurisdiction in which Layerhub LLC is established.
43
+
44
+ For licensing inquiries, please contact Layerhub LLC at [contact information].
45
+
46
+ Version 1.1 - Effective Date: March 19, 2024
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # @designcombo/animations
2
+
3
+ A powerful animation library for managing complex animation sequences and transitions in React applications, with specialized components for different animation scenarios.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @designcombo/animations
9
+ # or
10
+ yarn add @designcombo/animations
11
+ # or
12
+ pnpm add @designcombo/animations
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### BoxAnim Component
18
+
19
+ The main animation wrapper for standard in/out animations with rotation handling:
20
+
21
+ ```tsx
22
+ import { BoxAnim } from "@designcombo/animations";
23
+
24
+ <BoxAnim
25
+ animationIn={[
26
+ {
27
+ property: "opacity",
28
+ from: 0,
29
+ to: 1,
30
+ durationInFrames: 30,
31
+ ease: (t) => t,
32
+ delay: 0
33
+ },
34
+ {
35
+ property: "translateX",
36
+ from: -100,
37
+ to: 0,
38
+ durationInFrames: 30,
39
+ ease: (t) => t
40
+ }
41
+ ]}
42
+ animationOut={[
43
+ {
44
+ property: "opacity",
45
+ from: 1,
46
+ to: 0,
47
+ durationInFrames: 15,
48
+ ease: (t) => t
49
+ }
50
+ ]}
51
+ durationInFrames={60}
52
+ frame={currentFrame}
53
+ style={{ transform: "rotate(45deg)" }}
54
+ >
55
+ <div>Your BoxAnim content here</div>
56
+ </BoxAnim>;
57
+ ```
58
+
59
+ ### ContentAnim Component
60
+
61
+ For timed animations that are affected by rotation transformations:
62
+
63
+ ```tsx
64
+ import { ContentAnim } from "@designcombo/animations";
65
+
66
+ <ContentAnim
67
+ animationTimed={[
68
+ {
69
+ property: "scale",
70
+ from: 0.8,
71
+ to: 1.2,
72
+ durationInFrames: 45,
73
+ ease: (t) => t,
74
+ persist: true
75
+ }
76
+ ]}
77
+ durationInFrames={60}
78
+ frame={currentFrame}
79
+ style={{ width: 200, height: 200 }}
80
+ >
81
+ <div>Content with timed animations</div>
82
+ </ContentAnim>;
83
+ ```
84
+
85
+ ### MaskAnim Component
86
+
87
+ For creating mask reveal animations with different patterns:
88
+
89
+ ```tsx
90
+ import { MaskAnim } from "@designcombo/animations";
91
+
92
+ <MaskAnim
93
+ frame={currentFrame}
94
+ item={itemData}
95
+ keyframeAnimations={[
96
+ {
97
+ property: "maskRevealIn", // or "maskRevealCenterIn", "maskRevealCornerIn"
98
+ durationInFrames: 30
99
+ }
100
+ ]}
101
+ >
102
+ <div>Content that will be revealed with mask animation</div>
103
+ </MaskAnim>;
104
+ ```
105
+
106
+ ### Animation Hook
107
+
108
+ Direct access to animation calculations:
109
+
110
+ ```tsx
111
+ import {
112
+ useAnimation,
113
+ combineAnimations,
114
+ combine
115
+ } from "@designcombo/animations";
116
+
117
+ // Basic usage
118
+ const style = useAnimation(
119
+ combineAnimations(animations),
120
+ durationInFrames,
121
+ frame,
122
+ false // isOut
123
+ );
124
+
125
+ // Advanced usage with timed animations
126
+ const timedStyle = useAnimation(
127
+ combineAnimations(animations),
128
+ durationInFrames,
129
+ frame,
130
+ false, // isOut
131
+ true // isTimed
132
+ );
133
+
134
+ // Combining multiple animation sources
135
+ const combinedAnimations = combine(
136
+ animationIn,
137
+ animationOut,
138
+ additionalAnimations
139
+ );
140
+ ```
141
+
142
+ ## Animation Properties
143
+
144
+ The library supports various animation properties:
145
+
146
+ - **Transform Properties**: `scale`, `translateX`, `translateY`, `rotate`
147
+ - **Visual Properties**: `opacity`
148
+ - **Special Properties**: `shake` (with automatic intervals)
149
+ - **Mask Properties**: `maskRevealIn`, `maskRevealCenterIn`, `maskRevealCornerIn`
150
+
151
+ ## Animation Interface
152
+
153
+ ```tsx
154
+ interface Animation {
155
+ property: keyof React.CSSProperties | string;
156
+ from: number;
157
+ to: number;
158
+ durationInFrames: number;
159
+ ease: (t: number) => number;
160
+ delay?: number;
161
+ persist?: boolean; // For timed animations
162
+ }
163
+ ```
164
+
165
+ ## Features
166
+
167
+ - **Animated Component**: Main wrapper for in/out animations with rotation compensation
168
+ - **ContentAnimations Component**: Specialized for timed animations affected by rotation
169
+ - **MaskWrapper Component**: Creates mask reveal effects with multiple patterns
170
+ - **Animation Hook**: Direct access to animation calculations
171
+ - **Rotation Handling**: Automatic compensation for rotated elements
172
+ - **Persistent Animations**: Support for animations that persist after completion
173
+ - **Shake Effects**: Built-in shake animation with automatic intervals
174
+ - **Transform Extraction**: Utilities for parsing and combining transform properties
175
+ - **Performance Optimized**: Efficient animation rendering with memoization
176
+ - **TypeScript Support**: Full type safety with comprehensive interfaces
177
+ - **Remotion Integration**: Built for Remotion video framework
178
+
179
+ ## Development
180
+
181
+ ```bash
182
+ # Install dependencies
183
+ pnpm install
184
+
185
+ # Start development server
186
+ pnpm dev
187
+
188
+ # Build package
189
+ pnpm build
190
+
191
+ # Format code
192
+ pnpm format
193
+ ```
194
+
195
+ ## License
196
+
197
+ MIT
@@ -0,0 +1,28 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface Animation {
4
+ property: keyof React.CSSProperties | string;
5
+ from: number;
6
+ to: number;
7
+ durationInFrames: number;
8
+ ease: (t: number) => number;
9
+ delay?: number;
10
+ }
11
+ export interface AnimatedProps {
12
+ animationIn?: Animation | Animation[] | null;
13
+ animationOut?: Animation | Animation[] | null;
14
+ durationInFrames: number;
15
+ children: React.ReactNode;
16
+ className?: string;
17
+ style?: React.CSSProperties;
18
+ frame: number;
19
+ }
20
+ export declare const BoxAnim: React.FC<AnimatedProps>;
21
+ export declare const combine: (...animations: (Animation | Animation[] | undefined)[]) => Animation[];
22
+ export declare const extractTransformations: (transform: string) => {
23
+ translateX: string;
24
+ translateY: string;
25
+ scale: string;
26
+ rotation: string;
27
+ rotateY: string;
28
+ };
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { Animation } from './Animated';
3
+
4
+ export interface ContentAnimationsProps {
5
+ animationTimed?: Animation | Animation[] | null;
6
+ durationInFrames: number;
7
+ children: React.ReactNode;
8
+ style?: React.CSSProperties;
9
+ frame: number;
10
+ }
11
+ export declare const ContentAnim: React.FC<ContentAnimationsProps>;
@@ -0,0 +1,7 @@
1
+ export { BoxAnim } from './Animated';
2
+ export { useAnimation, combineAnimations, combine } from './use-animation';
3
+ export type { Animation, AnimatedProps } from './Animated';
4
+ export { extractTransformations } from './Animated';
5
+ export { ContentAnim } from './content';
6
+ export type { ContentAnimationsProps } from './content';
7
+ export { MaskAnim } from './mask';
@@ -0,0 +1,343 @@
1
+ import { jsx as w } from "react/jsx-runtime";
2
+ import x, { useMemo as V } from "react";
3
+ import { interpolate as Y } from "remotion";
4
+ const j = () => ({
5
+ scale: (t) => ({ transform: `scale(${t})` }),
6
+ opacity: (t) => ({ opacity: t }),
7
+ translateX: (t) => ({ transform: `translateX(${t}px)` }),
8
+ translateY: (t) => ({ transform: `translateY(${t}px)` }),
9
+ rotate: (t) => ({ transform: `rotate(${t}deg)` }),
10
+ default: () => ({}),
11
+ rotateY: (t) => ({ transform: `rotateY(${t}deg)` }),
12
+ shakeHorizontalIn: (t) => ({
13
+ transform: `translateX(${t}px)`,
14
+ overflow: "hidden"
15
+ }),
16
+ shakeVerticalIn: (t) => ({
17
+ transform: `translateY(${t}px)`,
18
+ overflow: "hidden"
19
+ }),
20
+ shakeHorizontalOut: (t) => ({
21
+ transform: `translateX(${t}px)`,
22
+ overflow: "hidden"
23
+ }),
24
+ shakeVerticalOut: (t) => ({
25
+ transform: `translateY(${t}px)`,
26
+ overflow: "hidden"
27
+ })
28
+ }), R = (t, n = 0) => {
29
+ const e = [], s = t / 5;
30
+ for (let l = 0; l < 6; l += 1)
31
+ e.push(l * s + n);
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))
36
+ return console.error("Invalid animation values:", {
37
+ from: l,
38
+ to: r,
39
+ animationDurationInFrames: o,
40
+ property: n.property
41
+ }), f;
42
+ o === void 0 && console.warn(
43
+ `durationInFrames is undefined for animation: ${n.property}. Using 1 frame as default.`
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(
52
+ t,
53
+ p,
54
+ [0, f, c, f, c, 0],
55
+ {
56
+ extrapolateLeft: "clamp",
57
+ extrapolateRight: "clamp",
58
+ easing: i
59
+ }
60
+ );
61
+ }
62
+ return Y(t, d, [f, c], {
63
+ extrapolateLeft: "clamp",
64
+ extrapolateRight: "clamp",
65
+ easing: i
66
+ });
67
+ }, E = (t, n, e, s) => {
68
+ const l = n - (t.delay || 0) * (s ? -1 : 1), { property: r, durationInFrames: i } = t;
69
+ if (!s && l > i) return {};
70
+ const o = I(
71
+ l,
72
+ t,
73
+ e,
74
+ s
75
+ ), f = j();
76
+ return (f[r] || f.default)(o);
77
+ }, M = (t, n, e, s = !1, l = !1) => x.useMemo(() => {
78
+ if (t.length === 0) return {};
79
+ const r = t.filter(
80
+ (i) => i.from !== void 0 && i.to !== void 0
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 = E(a, e, n, !1);
86
+ if (a.persist === !0 && e - (a.delay || 0) >= a.durationInFrames) {
87
+ const $ = a.to, u = j(), 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;
92
+ });
93
+ }
94
+ i.push(d);
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),
100
+ {}
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;
106
+ } else
107
+ return r.map((o) => E(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),
111
+ {}
112
+ );
113
+ }, [t, e, n, s]), F = (t) => t ? Array.isArray(t) ? t : [t] : [], D = (...t) => {
114
+ const n = [];
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
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),
124
+ durationInFrames: Math.max(
125
+ r.durationInFrames,
126
+ s.durationInFrames
127
+ ),
128
+ delay: Math.min(r.delay || 0, s.delay || 0),
129
+ ease: (i) => (r.ease(i) + s.ease(i)) / 2
130
+ // Average the easing functions
131
+ } : r
132
+ ) : [...e, s], []);
133
+ }, _ = ({
134
+ animationIn: t,
135
+ animationOut: n,
136
+ durationInFrames: e,
137
+ children: s,
138
+ style: l = {},
139
+ frame: r
140
+ }) => {
141
+ var X;
142
+ const i = M(
143
+ F(t),
144
+ e,
145
+ r,
146
+ !1
147
+ ), o = M(
148
+ F(n),
149
+ e,
150
+ r,
151
+ !0
152
+ ), f = x.useMemo(() => {
153
+ const m = Object.keys(i).length > 0, v = t == null ? void 0 : t.reduce(
154
+ (y, S) => Math.min(y, S.delay || 0),
155
+ 1 / 0
156
+ ), g = r - (v || 0);
157
+ return m && g < 0 ? { visibility: "hidden" } : i;
158
+ }, [i, r, t]), c = x.useMemo(() => {
159
+ const m = (n == null ? void 0 : n.length) > 0, v = n == null ? void 0 : n.reduce(
160
+ (g, y) => {
161
+ const S = y.delay || 0;
162
+ return Math.max(g, S);
163
+ },
164
+ 0
165
+ );
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 = x.useMemo(() => {
168
+ const m = {
169
+ ...f
170
+ // , ...timedStyle
171
+ };
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(
179
+ /rotate\(([^)]+)deg\)/,
180
+ (v, g) => `rotate(${parseFloat(g) - $}deg)`
181
+ );
182
+ }
183
+ const b = V(() => {
184
+ const m = u.transform || "", { translateX: v, translateY: g, scale: y, rotation: S, rotateY: A } = H(m);
185
+ return `${v} ${g} ${y} ${S || `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(
191
+ /translateX\(([^)]+)\)/g,
192
+ (m, v) => `translateX(${parseFloat(v)}px)`
193
+ )
194
+ }), /* @__PURE__ */ w(
195
+ "div",
196
+ {
197
+ style: {
198
+ overflow: u.overflow || "visible",
199
+ pointerEvents: "none",
200
+ ...h,
201
+ transform: (h.transform || "") + ` -rotate(${$}deg) scale(1)`,
202
+ background: Object.keys(u).length === 0 ? "transparent" : u.backgroundColor,
203
+ display: "flex",
204
+ justifyContent: "center"
205
+ },
206
+ children: /* @__PURE__ */ w(
207
+ "div",
208
+ {
209
+ style: {
210
+ ...l,
211
+ ...u,
212
+ rotate: `${$}deg`,
213
+ overflow: "visible",
214
+ transform: b,
215
+ pointerEvents: "none",
216
+ background: Object.keys(u).length === 0 ? "transparent" : u.backgroundColor
217
+ },
218
+ children: s
219
+ }
220
+ )
221
+ }
222
+ );
223
+ }, H = (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]);
229
+ const f = t.match(/scale\([^)]+\)/);
230
+ 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 = ({
236
+ animationTimed: t,
237
+ durationInFrames: n,
238
+ children: e,
239
+ style: s = {},
240
+ frame: l
241
+ }) => {
242
+ var p;
243
+ const r = M(
244
+ F(t),
245
+ n,
246
+ l,
247
+ !1,
248
+ !0
249
+ ), o = ((s == null ? void 0 : s.transform) || "").match(/rotate\((-?[\d.]+)deg\)/), f = o ? parseFloat(o[1]) : 0, c = -f, a = x.useMemo(() => ({
250
+ ...r
251
+ }), [r]);
252
+ if ((p = a.transform) != null && p.includes("rotate")) {
253
+ const $ = a.transform;
254
+ a.transform = $.replace(
255
+ /rotate\(([^)]+)deg\)/,
256
+ (u, b) => `rotate(${parseFloat(b) - c}deg)`
257
+ );
258
+ }
259
+ let d = a;
260
+ return f > 0 && d.transform && d.transform.includes("translateX") && (d = {
261
+ ...d,
262
+ transform: d.transform.replace(
263
+ /translateX\(([^)]+)\)/g,
264
+ ($, u) => `translateX(${parseFloat(u)}px)`
265
+ )
266
+ }), /* @__PURE__ */ w(
267
+ "div",
268
+ {
269
+ style: {
270
+ overflow: a.overflow || "visible",
271
+ pointerEvents: "none",
272
+ height: s.height,
273
+ width: s.width,
274
+ ...d
275
+ },
276
+ children: /* @__PURE__ */ w(
277
+ "div",
278
+ {
279
+ style: {
280
+ ...a,
281
+ overflow: "visible",
282
+ pointerEvents: "none",
283
+ height: "100%",
284
+ width: "100%"
285
+ },
286
+ children: e
287
+ }
288
+ )
289
+ }
290
+ );
291
+ }, L = ({
292
+ children: t,
293
+ frame: n,
294
+ item: e,
295
+ keyframeAnimations: s
296
+ }) => {
297
+ var p, $;
298
+ const l = s == null ? void 0 : s.find(
299
+ (u) => u.property.includes("maskReveal")
300
+ ), r = ((p = e.details.crop) == null ? void 0 : p.width) || e.details.width, i = (($ = e.details.crop) == null ? void 0 : $.height) || e.details.height;
301
+ let o = 1, f = i, c = 0, a = 0, d = r;
302
+ if ((n || 0) - e.display.from >= 0 && (l == null ? void 0 : l.property) === "maskRevealIn")
303
+ o = Math.min((n || 0) / l.durationInFrames, 1), f = i - i * (1 - o);
304
+ else if ((n || 0) - e.display.from >= 0 && (l == null ? void 0 : l.property) === "maskRevealCenterIn") {
305
+ o = Math.min((n || 0) / l.durationInFrames, 1);
306
+ const u = r / 2, b = i / 2;
307
+ d = r, f = i * o, c = u - d / 2, a = b - f / 2;
308
+ } 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);
309
+ return /* @__PURE__ */ w(
310
+ "div",
311
+ {
312
+ style: {
313
+ width: r,
314
+ height: i,
315
+ position: "relative",
316
+ overflow: "hidden"
317
+ },
318
+ children: /* @__PURE__ */ w(
319
+ "div",
320
+ {
321
+ style: {
322
+ position: "absolute",
323
+ left: c,
324
+ top: a,
325
+ width: d,
326
+ height: f,
327
+ overflow: "hidden"
328
+ },
329
+ children: t
330
+ }
331
+ )
332
+ }
333
+ );
334
+ };
335
+ export {
336
+ _ as BoxAnim,
337
+ z as ContentAnim,
338
+ L as MaskAnim,
339
+ D as combine,
340
+ F as combineAnimations,
341
+ H as extractTransformations,
342
+ M as useAnimation
343
+ };
@@ -0,0 +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},I=(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),{property:r,durationInFrames:i}=t;if(!a&&l>i)return{};const n=I(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 $=s.to,p=X(),y=(p[s.property]||p.default)($);Object.keys(y).forEach(h=>{h==="transform"?n[h]=n[h]?{[h]:`${n[h][h]} ${y[h]}`}:y:n[h]=y})}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 T;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,$=-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((T=p.transform)!=null&&T.includes("rotate")){const m=p.transform;p.transform=m.replace(/rotate\(([^)]+)deg\)/,(v,b)=>`rotate(${parseFloat(b)-$}deg)`)}const y=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(${$}deg) scale(1)`,background:Object.keys(p).length===0?"transparent":p.backgroundColor,display:"flex",justifyContent:"center"},children:S.jsx("div",{style:{...l,...p,rotate:`${$}deg`,overflow:"visible",transform:y,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 $=s.transform;s.transform=$.replace(/rotate\(([^)]+)deg\)/,(p,y)=>`rotate(${parseFloat(y)-c}deg)`)}let d=s;return f>0&&d.transform&&d.transform.includes("translateX")&&(d={...d,transform:d.transform.replace(/translateX\(([^)]+)\)/g,($,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%"},children:e})})},R=({children:t,frame:o,item:e,keyframeAnimations:a})=>{var u,$;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=(($=e.details.crop)==null?void 0:$.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,y=i/2;d=r,f=i*n,c=p-d/2,s=y-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"})});
package/dist/mask.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const MaskAnim: ({ children, frame, item, keyframeAnimations }: {
2
+ children: React.ReactNode;
3
+ frame: number;
4
+ item: any;
5
+ keyframeAnimations: any;
6
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface Animation {
4
+ property: keyof React.CSSProperties | string;
5
+ from: number;
6
+ to: number;
7
+ durationInFrames: number;
8
+ ease: (t: number) => number;
9
+ delay?: number;
10
+ persist?: boolean;
11
+ }
12
+ export declare const useAnimation: (animations: Animation[], durationInFrames: number, frame: number, isOut?: boolean, isTimed?: boolean) => React.CSSProperties;
13
+ export declare const combineAnimations: (animations: Animation | Animation[] | undefined) => Animation[];
14
+ export declare const combine: (...animations: (Animation | Animation[] | undefined)[]) => Animation[];
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@cliquify.me/animations",
3
+ "version": "6.0.0",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "main": "dist/index.umd.js",
12
+ "module": "dist/index.es.js",
13
+ "types": "dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./dist/index.es.js",
17
+ "require": "./dist/index.umd.js",
18
+ "types": "./dist/index.d.ts"
19
+ }
20
+ },
21
+ "devDependencies": {
22
+ "@designcombo/events": "^1.0.2",
23
+ "@types/node": "^20.11.24",
24
+ "@types/react": "^18.2.0",
25
+ "rollup-plugin-peer-deps-external": "^2.2.4",
26
+ "typescript": "^5.3.3",
27
+ "vite": "^5.2.0",
28
+ "vite-plugin-dts": "^3.9.1",
29
+ "@cliquify.me/types": "5.0.0",
30
+ "@cliquify.me/typescript-config": "0.0.2"
31
+ },
32
+ "dependencies": {
33
+ "react": "^18.2.0",
34
+ "remotion": "^4.0.0",
35
+ "rxjs": "^7.8.1",
36
+ "nanoid": "^5.0.7"
37
+ },
38
+ "peerDependencies": {
39
+ "@designcombo/events": "^1.0.2",
40
+ "react": "^18.2.0",
41
+ "remotion": "^4.0.0",
42
+ "@cliquify.me/types": "5.0.0"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "tsc && vite build",
47
+ "format": "prettier --write ."
48
+ }
49
+ }