我想在屏幕退出时开始动画制作,但是动画没有开始。我当前正在使用React Navigation
:
const transitionAnimation = () => {
Animated.stagger(100, [
Animated.spring(animation, {
toValue: 0,
tension: 20,
duration: 1000,
useNativeDriver: true,
}),
Animated.timing(logoAnimation, {
toValue: 0,
duration: 1000,
useNativeDriver: true,
})
]).start()
}
useLayoutEffect(() => {
const focusListener = navigation.addListener('willBlur', () => {
transitionAnimation()
})
return () => {
focusListener.remove()
}
}, [])
要将屏幕退出到另一个屏幕:
const onPressHandler = () => {
navigation.navigate('NewScreen')
}