Skip to content

Best way to do transitions with Fela #907

Answered by robinweser
martyjg asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @martyjg,

I've been on a 3 week vacation, so sorry for the late response here.

Great question! Here's what I'd do:
Given that you want to reuse the same keyframe in multiple places, you're that the animation name is what needs to be stored somehow. Given how efficient the rendering process is, the impact of copy-pasting the code into many components actually wouldn't be noticeable, but thanks to React hooks we can solve that even better:

// note that the keyframe itself doesn't need to be inside of the function (or component respectively)
const keyframe = () => ({
  from: {
    transform: 'translateY(50%)',
    opacity: 0
  },
  to: {
    transform: 'translateY(0)',
    opacity: 1
  }
})

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robinweser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants