mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
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:
committed by
Facebook Github Bot 5
parent
37ab1c8844
commit
2a7f4be8f8
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user