LayoutAnimation
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
class App extends Component {
constructor(props) {
super(props);
this.state = { s: 100 };
}
_onPress = () => {
LayoutAnimation.spring();
this.setState({ s: this.state.s + 15 });
}
render() {
return (
<View style={ styles.container }>
<View style={[
styles.box,
{ width: this.state.s, height: this.state.s }
]} />
<TouchableOpacity onPress={ this._onPress }>
<View style={ styles.button }>
<Text style={ styles.buttonText }>Press me!</Text>
</View>
</TouchableOpacity>
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
box: {
backgroundColor: 'red',
},
button: {
marginTop: 10,
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: 'black',
},
buttonText: {
color: 'white',
fontSize: 16,
fontWeight: 'bold',
},
});