You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

HelloWave.tsx 922B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { useEffect } from 'react';
  2. import { StyleSheet } from 'react-native';
  3. import Animated, {
  4. useSharedValue,
  5. useAnimatedStyle,
  6. withTiming,
  7. withRepeat,
  8. withSequence,
  9. } from 'react-native-reanimated';
  10. import { ThemedText } from '@/components/ThemedText';
  11. export function HelloWave() {
  12. const rotationAnimation = useSharedValue(0);
  13. useEffect(() => {
  14. rotationAnimation.value = withRepeat(
  15. withSequence(withTiming(25, { duration: 150 }), withTiming(0, { duration: 150 })),
  16. 4 // Run the animation 4 times
  17. );
  18. }, []);
  19. const animatedStyle = useAnimatedStyle(() => ({
  20. transform: [{ rotate: `${rotationAnimation.value}deg` }],
  21. }));
  22. return (
  23. <Animated.View style={animatedStyle}>
  24. <ThemedText style={styles.text}>👋</ThemedText>
  25. </Animated.View>
  26. );
  27. }
  28. const styles = StyleSheet.create({
  29. text: {
  30. fontSize: 28,
  31. lineHeight: 32,
  32. marginTop: -6,
  33. },
  34. });