-
Notifications
You must be signed in to change notification settings - Fork 1
/
DecayTest.js
67 lines (53 loc) · 1.31 KB
/
DecayTest.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
// Components/Test.js
import React from 'react'
import { StyleSheet, View,Platform ,Animated } from 'react-native'
class DecayTest extends React.Component {
constructor(props) {
super(props)
this.state = {
topPosition: new Animated.Value(0),
}
}
componentDidMount() {
Animated.decay(
this.state.topPosition,
{
velocity: 0.8,
deceleration: 0.997,
}
).start();
}
render() {
return (
<View style={styles.main_container}>
<Animated.View style={[styles.animation_view, { top: this.state.topPosition}]}></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 DecayTest