在本机反应中向下滑动动画

问题描述

我在 React Native 中使用上下动画,但是动画只是从上到下滑动然后停在底部我想连续上下移动它。我也使用过动画循环,所以请检查并为此提供解决方案

import React,{ useEffect,useState } from 'react'
import { Text,View,Animated,Easing,StyleSheet } from 'react-native'
import LoaderLogo from '../../icons/commonicons/LoaderLogo'
import { Loadericon } from '../../constants/Image';
import LinearGradient from 'react-native-linear-gradient';
import { dynamicSize } from '../sizechoose';

const amimationScreen = () => {
    const startValue = new Animated.Value(0);
    const endValue = dynamicSize(225);

    const startValue2 = new Animated.Value(225);
    const endValue2 = dynamicSize(0);
    const duration = 5000;

    useEffect(() => {

        Animated.sequence([
            Animated.timing(startValue,{
                toValue: endValue,duration: duration,useNativeDriver: true,}),Animated.timing(startValue2,{
                toValue: endValue2,})
        ]).start()

    },[startValue,endValue,duration]);

    return (
        <Animated.View style={[{ transform: [{ translateY: startValue }] }]}>
       <View style={{backgroundColor:'red',height:10,width:100}}>
            </View>
        </Animated.View>
    )
}


export default amimationScreen

我也尝试过使用 react-native-animatable 包,但它不适合我使用,因为它从屏幕顶部开始动画。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)