blob: 0584b5aa8002a04a9391717f8d657d860f76aa74 (
plain)
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
|
import { motion, useInView } from 'framer-motion';
import * as React from 'react';
export function LettersPullUp({ text }: { text: string }) {
const splittedText = text.split('');
const pullupVariant = {
initial: { y: 10, opacity: 0 },
animate: (i: number) => ({
y: 0,
opacity: 1,
transition: {
delay: i * 0.05,
},
}),
};
const ref = React.useRef(null);
const isInView = useInView(ref, { once: true });
return (
<div>
{splittedText.map((current, i) => (
<motion.div
key={i}
ref={ref}
variants={pullupVariant}
initial="initial"
animate={isInView ? 'animate' : ''}
custom={i}
style={{ display: 'inline-block' }}
>
{current == ' ' ? <span> </span> : current}
</motion.div>
))}
</div>
);
}
|