-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathindexLAYOUTANIM.ios.js
More file actions
73 lines (64 loc) · 1.44 KB
/
indexLAYOUTANIM.ios.js
File metadata and controls
73 lines (64 loc) · 1.44 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
import React, {
AppRegistry,
Component,
StyleSheet,
Text,
View,
TouchableOpacity,
LayoutAnimation,
} from 'react-native';
class LayoutAnimationApp extends React.Component {
constructor(){
super();
this.state = {
txt: 'Small',
viewStyle: {
height: 250
}
}
}
animateView(){
let callback = this.onViewLayout.bind(this)
LayoutAnimation.configureNext(LayoutAnimation.Presets.spring, callback())
this.setState({
viewStyle: {
height: this.state.viewStyle.height > 250 ? 250 : 450
}
})
}
onViewLayout(){
this.setState({txt: this.state.viewStyle.height > 250 ? 'Small' : 'BIG'})
}
render(){
let viewStyle = [styles.view, this.state.viewStyle]
return (
<View style={styles.container}>
<TouchableWithoutFeedback onPress={this.animateView.bind(this)}>
<View style={viewStyle}>
<Text style={styles.viewText}>{this.state.txt}</Text>
</View>
</TouchableWithoutFeedback>
</View>
);
}
};
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
view: {
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'black',
margin: 20
},
viewText: {
color: 'white'
}
});
AppRegistry.registerComponent('Experiments', () => Experiments);