Rotate-out — rotate and fade out effect.
Implementation:
1import { Animated } from "react-native";23function RotateOutView({ visible, children }) {4 const rotateAnim = useRef(new Animated.Value(1)).current;5 const fadeAnim = useRef(new Animated.Value(1)).current;67 useEffect(() => {8 Animated.parallel([9 Animated.timing(rotateAnim, {10 toValue: visible ? 1 : 0,11 duration: 300,12 useNativeDriver: true,13 }),14 Animated.timing(fadeAnim, {15 toValue: visible ? 1 : 0,16 duration: 300,17 useNativeDriver: true,18 }),19 ]).start();20 }, [visible]);2122 const rotation = rotateAnim.interpolate({23 inputRange: [0, 1],24 outputRange: ["180deg", "0deg"],25 });2627 return (28 <Animated.View style={{29 opacity: fadeAnim,30 transform: [{ rotate: rotation }],31 }}>32 {children}33 </Animated.View>34 );35}