native decay animation

Summary: Add support for `useNativeDriver: true` to `Animated.decay`. Add example in Native Animated Example UIExplorer app.

Reviewed By: ritzau

Differential Revision: D3690127

fbshipit-source-id: eaa5e61293ed174191cec72255ea2677dbaa1757
This commit is contained in:
Felix Oghina
2016-08-19 07:06:29 -07:00
committed by Facebook Github Bot 5
parent 37ab1c8844
commit 2a7f4be8f8
5 changed files with 161 additions and 3 deletions

View File

@@ -41,12 +41,16 @@ class Tester extends React.Component {
current = 0;
onPress = () => {
const animConfig = (
this.current && this.props.reverseConfig ? this.props.reverseConfig : this.props.config
);
this.current = this.current ? 0 : 1;
const config = {
...this.props.config,
...animConfig,
toValue: this.current,
};
// $FlowIssue #0000000
Animated[this.props.type](this.state.native, { ...config, useNativeDriver: true }).start();
Animated[this.props.type](this.state.js, { ...config, useNativeDriver: false }).start();
};
@@ -344,6 +348,32 @@ exports.examples = [
</Tester>
);
},
},{
title: 'translateX => Animated.decay',
render: function() {
return (
<Tester
type="decay"
config={{ velocity: 0.5 }}
reverseConfig={{ velocity: -0.5 }}
>
{anim => (
<Animated.View
style={[
styles.block,
{
transform: [
{
translateX: anim
},
],
}
]}
/>
)}
</Tester>
);
},
},
{
title: 'Animated value listener',