Use of framer motion to move poker card into pile #60
-
Hi! I wanted to create a poker game using framer motion as well. I looked through your code but still confused on how you used framer motion to move the poker card from hand to pile. Can you provide any insight on how you approached that problem? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, appreciate your interest! It's been quite a while since I've last wrote code for this project. But I remember it being quite simple. I took a look at the Card component and think I found it: zhithead/src/components/ui/Card.tsx Line 36 in 7c78668 The prop layoutId on a motion component enables this feature. Let me know if that answers your question. Good luck on your poker game! |
Beta Was this translation helpful? Give feedback.
Hi, appreciate your interest! It's been quite a while since I've last wrote code for this project. But I remember it being quite simple. I took a look at the Card component and think I found it:
zhithead/src/components/ui/Card.tsx
Line 36 in 7c78668
The prop layoutId on a motion component enables this feature.
When you play a card it is removed from the Hand component, re-rendered without that card and rendered instead in the Pile component.
I don't know the technical details on how Framer Motion transitions the element. But I do know that using that prop animates out the old component and transitions it to the new component's place.
Let…