I'm trying to enable native animations (useNativeDriver) when using transitionTo with translateY and opacityas props, but as far as I can see it is not supported. Am I missing something?
Would it be possible to add this option?
I'm pretty sure setting useNativeDriver={true} as a prop will be enough.
<TouchableOpacity
onPress = {() => this.refs.view.transitionTo({ opacity: 0.5, width: 50, margin: 10 }, 500, 'linear')}>
<Animatable.View useNativeDriver={true} ref='view' style={{ width: 100, height: 100 }}>
<Text>Hello World</Text>
</Animatable.View>
</TouchableOpacity>
I have tried that, but as far as I can see it does not work. I tested it by animating a prop that the native driver does not support, and I did not get an error, thus I concluded that it was not being used.
I just checked the code and it seems like you're right. +1
Regarding the animatable package, adding useNativeDriver argument to the functions and pass it to transitionToValues and then to transitionToValue could be an easy solution.
Also interested in the useNativeDriver prop. Should we make a PR or it is already made?
Just rechecked the docs and I see that useNativeDriver prop is already defined. Does not it work?
I just submitted a PR: #106
@flybayer very nice 👍
It might be better to introduce useNativeDriver as an argument of transition and transitionTo functions, so it will be available when calling these functions imperatively (e.g [using argument destructoring]: this.refs.view.transitionTo({ toValues: {opacity: 0.2}, useNativeDriver: true}); )
@orenklein I didn't do that because:
You can't mix them.
Good point. I was not aware of that.
var fromValues = {opacity:1}//这是一个style
var toValues = {opacity:0.1}//这是一个 style,
this.refs.testView.transition(fromValues,toValues,2000,'esa-out');
Most helpful comment
I just submitted a PR: #106