import { Animated, StyleSheet, Text, View } from "react-native";
import React, { useEffect, useState } from "react";


let translateX;
let width = null
let tranx = null
export default function TestCom() {

  // const [widthAni,setWidthAni] = useState(new Animated.Value(0))

  // let translateY

  const animation = new Animated.Value(0);
  

  Animated.timing(animation, {
    toValue: 1,
    duration: 1000,
    useNativeDriver: false,
  }).start();

  width = animation.interpolate({
    inputRange:[0,1],
    
    outputRange:[260,60]
  })

  tranx = animation.interpolate({
    inputRange:[0,1],
    
    outputRange:[20,260]
  })




  useEffect(() => {
    // initAni()

  }, []);

  return (
    <View>
      <Text>Test</Text>

      <Animated.View style={[styles.box,{ transform: [{translateX:tranx}], width }]}></Animated.View>


    </View>
  );
}

const styles = StyleSheet.create({

  box: {
    height: 60,
    borderRadius: 30,
    backgroundColor: "#deb",
    marginTop: 50,
  },
});

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐