This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catWidthCal() { | |
const items = JSONdata.categories; | |
let width = []; | |
for (let i = 0; i < items.length; i++) { | |
width.push(document.getElementById("category" + i).offsetWidth); | |
} | |
this.setState({ catWidth: width }); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state = { | |
data:mockJSON, | |
categoryTextWidth: [], | |
toLeft: 40, //for inital position of the slider | |
currentSlideIndex: 0, | |
currentItem: 0 | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render(){ | |
return( | |
<div style={backgroundStyle}> | |
<div style={topMenusStyle} /> | |
<div style={categoriesStyle} /> | |
<div style={itemsStyle} /> | |
</div> | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"categories":[ | |
"Hulu Originals", "Featured Movies", "Holiday Shows", "TV Shows" | |
], | |
"items":[ | |
//we will link array index with categories index | |
[ | |
{ | |
"title": "Title of the show", | |
"color": "border and screen color", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class App extends Component { | |
render() { | |
return ( | |
<Animated.ScrollView | |
scrollEventThrottle={16} | |
onScroll={Animated.event( | |
[{ nativeEvent: { contentOffset: { x: xOffset } } }], | |
{ useNativeDriver: true } | |
)} | |
horizontal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const xOffset = new Animated.Value(0); | |
const transitionAnimation = index => { | |
return { | |
transform: [ | |
{ perspective: 800 }, | |
{ | |
scale: xOffset.interpolate({ | |
inputRange: [ | |
(index - 1) * SCREEN_WIDTH, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inputRange: [ | |
(index - 1) * SCREEN_WIDTH, | |
index * SCREEN_WIDTH, | |
(index + 1) * SCREEN_WIDTH | |
], | |
outputRange: [ | |
"entering animation", | |
"screen in the middle no transform", | |
"exiting animation" | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//We declare this here because the device width will be used for scrollView again | |
const SCREEN_WIDTH = Dimensions.get("window").width; | |
//Screen component | |
const Screen = props => { | |
return ( | |
<View style={styles.scrollPage}> | |
//we are going to write animation function and pass it to here | |
<Animated.View style={[styles.screen, transitionAnimation(props.index)]}> | |
<Text style={styles.text}>{props.text}</Text> | |
</Animated.View> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<View style={styleshere}> | |
<Animated.View | |
//this is the key for panResponder | |
{...this.panResponder.panHandlers} | |
style={[panStyle, { width: 200, height: 200 }]} | |
> | |
<Expo.GLView | |
style={{ flex: 1 }} | |
onContextCreate={this._onGLContextCreate} | |
/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_onGLContextCreate = async gl => { | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( | |
75, gl.drawingBufferWidth / gl.drawingBufferHeight, 0.1, 1000 | |
); | |
const renderer = ExpoTHREE.createRenderer({ gl }); | |
renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight); | |
const geometry = new THREE.SphereBufferGeometry(1, 36, 36); | |
const material = new THREE.MeshBasicMaterial({ |