Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Created August 5, 2019 10:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luandevpro/f68c1e6813c706396de796e743d91345 to your computer and use it in GitHub Desktop.
Save luandevpro/f68c1e6813c706396de796e743d91345 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import {
View, Text, Animated, StyleSheet, TouchableWithoutFeedback, Easing,
} from 'react-native';
import PropTypes from 'prop-types';
export default function Home() {
const [animated, setAnimated] = useState(new Animated.Value(150));
const animatedSpring = {
width: animated,
height: animated,
};
const handleOnPress = () => {
// animated.addListener(({ values }) => {
// console.log(values);
// });
Animated.spring(animated, {
toValue: 300,
friction: 2,
tension: 160,
}).start(() => {
Animated.timing(animated, {
toValue: 150,
duration: 100,
}).start();
});
};
return (
<View style={styles.container}>
<Text>Home</Text>
<TouchableWithoutFeedback
onPress={handleOnPress}
>
<Animated.View
style={[styles.box, animatedSpring]}
/>
</TouchableWithoutFeedback>
</View>
);
}
Home.propTypes = {
navigation: PropTypes.object , // eslint-disable-line
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
box: {
backgroundColor: 'blue',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment