CABasicAnimation Card Fixes
Tinder Firestore Swipe and Match
Now that we have the bottom controls implemented, let's also fix the animations with our cards while we tap on the like and dislike buttons. The fix in today's lesson will include code that uses CABasicAnimation to setup our views correctly in our application. Enjoy.

Comments (9)
Dennisvm82
4 years ago
Nice to see something like CABasicAnimation. Very well explained, and very interesting to work with. There is so much stuff out there hidden somewhere in the huge amount of available classes and objects, that you often forget or just don't know where to begin and what to use in certain situations.
slcott
4 years ago
I used a `CAAnimationGroup`. It allows me to set stuff like duration in one place. my code: ``` let groupAnimation: CAAnimationGroup = { let groupAnim = CAAnimationGroup() groupAnim.duration = 0.3 ``` ... ``` groupAnim.animations = [rotAnim, posnAnim, opacityAnim] return groupAnim }() ```
Brian Voong
4 years ago
flashtrend
4 years ago
Hi Brain, hope all is well. Can you show us how to slide between pages like how the actual Tinder app does?
Brian Voong
4 years ago
st4n
4 years ago
great stuff!
Anas Belkhadir
4 years ago
Hi Brain , i hope you do well . after playing with the code i have notice when i fetch more data, even i remove the card view and the user, the memory increase badly going to 500 MB , how i can fix such a problem ? .
Anas Belkhadir
4 years ago
I have fixed the problem, it's was coming from the image i was doing graphique optimisation over the image and it's was leading to memory problem.
romulusc
4 years ago
Hi guys. Very nice animation with CABasicAnim, butter smooth. My question here is do I allow this to happen in the app if it was a real app? the user to tap away maybe without looking at the cards? maybe increasing data fetches and rising firestore costs? Prior to this lesson I've implemented a temporary disable of "like button" only for the 1s duration of animation and I showed that to the user by fading the alpha of the button. Is this a acceptable solution in a real app situation?
romulusc
4 years ago
Found one more small bug, if tapping 2 times consecutively on "refreshButton" the stack of cards gets loaded twice and the top card wont move, can't be liked or disliked. only the cards underneath the top card will react to like/dislike. I found a solution where handleRegresh works only when topCardView is empty, at the end of the stack, or in my case at the end of paggination which i kept as a feature. @objc fileprivate func handleRefresh() { if topCardView == nil { fetchUsersFromFirestore() } }
Brian Voong
4 years ago
romulusc
4 years ago
cheers
David Guarino
4 years ago
So your modification works pretty good when I click the "like" and "Dislike" button However when I use the swiping feature the "refresh button" doesn't fetch the users again.... Did this happen to you as well? If so, is this another bug that gets sorted out later
David Guarino
4 years ago
Cancel that....it works based on the hack Brian performs in the next lesson. Thanks
Dongjun Kim
4 years ago
Hey Brian! Why do we need to commit() from CATransaction?
sknerd
3 years ago
Hey, Brian. For some reason my animations go in reverse order - the bottom card from the stack gets of the screen first and so on. Can't figure out why, hope you can help me. Thanks.
sknerd
3 years ago
figured it out i was missing "cardsDeckView.sendSubviewToBack(cardView)" line in setupCardFromUser func
HELP & SUPPORT