2015-07-07 20:34:09 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2016-07-12 12:51:57 +00:00
|
|
|
*
|
2018-05-11 20:32:37 +00:00
|
|
|
* @format
|
2016-02-25 10:44:58 +00:00
|
|
|
* @flow
|
2015-07-07 20:34:09 +00:00
|
|
|
*/
|
2018-05-11 20:32:37 +00:00
|
|
|
|
2015-07-07 20:34:09 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 03:36:40 +00:00
|
|
|
var React = require('react');
|
|
|
|
var ReactNative = require('react-native');
|
2018-05-11 20:32:37 +00:00
|
|
|
var {Animated, Image, ScrollView, StyleSheet, Text, View} = ReactNative;
|
2015-07-07 20:34:09 +00:00
|
|
|
|
2017-08-18 01:36:54 +00:00
|
|
|
class AnExScroll extends React.Component<$FlowFixMeProps, any> {
|
2018-05-11 20:32:37 +00:00
|
|
|
state: any = {scrollX: new Animated.Value(0)};
|
2015-07-07 20:34:09 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
var width = this.props.panelWidth;
|
|
|
|
return (
|
|
|
|
<View style={styles.container}>
|
|
|
|
<ScrollView
|
|
|
|
automaticallyAdjustContentInsets={false}
|
2018-05-11 20:32:37 +00:00
|
|
|
scrollEventThrottle={16 /* get all events */}
|
2015-07-07 20:34:09 +00:00
|
|
|
onScroll={Animated.event(
|
2018-05-11 20:32:37 +00:00
|
|
|
[{nativeEvent: {contentOffset: {x: this.state.scrollX}}}], // nested event mapping
|
2015-07-07 20:34:09 +00:00
|
|
|
)}
|
|
|
|
contentContainerStyle={{flex: 1, padding: 10}}
|
|
|
|
pagingEnabled={true}
|
|
|
|
horizontal={true}>
|
|
|
|
<View style={[styles.page, {width}]}>
|
2018-05-11 20:32:37 +00:00
|
|
|
<Image style={{width: 180, height: 180}} source={HAWK_PIC} />
|
2015-07-07 20:34:09 +00:00
|
|
|
<Text style={styles.text}>
|
2018-05-11 20:32:37 +00:00
|
|
|
{"I'll find something to put here."}
|
2015-07-07 20:34:09 +00:00
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
<View style={[styles.page, {width}]}>
|
|
|
|
<Text style={styles.text}>{'And here.'}</Text>
|
|
|
|
</View>
|
|
|
|
<View style={[styles.page, {width}]}>
|
|
|
|
<Text>{'But not here.'}</Text>
|
|
|
|
</View>
|
|
|
|
</ScrollView>
|
|
|
|
<Animated.Image
|
|
|
|
pointerEvents="none"
|
2018-05-11 20:32:37 +00:00
|
|
|
style={[
|
|
|
|
styles.bunny,
|
2017-01-29 20:32:19 +00:00
|
|
|
{
|
2018-05-11 20:32:37 +00:00
|
|
|
transform: [
|
|
|
|
{
|
|
|
|
translateX: this.state.scrollX.interpolate({
|
|
|
|
inputRange: [0, width, 2 * width],
|
|
|
|
outputRange: [0, 0, width / 3],
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
translateY: this.state.scrollX.interpolate({
|
|
|
|
inputRange: [0, width, 2 * width],
|
|
|
|
outputRange: [0, -200, -260],
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
scale: this.state.scrollX.interpolate({
|
|
|
|
inputRange: [0, width, 2 * width],
|
|
|
|
outputRange: [0.5, 0.5, 2],
|
|
|
|
extrapolate: 'clamp',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
],
|
2017-01-29 20:32:19 +00:00
|
|
|
},
|
2018-05-11 20:32:37 +00:00
|
|
|
]}
|
2015-07-07 20:34:09 +00:00
|
|
|
source={BUNNY_PIC}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var styles = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
text: {
|
|
|
|
padding: 4,
|
|
|
|
paddingBottom: 10,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 18,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
|
|
|
bunny: {
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
position: 'absolute',
|
|
|
|
height: 160,
|
|
|
|
width: 160,
|
|
|
|
},
|
|
|
|
page: {
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2018-05-11 20:32:37 +00:00
|
|
|
var HAWK_PIC = {
|
|
|
|
uri:
|
|
|
|
'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xfa1/t39.1997-6/10734304_1562225620659674_837511701_n.png',
|
|
|
|
};
|
|
|
|
var BUNNY_PIC = {
|
|
|
|
uri:
|
|
|
|
'https://scontent-sea1-1.xx.fbcdn.net/hphotos-xaf1/t39.1997-6/851564_531111380292237_1898871086_n.png',
|
|
|
|
};
|
2015-07-07 20:34:09 +00:00
|
|
|
|
|
|
|
module.exports = AnExScroll;
|