-
Notifications
You must be signed in to change notification settings - Fork 1
/
ParallelTest.js
79 lines (66 loc) · 1.72 KB
/
ParallelTest.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
// Components/Test.js
import React from 'react'
import { StyleSheet, View,Platform ,Text,Animated,Easing } from 'react-native'
// Components/Test.js
class ParallelTest extends React.Component {
constructor(props) {
super(props)
this.state = {
topPosition: new Animated.Value(0),
leftPosition: new Animated.Value(0),
}
}
componentDidMount() {
Animated.parallel([
Animated.spring(
this.state.topPosition,
{
toValue: 100,
tension: 8,
friction: 3
}
),
Animated.timing(
this.state.leftPosition,
{
toValue: 100,
duration: 1000,
easing: Easing.elastic(2)
}
)
]).start()
}
render() {
return (
<View style={styles.main_container}>
<Animated.View style={[styles.animation_view, { top: this.state.topPosition, left: this.state.leftPosition }]}></Animated.View>
</View>
)
}
}
const styles = StyleSheet.create({
main_container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
subview_container: {
...Platform.select({
ios:{
backgroundColor:'red',
height:50,
width:100,
},
android:{
backgroundColor:'blue',
height:100,
width:50,
}}
) },
animation_view: {
backgroundColor: 'red',
width: 100,
height: 100
}
})
export default ParallelTest