Skip to content

Instantly share code, notes, and snippets.

@osama256
Created January 4, 2022 17:37
Show Gist options
  • Save osama256/f804b08732291094fb9e6518ef1308d2 to your computer and use it in GitHub Desktop.
Save osama256/f804b08732291094fb9e6518ef1308d2 to your computer and use it in GitHub Desktop.
import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';
import React from 'react';
import Animated, { useSharedValue, withRepeat, useAnimatedStyle, withTiming } from 'react-native-reanimated'
const App: () => React$Node = () => {
const animation = useSharedValue(1)
const animationStyle = useAnimatedStyle(() => {
return {
transform: [
{
scale: animation.value
}
]
}
})
const startAnimation = () => {
animation.value = withRepeat(withTiming(1.5, {
duration: 1000
}), -1)
}
return (
<View style={styles.container}>
<TouchableWithoutFeedback onPress={startAnimation}>
<Animated.View style={[styles.box, animationStyle]} />
</TouchableWithoutFeedback>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
box: {
width: 200,
height: 200,
backgroundColor: '#631d94'
}
});
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment