-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
99 lines (89 loc) · 2.07 KB
/
App.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
94
95
96
97
98
99
import React from 'react';
import {
StyleSheet,
Text,
View,
Animated,
Easing,
} from 'react-native';
const logoImage = require('./assets/icon.png');
export default class App extends React.Component {
state={
animatedRotateValue: new Animated.Value(0),
animatedScaleValue: new Animated.Value(0),
};
componentDidMount() {
const { animatedRotateValue, animatedScaleValue } = this.state;
Animated.timing(
animatedScaleValue, {
toValue: 1,
useNativeDriver: true,
duration: 3000,
easing: Easing.elastic(2),
},
).start();
Animated.loop(
Animated.timing(
animatedRotateValue,
{
toValue: 1,
duration: 2000,
useNativeDriver: true,
easing: Easing.linear,
},
),
).start();
}
render() {
const { animatedRotateValue, animatedScaleValue } = this.state;
const spinTransform = animatedRotateValue.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg'],
});
const scaleTransform = animatedScaleValue.interpolate({
inputRange: [0, 1],
outputRange: [0, 1],
});
return (
<View style={styles.container}>
<Animated.Image
source={logoImage}
style={{
height: 100,
width: 100,
transform: [
{ rotate: spinTransform },
{ scaleX: scaleTransform },
{ scaleY: scaleTransform },
],
}}
/>
<Text style={styles.t1}>
Checkout the branches of this repo to try out awesome animations.
</Text>
<Text style={styles.t2}>
{'😬 Also check README.md 😬'}
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
padding: 32,
},
t1: {
fontWeight: '500',
textAlign: 'center',
marginTop: 16,
},
t2: {
fontWeight: '300',
textAlign: 'center',
marginTop: 16,
},
});