Skip to content

Instantly share code, notes, and snippets.

@luisbajana
Created July 6, 2019 15:07
Show Gist options
  • Save luisbajana/b9dd15513bbb96d1beb6556dda7ca232 to your computer and use it in GitHub Desktop.
Save luisbajana/b9dd15513bbb96d1beb6556dda7ca232 to your computer and use it in GitHub Desktop.
Basic Animation using React Native
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