Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 96a40b6

Browse files
committed
home page scroll effects
1 parent 27591a9 commit 96a40b6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

js/containers/HomeTab/index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export default class HomeFragment extends Component{
1313
constructor(props){
1414
super(props);
1515
this.state = {
16-
opacity: 1,
17-
16+
opacity: 0,
1817
};
18+
this.imageHeight = 300;
1919
}
2020

2121
render(){
@@ -25,17 +25,24 @@ export default class HomeFragment extends Component{
2525
<NavigationBar title="今日Gank"/>
2626
</View>
2727
<ScrollView
28+
scrollEnabled={this.state.scrollEnabled}
2829
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}}/>
3031
<View style={styles.scrollContents}>
31-
32+
<Text>dsds</Text>
3233
</View>
3334
</ScrollView>
3435
</View>
3536
);
3637
}
3738

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+
3946

4047
}
4148

@@ -50,7 +57,7 @@ const styles = StyleSheet.create({
5057
width: theme.screenWidth,
5158
left: 0,
5259
top: 0,
53-
elevation: 8
60+
zIndex: 1
5461
},
5562
scrollContents: {
5663
height: theme.screenHeight,

0 commit comments

Comments
 (0)