@twick/visualizer 0.14.0 → 0.14.2
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 +12 -12
- package/package.json +13 -13
- package/package.json.bak +34 -0
- package/src/animations/blur.tsx +60 -60
- package/src/animations/breathe.tsx +60 -60
- package/src/animations/fade.tsx +60 -60
- package/src/animations/photo-rise.tsx +66 -66
- package/src/animations/photo-zoom.tsx +73 -73
- package/src/animations/rise.tsx +118 -118
- package/src/animations/succession.tsx +77 -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 +17 -17
- package/src/elements/caption.element.tsx +87 -87
- package/src/elements/circle.element.tsx +20 -20
- package/src/elements/icon.element.tsx +20 -20
- package/src/elements/image.element.tsx +53 -55
- package/src/elements/rect.element.tsx +22 -22
- package/src/elements/scene.element.tsx +29 -29
- package/src/elements/text.element.tsx +27 -27
- package/src/elements/video.element.tsx +55 -56
- package/src/frame-effects/circle.frame.tsx +103 -103
- package/src/frame-effects/rect.frame.tsx +103 -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 +239 -239
- package/src/helpers/event.utils.ts +6 -0
- package/src/helpers/filters.ts +127 -127
- package/src/helpers/log.utils.ts +29 -29
- package/src/helpers/timing.utils.ts +109 -109
- package/src/helpers/types.ts +242 -241
- package/src/helpers/utils.ts +19 -19
- package/src/index.ts +6 -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 +39 -39
- package/src/text-effects/erase.tsx +58 -58
- package/src/text-effects/stream-word.tsx +60 -60
- package/src/text-effects/typewriter.tsx +59 -59
- package/src/visualizer.tsx +98 -78
- package/tsconfig.json +11 -11
- package/typedoc.json +14 -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
|
@@ -1,239 +1,239 @@
|
|
|
1
|
-
import { all, Reference, waitFor } from "@twick/core";
|
|
2
|
-
import { FrameState, ObjectFit, SizeVector, VisualizerElement } from "./types";
|
|
3
|
-
import { OBJECT_FIT } from "./constants";
|
|
4
|
-
import textEffectController from "../controllers/text-effect.controller";
|
|
5
|
-
import animationController from "../controllers/animation.controller";
|
|
6
|
-
import { View2D } from "@twick/2d";
|
|
7
|
-
import frameEffectController from "../controllers/frame-effect.controller";
|
|
8
|
-
import { logger } from "./log.utils";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Element utilities for the visualizer package.
|
|
12
|
-
* Provides functions for handling element positioning, sizing, and transformations.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fits an element within specified bounds while maintaining aspect ratio
|
|
17
|
-
* @param {Object} params - Parameters for fitting the element
|
|
18
|
-
* @param {Object} params.containerSize - The container size
|
|
19
|
-
* @param {Object} params.elementSize - The element size
|
|
20
|
-
* @param {Object} params.elementRef - The element reference
|
|
21
|
-
* @param {string} [params.objectFit] - The fit mode (contain, cover, fill)
|
|
22
|
-
* @returns {Object} Updated element dimensions
|
|
23
|
-
*/
|
|
24
|
-
export function* fitElement({
|
|
25
|
-
containerSize,
|
|
26
|
-
elementSize,
|
|
27
|
-
elementRef,
|
|
28
|
-
objectFit,
|
|
29
|
-
}: {
|
|
30
|
-
containerSize: SizeVector;
|
|
31
|
-
elementSize: SizeVector;
|
|
32
|
-
elementRef: Reference<any>;
|
|
33
|
-
objectFit?: ObjectFit;
|
|
34
|
-
}) {
|
|
35
|
-
const containerAspectRatio = containerSize.x / containerSize.y;
|
|
36
|
-
const elementAspectRatio = elementSize.x / elementSize.y;
|
|
37
|
-
switch (objectFit) {
|
|
38
|
-
case OBJECT_FIT.CONTAIN:
|
|
39
|
-
if (elementAspectRatio > containerAspectRatio) {
|
|
40
|
-
yield elementRef().size({
|
|
41
|
-
x: containerSize.x,
|
|
42
|
-
y: containerSize.x / elementAspectRatio,
|
|
43
|
-
});
|
|
44
|
-
yield elementRef().scale(
|
|
45
|
-
containerSize.x / elementSize.x,
|
|
46
|
-
(containerSize.x * elementAspectRatio) / elementSize.y
|
|
47
|
-
);
|
|
48
|
-
} else {
|
|
49
|
-
yield elementRef().size({
|
|
50
|
-
x: containerSize.y * elementAspectRatio,
|
|
51
|
-
y: containerSize.y,
|
|
52
|
-
});
|
|
53
|
-
yield elementRef().scale(
|
|
54
|
-
(containerSize.y * elementAspectRatio) / elementSize.x,
|
|
55
|
-
containerSize.y / elementSize.y
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case OBJECT_FIT.COVER:
|
|
60
|
-
if (elementAspectRatio > containerAspectRatio) {
|
|
61
|
-
yield elementRef().size({
|
|
62
|
-
x: containerSize.y * elementAspectRatio,
|
|
63
|
-
y: containerSize.y,
|
|
64
|
-
});
|
|
65
|
-
yield elementRef().scale(
|
|
66
|
-
(containerSize.y * elementAspectRatio) / elementSize.x,
|
|
67
|
-
containerSize.y / elementSize.y
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
yield elementRef().size({
|
|
71
|
-
x: containerSize.x,
|
|
72
|
-
y: containerSize.x / elementAspectRatio,
|
|
73
|
-
});
|
|
74
|
-
yield elementRef().scale(
|
|
75
|
-
containerSize.x / elementSize.x,
|
|
76
|
-
(containerSize.x * elementAspectRatio) / elementSize.y
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
case OBJECT_FIT.FILL:
|
|
81
|
-
yield elementRef().size(containerSize);
|
|
82
|
-
yield elementRef().scale(
|
|
83
|
-
containerSize.x / elementSize.x,
|
|
84
|
-
containerSize.x / elementSize.y
|
|
85
|
-
);
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function* addTextEffect({
|
|
93
|
-
elementRef,
|
|
94
|
-
element,
|
|
95
|
-
}: {
|
|
96
|
-
elementRef: Reference<any>;
|
|
97
|
-
element: VisualizerElement;
|
|
98
|
-
}) {
|
|
99
|
-
yield elementRef();
|
|
100
|
-
if (element.textEffect) {
|
|
101
|
-
const effect = textEffectController.get(element.textEffect.name);
|
|
102
|
-
if (effect) {
|
|
103
|
-
yield* effect.run({
|
|
104
|
-
elementRef,
|
|
105
|
-
duration: element.e - element.s,
|
|
106
|
-
...element.textEffect,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function* addAnimation({
|
|
113
|
-
elementRef,
|
|
114
|
-
containerRef,
|
|
115
|
-
element,
|
|
116
|
-
view,
|
|
117
|
-
}: {
|
|
118
|
-
elementRef: Reference<any>;
|
|
119
|
-
containerRef?: Reference<any>;
|
|
120
|
-
element: VisualizerElement;
|
|
121
|
-
view: View2D;
|
|
122
|
-
}) {
|
|
123
|
-
yield elementRef();
|
|
124
|
-
if (element.animation) {
|
|
125
|
-
const animation = animationController.get(element.animation.name);
|
|
126
|
-
if (animation) {
|
|
127
|
-
yield* animation.run({
|
|
128
|
-
elementRef,
|
|
129
|
-
containerRef,
|
|
130
|
-
view,
|
|
131
|
-
duration: element.e - element.s,
|
|
132
|
-
...element.animation,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
export function* addFrameEffect({
|
|
140
|
-
containerRef,
|
|
141
|
-
elementRef,
|
|
142
|
-
element,
|
|
143
|
-
}: {
|
|
144
|
-
containerRef: Reference<any>;
|
|
145
|
-
elementRef: Reference<any>;
|
|
146
|
-
element: VisualizerElement;
|
|
147
|
-
}) {
|
|
148
|
-
let frameEffects = [];
|
|
149
|
-
const initProps = getFrameState({
|
|
150
|
-
containerRef,
|
|
151
|
-
elementRef,
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
for (let i = 0; i < element?.frameEffects?.length; i++) {
|
|
155
|
-
const frameEffect = element.frameEffects[i];
|
|
156
|
-
const restore =
|
|
157
|
-
i === element.frameEffects.length - 1 ||
|
|
158
|
-
element.frameEffects[i + 1].s !== frameEffect.e;
|
|
159
|
-
const frameEffectPlugin = frameEffectController.get(frameEffect.name);
|
|
160
|
-
if (frameEffectPlugin) {
|
|
161
|
-
yield* frameEffectPlugin.run({
|
|
162
|
-
containerRef,
|
|
163
|
-
elementRef,
|
|
164
|
-
initFrameState: initProps,
|
|
165
|
-
frameEffect,
|
|
166
|
-
});
|
|
167
|
-
if (restore) {
|
|
168
|
-
yield* restoreFrameState({
|
|
169
|
-
containerRef,
|
|
170
|
-
elementRef,
|
|
171
|
-
duration: frameEffect.e - frameEffect.s,
|
|
172
|
-
element,
|
|
173
|
-
initProps,
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
// frameEffects.push(...sequence);
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
// yield* all(...frameEffects);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function getFrameState({
|
|
184
|
-
containerRef,
|
|
185
|
-
elementRef,
|
|
186
|
-
}: {
|
|
187
|
-
containerRef: Reference<any>;
|
|
188
|
-
elementRef: Reference<any>;
|
|
189
|
-
}): FrameState {
|
|
190
|
-
return {
|
|
191
|
-
frame: {
|
|
192
|
-
size: containerRef().size(),
|
|
193
|
-
pos: containerRef().position(),
|
|
194
|
-
radius: containerRef().radius(),
|
|
195
|
-
scale: containerRef().scale(),
|
|
196
|
-
rotation: containerRef().rotation(),
|
|
197
|
-
},
|
|
198
|
-
element: {
|
|
199
|
-
size: containerRef().size(),
|
|
200
|
-
pos: elementRef().position(),
|
|
201
|
-
scale: elementRef().scale(),
|
|
202
|
-
},
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export function* restoreFrameState({
|
|
207
|
-
containerRef,
|
|
208
|
-
elementRef,
|
|
209
|
-
duration,
|
|
210
|
-
element,
|
|
211
|
-
initProps,
|
|
212
|
-
}: {
|
|
213
|
-
containerRef: Reference<any>;
|
|
214
|
-
elementRef: Reference<any>;
|
|
215
|
-
duration: number;
|
|
216
|
-
element: VisualizerElement;
|
|
217
|
-
initProps: FrameState;
|
|
218
|
-
}) {
|
|
219
|
-
yield* waitFor(duration);
|
|
220
|
-
logger(`restoreFrameState: ${JSON.stringify(initProps)}`);
|
|
221
|
-
let sequence = [];
|
|
222
|
-
sequence.push(containerRef().size(initProps.frame.size));
|
|
223
|
-
sequence.push(containerRef().position(initProps.frame.pos));
|
|
224
|
-
sequence.push(containerRef().scale(initProps.frame.scale));
|
|
225
|
-
sequence.push(containerRef().rotation(initProps.frame.rotation));
|
|
226
|
-
sequence.push(containerRef().radius(initProps.frame.radius));
|
|
227
|
-
sequence.push(elementRef().size(initProps.element.size));
|
|
228
|
-
sequence.push(elementRef().position(initProps.element.pos));
|
|
229
|
-
sequence.push(elementRef().scale(initProps.element.scale));
|
|
230
|
-
sequence.push(
|
|
231
|
-
fitElement({
|
|
232
|
-
elementRef,
|
|
233
|
-
containerSize: initProps.frame.size,
|
|
234
|
-
elementSize: initProps.element.size,
|
|
235
|
-
objectFit: element.objectFit ?? "none",
|
|
236
|
-
})
|
|
237
|
-
);
|
|
238
|
-
yield* all(...sequence);
|
|
239
|
-
}
|
|
1
|
+
import { all, Reference, waitFor } from "@twick/core";
|
|
2
|
+
import { FrameState, ObjectFit, SizeVector, VisualizerElement } from "./types";
|
|
3
|
+
import { OBJECT_FIT } from "./constants";
|
|
4
|
+
import textEffectController from "../controllers/text-effect.controller";
|
|
5
|
+
import animationController from "../controllers/animation.controller";
|
|
6
|
+
import { View2D } from "@twick/2d";
|
|
7
|
+
import frameEffectController from "../controllers/frame-effect.controller";
|
|
8
|
+
import { logger } from "./log.utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Element utilities for the visualizer package.
|
|
12
|
+
* Provides functions for handling element positioning, sizing, and transformations.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Fits an element within specified bounds while maintaining aspect ratio
|
|
17
|
+
* @param {Object} params - Parameters for fitting the element
|
|
18
|
+
* @param {Object} params.containerSize - The container size
|
|
19
|
+
* @param {Object} params.elementSize - The element size
|
|
20
|
+
* @param {Object} params.elementRef - The element reference
|
|
21
|
+
* @param {string} [params.objectFit] - The fit mode (contain, cover, fill)
|
|
22
|
+
* @returns {Object} Updated element dimensions
|
|
23
|
+
*/
|
|
24
|
+
export function* fitElement({
|
|
25
|
+
containerSize,
|
|
26
|
+
elementSize,
|
|
27
|
+
elementRef,
|
|
28
|
+
objectFit,
|
|
29
|
+
}: {
|
|
30
|
+
containerSize: SizeVector;
|
|
31
|
+
elementSize: SizeVector;
|
|
32
|
+
elementRef: Reference<any>;
|
|
33
|
+
objectFit?: ObjectFit;
|
|
34
|
+
}) {
|
|
35
|
+
const containerAspectRatio = containerSize.x / containerSize.y;
|
|
36
|
+
const elementAspectRatio = elementSize.x / elementSize.y;
|
|
37
|
+
switch (objectFit) {
|
|
38
|
+
case OBJECT_FIT.CONTAIN:
|
|
39
|
+
if (elementAspectRatio > containerAspectRatio) {
|
|
40
|
+
yield elementRef().size({
|
|
41
|
+
x: containerSize.x,
|
|
42
|
+
y: containerSize.x / elementAspectRatio,
|
|
43
|
+
});
|
|
44
|
+
yield elementRef().scale(
|
|
45
|
+
containerSize.x / elementSize.x,
|
|
46
|
+
(containerSize.x * elementAspectRatio) / elementSize.y
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
yield elementRef().size({
|
|
50
|
+
x: containerSize.y * elementAspectRatio,
|
|
51
|
+
y: containerSize.y,
|
|
52
|
+
});
|
|
53
|
+
yield elementRef().scale(
|
|
54
|
+
(containerSize.y * elementAspectRatio) / elementSize.x,
|
|
55
|
+
containerSize.y / elementSize.y
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case OBJECT_FIT.COVER:
|
|
60
|
+
if (elementAspectRatio > containerAspectRatio) {
|
|
61
|
+
yield elementRef().size({
|
|
62
|
+
x: containerSize.y * elementAspectRatio,
|
|
63
|
+
y: containerSize.y,
|
|
64
|
+
});
|
|
65
|
+
yield elementRef().scale(
|
|
66
|
+
(containerSize.y * elementAspectRatio) / elementSize.x,
|
|
67
|
+
containerSize.y / elementSize.y
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
yield elementRef().size({
|
|
71
|
+
x: containerSize.x,
|
|
72
|
+
y: containerSize.x / elementAspectRatio,
|
|
73
|
+
});
|
|
74
|
+
yield elementRef().scale(
|
|
75
|
+
containerSize.x / elementSize.x,
|
|
76
|
+
(containerSize.x * elementAspectRatio) / elementSize.y
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case OBJECT_FIT.FILL:
|
|
81
|
+
yield elementRef().size(containerSize);
|
|
82
|
+
yield elementRef().scale(
|
|
83
|
+
containerSize.x / elementSize.x,
|
|
84
|
+
containerSize.x / elementSize.y
|
|
85
|
+
);
|
|
86
|
+
break;
|
|
87
|
+
default:
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function* addTextEffect({
|
|
93
|
+
elementRef,
|
|
94
|
+
element,
|
|
95
|
+
}: {
|
|
96
|
+
elementRef: Reference<any>;
|
|
97
|
+
element: VisualizerElement;
|
|
98
|
+
}) {
|
|
99
|
+
yield elementRef();
|
|
100
|
+
if (element.textEffect) {
|
|
101
|
+
const effect = textEffectController.get(element.textEffect.name);
|
|
102
|
+
if (effect) {
|
|
103
|
+
yield* effect.run({
|
|
104
|
+
elementRef,
|
|
105
|
+
duration: element.e - element.s,
|
|
106
|
+
...element.textEffect,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function* addAnimation({
|
|
113
|
+
elementRef,
|
|
114
|
+
containerRef,
|
|
115
|
+
element,
|
|
116
|
+
view,
|
|
117
|
+
}: {
|
|
118
|
+
elementRef: Reference<any>;
|
|
119
|
+
containerRef?: Reference<any>;
|
|
120
|
+
element: VisualizerElement;
|
|
121
|
+
view: View2D;
|
|
122
|
+
}) {
|
|
123
|
+
yield elementRef();
|
|
124
|
+
if (element.animation) {
|
|
125
|
+
const animation = animationController.get(element.animation.name);
|
|
126
|
+
if (animation) {
|
|
127
|
+
yield* animation.run({
|
|
128
|
+
elementRef,
|
|
129
|
+
containerRef,
|
|
130
|
+
view,
|
|
131
|
+
duration: element.e - element.s,
|
|
132
|
+
...element.animation,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
export function* addFrameEffect({
|
|
140
|
+
containerRef,
|
|
141
|
+
elementRef,
|
|
142
|
+
element,
|
|
143
|
+
}: {
|
|
144
|
+
containerRef: Reference<any>;
|
|
145
|
+
elementRef: Reference<any>;
|
|
146
|
+
element: VisualizerElement;
|
|
147
|
+
}) {
|
|
148
|
+
let frameEffects = [];
|
|
149
|
+
const initProps = getFrameState({
|
|
150
|
+
containerRef,
|
|
151
|
+
elementRef,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
for (let i = 0; i < element?.frameEffects?.length; i++) {
|
|
155
|
+
const frameEffect = element.frameEffects[i];
|
|
156
|
+
const restore =
|
|
157
|
+
i === element.frameEffects.length - 1 ||
|
|
158
|
+
element.frameEffects[i + 1].s !== frameEffect.e;
|
|
159
|
+
const frameEffectPlugin = frameEffectController.get(frameEffect.name);
|
|
160
|
+
if (frameEffectPlugin) {
|
|
161
|
+
yield* frameEffectPlugin.run({
|
|
162
|
+
containerRef,
|
|
163
|
+
elementRef,
|
|
164
|
+
initFrameState: initProps,
|
|
165
|
+
frameEffect,
|
|
166
|
+
});
|
|
167
|
+
if (restore) {
|
|
168
|
+
yield* restoreFrameState({
|
|
169
|
+
containerRef,
|
|
170
|
+
elementRef,
|
|
171
|
+
duration: frameEffect.e - frameEffect.s,
|
|
172
|
+
element,
|
|
173
|
+
initProps,
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
// frameEffects.push(...sequence);
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// yield* all(...frameEffects);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function getFrameState({
|
|
184
|
+
containerRef,
|
|
185
|
+
elementRef,
|
|
186
|
+
}: {
|
|
187
|
+
containerRef: Reference<any>;
|
|
188
|
+
elementRef: Reference<any>;
|
|
189
|
+
}): FrameState {
|
|
190
|
+
return {
|
|
191
|
+
frame: {
|
|
192
|
+
size: containerRef().size(),
|
|
193
|
+
pos: containerRef().position(),
|
|
194
|
+
radius: containerRef().radius(),
|
|
195
|
+
scale: containerRef().scale(),
|
|
196
|
+
rotation: containerRef().rotation(),
|
|
197
|
+
},
|
|
198
|
+
element: {
|
|
199
|
+
size: containerRef().size(),
|
|
200
|
+
pos: elementRef().position(),
|
|
201
|
+
scale: elementRef().scale(),
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function* restoreFrameState({
|
|
207
|
+
containerRef,
|
|
208
|
+
elementRef,
|
|
209
|
+
duration,
|
|
210
|
+
element,
|
|
211
|
+
initProps,
|
|
212
|
+
}: {
|
|
213
|
+
containerRef: Reference<any>;
|
|
214
|
+
elementRef: Reference<any>;
|
|
215
|
+
duration: number;
|
|
216
|
+
element: VisualizerElement;
|
|
217
|
+
initProps: FrameState;
|
|
218
|
+
}) {
|
|
219
|
+
yield* waitFor(duration);
|
|
220
|
+
logger(`restoreFrameState: ${JSON.stringify(initProps)}`);
|
|
221
|
+
let sequence = [];
|
|
222
|
+
sequence.push(containerRef().size(initProps.frame.size));
|
|
223
|
+
sequence.push(containerRef().position(initProps.frame.pos));
|
|
224
|
+
sequence.push(containerRef().scale(initProps.frame.scale));
|
|
225
|
+
sequence.push(containerRef().rotation(initProps.frame.rotation));
|
|
226
|
+
sequence.push(containerRef().radius(initProps.frame.radius));
|
|
227
|
+
sequence.push(elementRef().size(initProps.element.size));
|
|
228
|
+
sequence.push(elementRef().position(initProps.element.pos));
|
|
229
|
+
sequence.push(elementRef().scale(initProps.element.scale));
|
|
230
|
+
sequence.push(
|
|
231
|
+
fitElement({
|
|
232
|
+
elementRef,
|
|
233
|
+
containerSize: initProps.frame.size,
|
|
234
|
+
elementSize: initProps.element.size,
|
|
235
|
+
objectFit: element.objectFit ?? "none",
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
yield* all(...sequence);
|
|
239
|
+
}
|