-
Notifications
You must be signed in to change notification settings - Fork 0
/
Animated4.js
93 lines (86 loc) · 1.95 KB
/
Animated4.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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react';
import {
View,
Text,
TouchableOpacity,
LayoutAnimation,
StyleSheet,
} from 'react-native';
const customAnim = {
customSpring: {
duration: 400,
create: {
type: LayoutAnimation.Types.spring,
property: LayoutAnimation.Properties.scaleXY,
springDamping: 0.6
},
update: {
type: LayoutAnimation.Types.spring,
springDamping: 0.6
}
},
customLinear: {
duration: 200,
create: {
type: LayoutAnimation.Types.linear,
property: LayoutAnimation.Properties.opacity,
},
update: {
type: LayoutAnimation.Types.easeInEaseOut
}
}
};
export default class DemoLayoutAnimation extends React.Component {
constructor(props) {
super(props);
this.state = {
width: 100,
height: 100,
};
this._onPress = this._onPress.bind(this);
//this._createAnimation = this._createAnimation.bind(this);
}
// componentWillMount() {
// LayoutAnimation.spring();
// }
componentWillUpdate() {
LayoutAnimation.configureNext(customAnim.customLinear);
}
_onPress = () => {
// LayoutAnimation.spring();
this.setState({ width: this.state.width + 20, height: this.state.height + 20 });
};
render() {
return (
<View style={styles.container}>
<View style={[styles.box, { width: this.state.width, height: this.state.height }]} />
<TouchableOpacity onPress={this._onPress}>
<View style={styles.button}>
<Text style={styles.buttonText}>Press me!</Text>
</View>
</TouchableOpacity>
</View>
);
}
};
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center'
},
box: {
backgroundColor: 'red'
},
button: {
marginTop: 10,
paddingVertical: 10,
paddingHorizontal: 20,
backgroundColor: 'black'
},
buttonText: {
color: 'white',
fontSize: 16,
fontWeight: 'bold'
}
});