-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLayoutAnimationExample.js
40 lines (37 loc) · 1.11 KB
/
LayoutAnimationExample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import { View, LayoutAnimation, Button, StyleSheet } from 'react-native';
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
export default class LayoutAnimationExample extends React.Component {
constructor(props) {
super(props);
this.state = {
minimized: false,
};
}
render() {
const { minimized } = this.state;
return (
<View style={styles.container}>
<Button
title="Toggle"
onPress={() => {
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
this.setState(p => ({ ...p, minimized: !p.minimized }));
}}
/>
<View style={{ width: '100%', flexDirection: 'row' }}>
<View style={{ backgroundColor: 'green', height: 50, flex: minimized ? 2 : 1 }} />
<View style={{ backgroundColor: 'blue', height: 50, flex: minimized ? 0.5 : 1 }} />
<View style={{ backgroundColor: 'red', height: 50, flex: 1 }} />
</View>
</View>
);
}
}