This repository was archived by the owner on Nov 12, 2019. It is now read-only.
File tree 1 file changed +13
-6
lines changed
1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ export default class HomeFragment extends Component{
13
13
constructor ( props ) {
14
14
super ( props ) ;
15
15
this . state = {
16
- opacity : 1 ,
17
-
16
+ opacity : 0 ,
18
17
} ;
18
+ this . imageHeight = 300 ;
19
19
}
20
20
21
21
render ( ) {
@@ -25,17 +25,24 @@ export default class HomeFragment extends Component{
25
25
< NavigationBar title = "今日Gank" />
26
26
</ View >
27
27
< ScrollView
28
+ scrollEnabled = { this . state . scrollEnabled }
28
29
onScroll = { this . _onScroll . bind ( this ) } >
29
- < Image source = { require ( '../../assets/test.jpg' ) } resizeMode = "cover" style = { { height : 300 , width : theme . screenWidth } } />
30
+ < Image source = { require ( '../../assets/test.jpg' ) } resizeMode = "cover" style = { { height : this . imageHeight , width : theme . screenWidth } } />
30
31
< View style = { styles . scrollContents } >
31
-
32
+ < Text > dsds </ Text >
32
33
</ View >
33
34
</ ScrollView >
34
35
</ View >
35
36
) ;
36
37
}
37
38
38
- _onScroll ( ) {
39
+ _onScroll ( event ) {
40
+ var offsetY = event . nativeEvent . contentOffset . y ;
41
+ if ( offsetY <= this . imageHeight - theme . toolbar . height ) {
42
+ var opacity = offsetY / ( this . imageHeight - theme . toolbar . height ) ;
43
+ this . setState ( { opacity : opacity } ) ;
44
+ }
45
+
39
46
40
47
}
41
48
@@ -50,7 +57,7 @@ const styles = StyleSheet.create({
50
57
width : theme . screenWidth ,
51
58
left : 0 ,
52
59
top : 0 ,
53
- elevation : 8
60
+ zIndex : 1
54
61
} ,
55
62
scrollContents : {
56
63
height : theme . screenHeight ,
You can’t perform that action at this time.
0 commit comments