Created
March 15, 2016 10:31
-
-
Save kmagiera/bbfbac6c00077d188bc5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @providesModule Playground | |
*/ | |
'use strict'; | |
var React = require('react-native'); | |
var { | |
Animated, | |
StyleSheet, | |
Text, | |
View, | |
TouchableHighlight | |
} = React; | |
var FadeInView = React.createClass({ | |
getInitialState: function() { | |
return { | |
fadeAnim: new Animated.Value(0), | |
} | |
}, | |
componentDidMount: function() { | |
Animated.timing( | |
this.state.fadeAnim, | |
{ | |
toValue: 1, | |
duration: 2000, | |
useNativeDriver: true, | |
}, | |
).start(); | |
}, | |
render: function() { | |
return ( | |
<Animated.View // Special animatable View | |
style={{ | |
opacity: this.state.fadeAnim, | |
}}> | |
{this.props.children} | |
</Animated.View> | |
); | |
} | |
}); | |
var Playground = React.createClass({ | |
getInitialState: function() { | |
return { | |
show: true, | |
} | |
}, | |
render: function() { | |
return ( | |
<View> | |
<TouchableHighlight onPress={() => { | |
this.setState((state) => ( | |
{show: !state.show} | |
)); | |
}}> | |
<View style={styles.content}> | |
<Text>Press to {this.state.show ? 'Hide' : 'Show'}</Text> | |
</View> | |
</TouchableHighlight> | |
{this.state.show && <FadeInView> | |
<View style={styles.content}> | |
<Text>FadeInView</Text> | |
</View> | |
</FadeInView>} | |
</View> | |
); | |
} | |
}); | |
var styles = StyleSheet.create({ | |
content: { | |
backgroundColor: 'deepskyblue', | |
borderWidth: 1, | |
borderColor: 'dodgerblue', | |
padding: 20, | |
margin: 20, | |
borderRadius: 10, | |
alignItems: 'center', | |
}, | |
}); | |
module.exports = Playground; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment