Animation triggers twice #861
-
Hi there, I have build a swipe functionality (only for mobile) in our flashcard app. Further I have implemented two icons which appear when swiped (one for correct answer, one for wrong answer). Actually everything works as intended. Only when the icons appear after the swipe it looks like they flicker a bit – meaning the animation seems to start two times. I cannot figure out where the problem lies and why this happens. Maybe anyone has an idea and can provide a solution. And this is the repository link. Thanks in advance! 🤧 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello everyone 👋 unfortunately I don't have the solution, but I do have an approach - maybe this will help someone else to find the solution. I think it has something to do with the render cycle. I wrote So as I said: Unfortunately, I don't have the solution yet, but I think it has something to do with the frequent rendering (both of the By the way, I'm part of this capstone group, but I didn't work on this feature, so I'm not particularly familiar with this branch. PS: Anyway, it’s great what you have already achieved, Isabell! 💪😁 I find your code really complicated and impressive. 😅 |
Beta Was this translation helpful? Give feedback.
I think Elisabeth is right, in that it seems to be due to the number of times the component is rendering.
I would consider 2 things to potentially fix this.
Sync your timeouts. At the moment you have some timeouts at 1100, and one in App.js at 200. These will then cause the components to rerender around 900ms apart (which might be causing the flash). Do we need the 200ms timer now that the swipe animation is working?
Maybe consider moving the
isAnimating
state and logic to theFlashcard
component. That means you will have the state local, rather than ALL the cards in your list getting the isAnimating.Hopefully these help! Great work so far.