File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ import clsx from 'clsx' ;
2
+ import type { Variants } from 'motion/react' ;
3
+ import { AnimatePresence , motion } from 'motion/react' ;
4
+
5
+ interface FlipTextProps {
6
+ readonly className ?: string ;
7
+ readonly delayMultiple ?: number ;
8
+ readonly duration ?: number ;
9
+ readonly framerProps ?: Variants ;
10
+ readonly word : string ;
11
+ }
12
+
13
+ const FlipText : FC < FlipTextProps > = memo (
14
+ ( {
15
+ className,
16
+ delayMultiple = 0.08 ,
17
+ duration = 0.5 ,
18
+ framerProps = {
19
+ hidden : { opacity : 0 , rotateX : - 90 } ,
20
+ visible : { opacity : 1 , rotateX : 0 }
21
+ } ,
22
+ word
23
+ } ) => {
24
+ return (
25
+ < AnimatePresence mode = "sync" >
26
+ { word . split ( '' ) . map ( ( char , i ) => (
27
+ < motion . span
28
+ animate = "visible"
29
+ className = { clsx ( ' drop-shadow-sm' , className ) }
30
+ initial = "hidden"
31
+ key = { i }
32
+ transition = { { delay : i * delayMultiple , duration } }
33
+ variants = { framerProps }
34
+ >
35
+ { char }
36
+ </ motion . span >
37
+ ) ) }
38
+ </ AnimatePresence >
39
+ ) ;
40
+ }
41
+ ) ;
42
+
43
+ export default FlipText ;
You can’t perform that action at this time.
0 commit comments