-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDecayExample.js
More file actions
43 lines (37 loc) · 755 Bytes
/
DecayExample.js
File metadata and controls
43 lines (37 loc) · 755 Bytes
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
import React from 'react';
import { Animated, View } from 'react-native';
class DecayExample extends React.Component {
state = {
animation: new Animated.Value(-150)
}
componentDidMount() {
Animated.decay(
this.state.animation,
{
toValue: 200,
duration: 2000,
velocity: 0.95,
deceleration: 0.998
}
).start();
}
render() {
const animationStyles = {
transform: [
{ translateY: this.state.animation }
]
};
return (
<Animated.View style={[objectStyles.object, animationStyles]}>
</Animated.View>
);
}
}
const objectStyles = {
object: {
backgroundColor: 'orange',
width: 100,
height: 100
}
}
export { DecayExample };