-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9233f00
commit 46588ac
Showing
6 changed files
with
189 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react' | ||
import { motion } from 'framer-motion' | ||
|
||
const AnimatedTextCharacter = ({ text }: { text: string }) => { | ||
// splitting text into letters | ||
const letters = Array.from(text) | ||
|
||
// Variants for Container | ||
const container = { | ||
hidden: { opacity: 0 }, | ||
visible: (i = 1) => ({ | ||
opacity: 1, | ||
transition: { staggerChildren: 0.01, delayChildren: 0.01 * i }, | ||
}), | ||
} | ||
|
||
// Variants for each letter | ||
const child = { | ||
visible: { | ||
opacity: 1, | ||
x: 0, | ||
y: 0, | ||
transition: { | ||
type: 'spring', | ||
damping: 12, | ||
stiffness: 100, | ||
}, | ||
}, | ||
hidden: { | ||
opacity: 0, | ||
x: 0, | ||
y: 10, | ||
transition: { | ||
type: 'spring', | ||
damping: 12, | ||
stiffness: 100, | ||
}, | ||
}, | ||
} | ||
|
||
return ( | ||
<motion.div | ||
style={{ overflow: 'hidden', display: 'flex', fontSize: '1rem' }} | ||
variants={container} | ||
initial="hidden" | ||
animate="visible"> | ||
<b> | ||
{letters.map((letter, index) => ( | ||
<motion.span variants={child} key={index}> | ||
{letter === ' ' ? '\u00A0' : letter} | ||
</motion.span> | ||
))} | ||
</b> | ||
</motion.div> | ||
) | ||
} | ||
|
||
export default AnimatedTextCharacter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.