Skip to content

Instantly share code, notes, and snippets.

@krvajal
Created February 26, 2018 22:37
Show Gist options
  • Save krvajal/e54ca1811e1a43c1e9df1a7d6ec9c249 to your computer and use it in GitHub Desktop.
Save krvajal/e54ca1811e1a43c1e9df1a7d6ec9c249 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { Text, View, StyleSheet, ScrollView, Image, Animated } from 'react-native';
import { Constants } from 'expo';
// You can import from local files
import AssetExample from './components/AssetExample';
// or any pure javascript modules available in npm
import { Card } from 'react-native-elements'; // 0.18.5
export default class App extends Component {
state = {
scroll: 0
}
render() {
return (
<View style={styles.container}>
<Animated.ScrollView
contentInsetAdjustmentBehavior="always"
scrollEventThrottle={16}
contentContainerStyle={{paddingTop: 200, x:0}}
onScroll={(evt) => { this.setState({scroll: evt.nativeEvent.contentOffset.y})} } style={{flex:1, backgroundColor: 'red', position: "absolute", top: 0, left:0, right:0, height:2000}}>
<Text style={{height:23000}}>Hello world</Text>
</Animated.ScrollView>
<Image source={{uri:"http://hdwallsource.com/img/2014/3/green-landscape-16039-16527-hd-wallpapers.jpg"}} style={{position:"absolute", width: 500, height:200 - this.state.scroll , top:0}}/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
paddingTop: Constants.statusBarHeight,
backgroundColor: '#ecf0f1',
},
paragraph: {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
color: '#34495e',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment