-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathKeyframedPropsTest.tsx
More file actions
183 lines (175 loc) · 3.52 KB
/
KeyframedPropsTest.tsx
File metadata and controls
183 lines (175 loc) · 3.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
import {blur} from '@remotion/effects/blur';
import {scale} from '@remotion/effects/scale';
import React from 'react';
import {
AbsoluteFill,
AnimatedImage,
interpolate,
interpolateColors,
Sequence,
Solid,
staticFile,
useCurrentFrame,
} from 'remotion';
const Shifted = () => {
const frame = useCurrentFrame();
return (
<Sequence style={{scale: interpolate(frame, [0, 60], [2, 4])}}>
<div
style={{
width: 180,
height: 180,
borderRadius: 24,
backgroundColor: '#0b84f3',
}}
/>
</Sequence>
);
};
const NestedShifted = () => {
return (
<Sequence from={20}>
<Shifted />
</Sequence>
);
};
const NestedOwnFrom = () => {
const frame = useCurrentFrame();
return (
<Sequence
from={20}
name="nested own from keyframes should be shown at 30 and 70"
style={{scale: interpolate(frame, [0, 40], [2, 4])}}
>
<div
style={{
width: 180,
height: 180,
borderRadius: 24,
backgroundColor: '#0b84f3',
}}
/>
</Sequence>
);
};
const ShiftedEffect = () => {
const frame = useCurrentFrame();
return (
<AnimatedImage
src={staticFile('giphy.gif')}
fit="contain"
style={{
width: 360,
height: 200,
borderRadius: 24,
overflow: 'hidden',
}}
effects={[
blur({
radius: interpolate(frame, [0, 60], [0, 24]),
}),
]}
/>
);
};
const NestedShiftedEffect = () => {
return (
<Sequence from={20}>
<ShiftedEffect />
</Sequence>
);
};
const KeyframedPropsTest: React.FC = () => {
const frame = useCurrentFrame();
return (
<AbsoluteFill
style={{
justifyContent: 'space-evenly',
alignItems: 'center',
backgroundColor: 'white',
}}
>
<Sequence
name="keyframes should be shown at 0 and 100"
durationInFrames={120}
style={{scale: interpolate(frame, [0, 100], [2, 4])}}
>
<div
style={{
width: 180,
height: 180,
borderRadius: 24,
backgroundColor: '#0b84f3',
}}
/>
</Sequence>
<Sequence from={30} name="keyframes should be shown at 30 and 90">
<Shifted />
</Sequence>
<Sequence from={30} name="nested keyframes should be shown at 50 and 110">
<NestedShifted />
</Sequence>
<Sequence from={30}>
<NestedOwnFrom />
</Sequence>
<Sequence from={30} name="effect keyframes should be shown at 30 and 90">
<ShiftedEffect />
</Sequence>
<Sequence
name="color keyframes should be shown at 0 and 100"
durationInFrames={120}
>
<Solid
width={180}
height={180}
color={interpolateColors(frame, [0, 100], ['#0b84f3', '#f43b00'])}
style={{
borderRadius: 24,
}}
/>
</Sequence>
<Sequence
from={30}
name="nested effect keyframes should be shown at 50 and 110"
>
<NestedShiftedEffect />
</Sequence>
<Sequence
name="keyframes should be shown at 0 and 100 because relative to parent"
durationInFrames={120}
from={30}
style={{scale: interpolate(frame, [0, 100], [2, 4])}}
>
<div
style={{
width: 180,
height: 180,
borderRadius: 24,
backgroundColor: '#0b84f3',
}}
/>
</Sequence>
<Sequence durationInFrames={120}>
<AnimatedImage
src={staticFile('giphy.gif')}
fit="contain"
style={{
width: 360,
height: 200,
borderRadius: 24,
overflow: 'hidden',
}}
effects={[
blur({
radius: interpolate(frame, [0, 60, 119], [0, 24, 4]),
}),
scale({
scale: 2.2,
}),
]}
/>
</Sequence>
</AbsoluteFill>
);
};
export default KeyframedPropsTest;