Created
January 4, 2022 17:37
-
-
Save osama256/f804b08732291094fb9e6518ef1308d2 to your computer and use it in GitHub Desktop.
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 { 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