@twick/visualizer 0.14.0 → 0.14.3
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/.eslintrc.json +20 -20
- package/README.md +113 -13
- package/package.json +14 -14
- package/package.json.bak +34 -0
- package/src/animations/blur.tsx +96 -60
- package/src/animations/breathe.tsx +95 -60
- package/src/animations/fade.tsx +173 -60
- package/src/animations/index.ts +12 -0
- package/src/animations/photo-rise.tsx +103 -66
- package/src/animations/photo-zoom.tsx +109 -73
- package/src/animations/rise.tsx +157 -118
- package/src/animations/succession.tsx +112 -77
- package/src/components/frame-effects.tsx +188 -188
- package/src/components/track.tsx +237 -232
- package/src/controllers/animation.controller.ts +38 -38
- package/src/controllers/element.controller.ts +42 -42
- package/src/controllers/frame-effect.controller.tsx +29 -29
- package/src/controllers/text-effect.controller.ts +32 -32
- package/src/elements/audio.element.tsx +79 -17
- package/src/elements/caption.element.tsx +169 -87
- package/src/elements/circle.element.tsx +88 -20
- package/src/elements/icon.element.tsx +88 -20
- package/src/elements/image.element.tsx +134 -55
- package/src/elements/index.ts +14 -0
- package/src/elements/rect.element.tsx +92 -22
- package/src/elements/scene.element.tsx +97 -29
- package/src/elements/text.element.tsx +101 -27
- package/src/elements/video.element.tsx +274 -56
- package/src/frame-effects/circle.frame.tsx +168 -103
- package/src/frame-effects/index.ts +7 -0
- package/src/frame-effects/rect.frame.tsx +198 -103
- package/src/global.css +11 -11
- package/src/helpers/caption.utils.ts +29 -29
- package/src/helpers/constants.ts +162 -158
- package/src/helpers/element.utils.ts +331 -239
- package/src/helpers/event.utils.ts +21 -0
- package/src/helpers/filters.ts +127 -127
- package/src/helpers/log.utils.ts +55 -29
- package/src/helpers/timing.utils.ts +109 -109
- package/src/helpers/types.ts +361 -241
- package/src/helpers/utils.ts +36 -19
- package/src/index.ts +196 -6
- package/src/live.tsx +16 -16
- package/src/project.ts +6 -6
- package/src/sample.ts +247 -247
- package/src/text-effects/elastic.tsx +70 -39
- package/src/text-effects/erase.tsx +91 -58
- package/src/text-effects/index.ts +9 -0
- package/src/text-effects/stream-word.tsx +94 -60
- package/src/text-effects/typewriter.tsx +93 -59
- package/src/visualizer-grouped.ts +83 -0
- package/src/visualizer.tsx +182 -78
- package/tsconfig.json +11 -11
- package/typedoc.json +19 -14
- package/vite.config.ts +15 -15
- package/.turbo/turbo-build.log +0 -19
- package/.turbo/turbo-docs.log +0 -7
- package/LICENSE +0 -197
- package/dist/mp4.wasm +0 -0
- package/dist/project.css +0 -1
- package/dist/project.js +0 -145
- package/docs/.nojekyll +0 -1
- package/docs/README.md +0 -13
- package/docs/interfaces/Animation.md +0 -47
- package/docs/interfaces/Element.md +0 -47
- package/docs/interfaces/FrameEffectPlugin.md +0 -47
- package/docs/interfaces/TextEffect.md +0 -47
- package/docs/modules.md +0 -535
package/src/animations/rise.tsx
CHANGED
|
@@ -1,118 +1,157 @@
|
|
|
1
|
-
import { all,
|
|
2
|
-
import { AnimationParams } from "../helpers/types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* RiseAnimation
|
|
6
|
-
* to create a "rising"
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - "
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// Start fully transparent
|
|
85
|
-
ref().opacity(0);
|
|
86
|
-
|
|
87
|
-
if (direction === "up") {
|
|
88
|
-
//
|
|
89
|
-
ref().y(pos.y + intensity);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
ref().
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
//
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
1
|
+
import { all, delay, waitFor } from "@twick/core";
|
|
2
|
+
import { AnimationParams } from "../helpers/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @group RiseAnimation
|
|
6
|
+
* RiseAnimation combines vertical motion and opacity transitions to create a "rising"
|
|
7
|
+
* (or "falling") appearance/disappearance effect. Moves elements vertically with
|
|
8
|
+
* optional scaling effects for dynamic visual impact.
|
|
9
|
+
*
|
|
10
|
+
* Available animation modes:
|
|
11
|
+
* - "enter": Starts offset and transparent, moves into position while fading in
|
|
12
|
+
* - "exit": Waits, then moves out of position while fading out
|
|
13
|
+
* - "both": Enters, waits, and exits in a continuous sequence
|
|
14
|
+
*
|
|
15
|
+
* @param elementRef - Reference to the main element to animate
|
|
16
|
+
* @param containerRef - Optional reference to a container element
|
|
17
|
+
* @param interval - Duration of movement and opacity transitions in seconds
|
|
18
|
+
* @param duration - Total duration of the animation in seconds
|
|
19
|
+
* @param animate - Animation phase ("enter" | "exit" | "both")
|
|
20
|
+
* @param direction - Direction to animate ("up" or "down")
|
|
21
|
+
* @param intensity - Number of units to offset position vertically
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```js
|
|
25
|
+
* // Rise up animation
|
|
26
|
+
* animation: {
|
|
27
|
+
* name: "rise",
|
|
28
|
+
* animate: "enter",
|
|
29
|
+
* duration: 1.5,
|
|
30
|
+
* direction: "up",
|
|
31
|
+
* intensity: 0.8
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* // Fall down animation
|
|
35
|
+
* animation: {
|
|
36
|
+
* name: "rise",
|
|
37
|
+
* animate: "exit",
|
|
38
|
+
* duration: 2,
|
|
39
|
+
* direction: "down",
|
|
40
|
+
* intensity: 300
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export const RiseAnimation = {
|
|
45
|
+
name: "rise",
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Generator function controlling the rise/fall animation.
|
|
49
|
+
* Handles vertical movement and opacity transitions based on direction and intensity.
|
|
50
|
+
*
|
|
51
|
+
* @param params - Animation parameters including element references, timing, and direction
|
|
52
|
+
* @returns Generator that controls the rise animation timeline
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```js
|
|
56
|
+
* yield* RiseAnimation.run({
|
|
57
|
+
* elementRef: myElement,
|
|
58
|
+
* interval: 0.25,
|
|
59
|
+
* duration: 1.5,
|
|
60
|
+
* animate: "enter",
|
|
61
|
+
* direction: "up",
|
|
62
|
+
* intensity: 200
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
*run({
|
|
67
|
+
elementRef,
|
|
68
|
+
containerRef,
|
|
69
|
+
interval = 0.25,
|
|
70
|
+
duration,
|
|
71
|
+
animate,
|
|
72
|
+
direction,
|
|
73
|
+
intensity = 200,
|
|
74
|
+
}: AnimationParams) {
|
|
75
|
+
// Use containerRef if provided, otherwise fallback to elementRef
|
|
76
|
+
const ref = containerRef ?? elementRef;
|
|
77
|
+
|
|
78
|
+
// Get the element's current position
|
|
79
|
+
const pos = ref().position();
|
|
80
|
+
|
|
81
|
+
let animationInterval = Math.min(interval, duration);
|
|
82
|
+
|
|
83
|
+
if (animate === "enter") {
|
|
84
|
+
// Start fully transparent
|
|
85
|
+
ref().opacity(0);
|
|
86
|
+
|
|
87
|
+
if (direction === "up") {
|
|
88
|
+
// Offset element below final position
|
|
89
|
+
ref().y(pos.y + intensity);
|
|
90
|
+
// Animate moving up while fading in
|
|
91
|
+
yield* all(
|
|
92
|
+
ref().opacity(1, animationInterval / 4),
|
|
93
|
+
ref().y(pos.y, animationInterval)
|
|
94
|
+
);
|
|
95
|
+
} else if (direction === "down") {
|
|
96
|
+
// Offset element above final position
|
|
97
|
+
ref().y(pos.y - intensity);
|
|
98
|
+
// Animate moving down while fading in
|
|
99
|
+
yield* all(
|
|
100
|
+
ref().opacity(1, animationInterval / 4),
|
|
101
|
+
ref().y(pos.y, animationInterval)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
} else if (animate === "exit") {
|
|
105
|
+
// Wait until exit animation starts
|
|
106
|
+
yield* waitFor(duration - animationInterval);
|
|
107
|
+
|
|
108
|
+
if (direction === "up") {
|
|
109
|
+
// Animate moving up while fading out (opacity fades slightly after motion starts)
|
|
110
|
+
yield* all(
|
|
111
|
+
delay((3 * animationInterval) / 4, ref().opacity(0, animationInterval / 4)),
|
|
112
|
+
ref().y(pos.y - intensity, animationInterval)
|
|
113
|
+
);
|
|
114
|
+
} else if (direction === "down") {
|
|
115
|
+
// Animate moving down while fading out
|
|
116
|
+
yield* all(
|
|
117
|
+
delay((3 * animationInterval) / 4, ref().opacity(0, animationInterval / 4)),
|
|
118
|
+
ref().y(pos.y + intensity, animationInterval)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
} else if (animate === "both") {
|
|
122
|
+
animationInterval = Math.min(interval, duration/2);
|
|
123
|
+
// Start fully transparent
|
|
124
|
+
ref().opacity(0);
|
|
125
|
+
|
|
126
|
+
if (direction === "up") {
|
|
127
|
+
// Enter animation: move up while fading in
|
|
128
|
+
ref().y(pos.y + intensity);
|
|
129
|
+
yield* all(
|
|
130
|
+
ref().opacity(1, animationInterval / 4),
|
|
131
|
+
ref().y(pos.y, animationInterval)
|
|
132
|
+
);
|
|
133
|
+
// Wait for the remaining duration
|
|
134
|
+
yield* waitFor(duration - animationInterval);
|
|
135
|
+
// Exit animation: move up further while fading out
|
|
136
|
+
yield* all(
|
|
137
|
+
delay((3 * animationInterval) / 4, ref().opacity(0, animationInterval / 4)),
|
|
138
|
+
ref().y(pos.y - intensity, animationInterval)
|
|
139
|
+
);
|
|
140
|
+
} else if (direction === "down") {
|
|
141
|
+
// Enter animation: move down while fading in
|
|
142
|
+
ref().y(pos.y - intensity);
|
|
143
|
+
yield* all(
|
|
144
|
+
ref().opacity(1, animationInterval / 4),
|
|
145
|
+
ref().y(pos.y, animationInterval)
|
|
146
|
+
);
|
|
147
|
+
// Wait for the remaining duration
|
|
148
|
+
yield* waitFor(duration - animationInterval);
|
|
149
|
+
// Exit animation: move down further while fading out
|
|
150
|
+
yield* all(
|
|
151
|
+
delay((3 * animationInterval) / 4, ref().opacity(0, animationInterval / 4)),
|
|
152
|
+
ref().y(pos.y + intensity, animationInterval)
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
@@ -1,77 +1,112 @@
|
|
|
1
|
-
import { all, delay, Vector2, waitFor } from "@twick/core";
|
|
2
|
-
import { AnimationParams } from "../helpers/types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* SuccessionAnimation
|
|
6
|
-
* to create an appearing
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* - "
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
import { all, delay, Vector2, waitFor } from "@twick/core";
|
|
2
|
+
import { AnimationParams } from "../helpers/types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @group SuccessionAnimation
|
|
6
|
+
* SuccessionAnimation combines scaling and opacity transitions to create an appearing
|
|
7
|
+
* and disappearing zoom effect. Creates dynamic zoom animations that draw attention
|
|
8
|
+
* to content with smooth scaling and fade transitions.
|
|
9
|
+
*
|
|
10
|
+
* Available animation modes:
|
|
11
|
+
* - "enter": Starts scaled down and transparent, then scales up while fading in
|
|
12
|
+
* - "exit": Waits, then scales down while fading out
|
|
13
|
+
* - "both": Scales up and fades in, waits, then scales down and fades out
|
|
14
|
+
*
|
|
15
|
+
* @param elementRef - Reference to the main element to animate
|
|
16
|
+
* @param containerRef - Optional reference to a container element
|
|
17
|
+
* @param interval - Duration of scaling and opacity transitions in seconds
|
|
18
|
+
* @param duration - Total duration of the animation in seconds
|
|
19
|
+
* @param animate - Animation phase ("enter" | "exit" | "both")
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```js
|
|
23
|
+
* // Zoom in effect
|
|
24
|
+
* animation: {
|
|
25
|
+
* name: "succession",
|
|
26
|
+
* animate: "enter",
|
|
27
|
+
* duration: 2,
|
|
28
|
+
* interval: 0.5
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // Zoom out effect
|
|
32
|
+
* animation: {
|
|
33
|
+
* name: "succession",
|
|
34
|
+
* animate: "exit",
|
|
35
|
+
* duration: 1.5,
|
|
36
|
+
* interval: 0.3
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export const SuccessionAnimation = {
|
|
41
|
+
name: "succession",
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generator function controlling the succession animation.
|
|
45
|
+
* Handles scaling and opacity transitions to create zoom effects.
|
|
46
|
+
*
|
|
47
|
+
* @param params - Animation parameters including element references and timing
|
|
48
|
+
* @returns Generator that controls the succession animation timeline
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```js
|
|
52
|
+
* yield* SuccessionAnimation.run({
|
|
53
|
+
* elementRef: myElement,
|
|
54
|
+
* interval: 0.5,
|
|
55
|
+
* duration: 2,
|
|
56
|
+
* animate: "enter"
|
|
57
|
+
* });
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
*run({
|
|
61
|
+
elementRef,
|
|
62
|
+
containerRef,
|
|
63
|
+
interval,
|
|
64
|
+
duration,
|
|
65
|
+
animate,
|
|
66
|
+
}: AnimationParams) {
|
|
67
|
+
// Use containerRef if provided, otherwise fallback to elementRef
|
|
68
|
+
const ref = containerRef ?? elementRef;
|
|
69
|
+
|
|
70
|
+
// Capture the element's original scale
|
|
71
|
+
const scale = ref().scale();
|
|
72
|
+
|
|
73
|
+
let animationInterval = Math.min(interval, duration);
|
|
74
|
+
if (animate === "enter") {
|
|
75
|
+
// Start fully transparent and scaled down to 50%
|
|
76
|
+
ref().opacity(0);
|
|
77
|
+
ref().scale(new Vector2(scale.x / 2, scale.y / 2));
|
|
78
|
+
// Animate scaling up to original size and fading in
|
|
79
|
+
yield* all(
|
|
80
|
+
ref().scale(scale, animationInterval),
|
|
81
|
+
ref().opacity(1, animationInterval / 2)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
} else if (animate === "exit") {
|
|
85
|
+
// Wait until exit animation should start
|
|
86
|
+
yield* waitFor(duration - animationInterval);
|
|
87
|
+
// Animate scaling down to 50% and fading out (opacity starts after half the interval)
|
|
88
|
+
yield* all(
|
|
89
|
+
ref().scale(new Vector2(scale.x / 2, scale.y / 2), animationInterval),
|
|
90
|
+
delay(animationInterval / 2, ref().opacity(0, animationInterval / 2))
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
} else if (animate === "both") {
|
|
94
|
+
animationInterval = Math.min(interval, duration/2);
|
|
95
|
+
// Start fully transparent and scaled down to 50%
|
|
96
|
+
ref().opacity(0);
|
|
97
|
+
ref().scale(new Vector2(scale.x / 2, scale.y / 2));
|
|
98
|
+
// Animate scaling up and fading in
|
|
99
|
+
yield* all(
|
|
100
|
+
ref().scale(scale, animationInterval),
|
|
101
|
+
ref().opacity(1, animationInterval / 2)
|
|
102
|
+
);
|
|
103
|
+
// Wait for the remaining duration
|
|
104
|
+
yield* waitFor(duration - animationInterval);
|
|
105
|
+
// Animate scaling down and fading out
|
|
106
|
+
yield* all(
|
|
107
|
+
ref().scale(new Vector2(scale.x / 2, scale.y / 2), animationInterval),
|
|
108
|
+
delay(animationInterval / 2, ref().opacity(0, animationInterval / 2))
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
};
|