@@ -76,6 +76,7 @@ const FlippableCard = ({ frontContent, backContent }: FlippableCardProps) => {
7676 const [ isFlipped , setIsFlipped ] = useState ( false )
7777 const [ isHovered , setIsHovered ] = useState ( false )
7878 const [ isMerged , setIsMerged ] = useState ( true )
79+ const [ initialFlipComplete , setInitialFlipComplete ] = useState ( false )
7980
8081 const ref = useRef < HTMLDivElement > ( null )
8182 const anchorRef = useRef < HTMLDivElement > ( null )
@@ -88,6 +89,9 @@ const FlippableCard = ({ frontContent, backContent }: FlippableCardProps) => {
8889
8990 const controls = useAnimation ( )
9091
92+ const INITIAL_FLIP_DELAY_MS = 3000
93+ const JIGGLE_ANIMATION_DELAY_MS = 750
94+
9195 const zoom = useSpring ( 1 , {
9296 duration : 0.1 ,
9397 damping : 7 ,
@@ -99,10 +103,26 @@ const FlippableCard = ({ frontContent, backContent }: FlippableCardProps) => {
99103 } , [ rotateX , rotateY ] )
100104
101105 useEffect ( ( ) => {
102- // Start the jiggle animation when not hovered
103- setTimeout ( ( ) => controls . start ( jiggleAnimation ) , 750 )
106+ // Flip the card on initial load
107+ setIsFlipped ( true )
108+
109+ const timer = setTimeout ( ( ) => {
110+ setIsFlipped ( false )
111+ setInitialFlipComplete ( true )
112+ } , INITIAL_FLIP_DELAY_MS )
113+
114+ return ( ) => clearTimeout ( timer )
104115 } , [ ] )
105116
117+ useEffect ( ( ) => {
118+ if ( ! initialFlipComplete ) return
119+
120+ // Start the jiggle animation when not hovered
121+ const timer = setTimeout ( ( ) => controls . start ( jiggleAnimation ) , JIGGLE_ANIMATION_DELAY_MS )
122+
123+ return ( ) => clearTimeout ( timer )
124+ } , [ initialFlipComplete , controls ] )
125+
106126 const handleMouseMove = ( event : React . MouseEvent < HTMLDivElement > ) => {
107127 const element = ref . current
108128
0 commit comments