-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAnimatedSnow.js
58 lines (44 loc) · 905 Bytes
/
AnimatedSnow.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
/**
* Created by admin on 12/28/16.
*/
import React, {PureComponent} from 'react';
import {
StyleSheet,
Text,
View
} from 'react-native';
import Snow from './Snow';
export default class AnimatedSnow extends PureComponent {
constructor(props) {
super(props);
this.state = {
width: 0,
height: 0,
}
}
render() {
const snow = [];
if (this.state.width > 0 && this.state.height > 0) {
for (let i = 0; i < 40; i++) {
snow.push(
<Snow
key={i}
width={this.state.width}
height={this.state.height}
/>)
}
}
return (
<View {...this.props}
onLayout={(e) => {
const {width, height} = e.nativeEvent.layout;
this.setState ({
width: width,
height: height
});
}}>
{snow}
</View>
)
}
}