Created
July 6, 2019 15:07
-
-
Save luisbajana/b9dd15513bbb96d1beb6556dda7ca232 to your computer and use it in GitHub Desktop.
Basic Animation using React Native
This file contains 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
import React, {Component} from 'react'; | |
import { Platform, StyleSheet, Text, View, TouchableHighlight, Dimensions, Animated, PanResponder } from 'react-native'; | |
type Props = {}; | |
export default class App extends Component<Props> { | |
componentWillMount(){ | |
this.position = new Animated.ValueXY(0,0) | |
Animated.spring( this.position , { | |
toValue: { x: 300, y: 100 } | |
} ).start() | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Animated.View style={this.position.getLayout()}> | |
<View style={[ styles.square ]}></View> | |
</Animated.View> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#F5FCFF', | |
}, | |
square:{ | |
backgroundColor: '#000000', | |
height: 35, | |
width: 35, | |
position: 'absolute' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment