opacity effect
This commit is contained in:
@@ -28,12 +28,23 @@ const VerticalText: React.FC<Props> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const current = useCurrentFrame();
|
const current = useCurrentFrame();
|
||||||
const textArray = Array.from(text);
|
const textArray = Array.from(text);
|
||||||
const currentEndIndex = ~~(
|
const currentEndIndex = interpolate(
|
||||||
(textArray.length * (current - from)) /
|
current,
|
||||||
(to - from)
|
[from, to],
|
||||||
|
[0, textArray.length]
|
||||||
|
);
|
||||||
|
const r = random(current - (current % 3));
|
||||||
|
const duration = to - from;
|
||||||
|
const opacities = textArray.map((_, i) =>
|
||||||
|
interpolate(
|
||||||
|
current,
|
||||||
|
[
|
||||||
|
from + (i * duration) / textArray.length,
|
||||||
|
from + ((i + 1) * duration) / textArray.length,
|
||||||
|
],
|
||||||
|
[0, 1]
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const r = random(current - (current % 2));
|
|
||||||
const opacity = interpolate(current, [from, from + 8], [0, 1]);
|
|
||||||
return (
|
return (
|
||||||
<AbsoluteFill>
|
<AbsoluteFill>
|
||||||
<Sequence
|
<Sequence
|
||||||
@@ -41,21 +52,38 @@ const VerticalText: React.FC<Props> = ({
|
|||||||
from={from}
|
from={from}
|
||||||
durationInFrames={disappear ? disappear - from : 4096}
|
durationInFrames={disappear ? disappear - from : 4096}
|
||||||
style={{
|
style={{
|
||||||
opacity,
|
|
||||||
top: `${1080 - y}px`,
|
top: `${1080 - y}px`,
|
||||||
left: x,
|
left: x,
|
||||||
letterSpacing: '0.2em',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
width: 'min-content',
|
width: 'min-content',
|
||||||
fontSize: `${fontSize}px`,
|
height: 'min-content',
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
writingMode: 'vertical-lr',
|
writingMode: 'vertical-lr',
|
||||||
|
fontSize: `${fontSize}px`,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{textArray.slice(0, currentEndIndex).join('')}
|
{textArray.slice(0, currentEndIndex).map((char, index) => (
|
||||||
{currentEndIndex < text.length && textArray[~~(r * textArray.length)]}
|
<div
|
||||||
|
style={{
|
||||||
|
width: 'min-content',
|
||||||
|
height: 'min-content',
|
||||||
|
letterSpacing: '0.2em',
|
||||||
|
margin: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{char}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{currentEndIndex < textArray.length && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
opacity: opacities[~~currentEndIndex],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{textArray[~~(r * textArray.length)]}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Sequence>
|
</Sequence>
|
||||||
</AbsoluteFill>
|
</AbsoluteFill>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user