React-spring: Use Reanimated on React Native

Created on 28 Jul 2019  路  13Comments  路  Source: pmndrs/react-spring

馃殌 Feature Proposal

Use react-native-reanimated on React Native.

Motivation

It should provide 60 fps animations even on low end Android devices.

The animations would run at the native thread, not the JavaScript one. Plus it supports useNativeDriver on all properties, not only a limited subset like the official Animated.

Related: #299

enhancement

Most helpful comment

@rodolfovilaca can you open a draft pull request?

All 13 comments

This would be mind-blowing 馃く馃く:rocket: :rocket: . I'm gonna try an implementation on this issue soon. Could be game changing for cross-platform animations.

even if not all the functionality is available, it would be nice to have. maybe even as an experimental target: targets/native-driver. the v9 branch is modular enough for this to actually work out now.

@brunolemos So is it possible to currently use react-native-reanimated and react-spring together as seen from Evan's twitter example?

Here's hoping something drops soon - was just about to refactor a few dozen animations to reanimated for performance reasons on a react-native app, so this would save me days!

Hey guys just an update on the implementation and some thoughts, so you can organize your timelines:

  1. I got all interpolations working great (colors, rotations etc...).
  2. Today how it works, i track the array of animations and change the interpolation to be affected in each style, and for this I re-wrote(a simpler version) of everything to see if it could be done. This is ok, but not great as it doesn't support script animations(as react-spring supports) because it needs to be handled as a Promise like sequence of animations. So today i support animations like:
{
    from: { width: 0, opacity: 0 },
    to: [
        { width: 100, opacity: 1 },
        { width: 0, opacity: 0 }
    ]
}
// this will work as a sequence animation

but do not support function scripts.

  1. My current work is to implement this solution as a queue promise sequence(as react-spring works today) and try to plug into react-spring core and see if it works.
  2. react-native-reanimated has some overhead on transporting many Animated nodes to the native side, causing some fps loss(not noticeable in simple animations like above.) As seen https://github.com/react-navigation/stack/issues/252, this can impact some animations lists with trail and looping(cause i need to have a single Animated value for each item of the list) in long period of times the animations just get out of sync.

Unfortunately, I have 2 projects on my plate today and have little free time to implement this.

Feel free to comment and give some ideas on how we can do a roadmap to merge this into master. Maybe an experimental one as @drcmda said.

@evanheckert I don't have an estimate for you, but maybe I can share with you some stuff to see if it can help in your needs.

@rodolfovilaca can you open a draft pull request?

Any updates?

Any news guys ?

Integrating with react-native-reanimated just got a whole lot easier. 馃憖

https://twitter.com/kzzzf/status/1266038863681794048

Any update on this? Animations with spring's APIs are great. But are lagging on several Android devices tested. Reanimated will help in boosting this severely.

Reanimated v2's API is miles ahead of v1. It also now has web support, in case that's relevant.
Universal animations with reanimated performance on native would be 馃敟 Is this still looking realistic for 9.1?

If so, @aleclarson is there somewhere in the code I could start looking? I'm not familiar with the code base, but I could probably help with the reanimated integration.

(CC: https://github.com/nandorojo/dripsy/issues/46)

Was this page helpful?
0 / 5 - 0 ratings