Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feature) css.keyframes() and CSS animations #3

Open
necolas opened this issue Feb 20, 2024 · 2 comments
Open

(feature) css.keyframes() and CSS animations #3

necolas opened this issue Feb 20, 2024 · 2 comments
Labels
feature Feature or technical request

Comments

@necolas
Copy link
Contributor

necolas commented Feb 20, 2024

Describe the feature request

Support css.keyframes on native. We can use Animated to polyfill this API and the following CSS props:

  • animationDelay
  • animationDirection
  • animationDuration
  • animationFillMode
  • animationIterationCount
  • animationName
  • animationPlayState
  • animationTimingFunction
@necolas necolas added the feature Feature or technical request label Feb 20, 2024
@burhanyilmaz
Copy link

What you think about reanimated's keyframe animation? is it suitable for it?
https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/keyframe-animations/

import { Keyframe } from 'react-native-reanimated';

const keyframe = new Keyframe({
  0: {
    transform: [{ rotate: '0deg' }],
  },
  100: {
    transform: [{ rotate: '45deg' }],
  },
});
import { Keyframe } from 'react-native-reanimated';

const keyframe = new Keyframe({
  from: {
    transform: [{ rotate: '0deg' }],
  },
  to: {
    transform: [{ rotate: '45deg' }],
  },
});

@nandorojo
Copy link
Contributor

One idea for this feature is to allow a pluggable View / Text component from the root so that one can use reanimated.

For example, in the root of the app, we could define some component that replaces the underlying View/Text used by RSD on native in the case of an animation. Something like:

import { configureAnimationComponents } from 'react-strict-dom'
import Animated from 'react-native-reanimated'

configureAnimationComponents({
  components: { View: Animated.View, ... },
  getKeyframeProps: (animation) => ({ style: ... })
})

Not married to any API, but this could be an interesting way to do it, where you 1) define the components, and 2) define the way to get the props to them based on the animation the user wants.

On web, this wouldn't necessarily be needed and would potentially mess with tree shaking.

Open to alternatives, but I've liked Tamagui's "animation driver" approach and think it could be an interesting addition here until the day that RN's actual animations are performant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature or technical request
Projects
None yet
Development

No branches or pull requests

3 participants