React Native Animated不通过React Navigation Addlistener“ willBlur”触发

时间:2019-12-31 01:38:40

标签: reactjs react-native react-navigation react-animated

我想在屏幕退出时开始动画制作,但是动画没有开始。我当前正在使用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')
    }

0 个答案:

没有答案