我正在为dx
设置动画以便与TextInput
一起移动,但是当我应用React Native translateY
时,animated
响应一次只键入一个字符。我的意思是,一旦输入了字符,键盘就会关闭。
我正在发生三个动画,而其他动画工作正常:
TextInput
动画的 const [textInputAnimation] = useState(new Animated.Value(0))
useEffect(() => {
Animated.parallel([
Animated.timing(animation, {
toValue: 1,
duration: 800,
useNativeDriver: true,
}),
Animated.timing(textInputAnimation, {
toValue: 1,
duration: 400,
delay: 700,
useNativeDriver: true,
}),
Animated.timing(logoAnimation, {
toValue: 1,
duration: 400,
delay: 900,
useNativeDriver: true,
})
]).start()
}, [])
const translateYInterpolate = textInputAnimation.interpolate({
inputRange: [0, 1],
outputRange: [-50, 0]
})
const animatedOpacity = textInputAnimation.interpolate({
inputRange: [0, 1],
outputRange: [0, 1]
})
const animatedTranslateStyle = {
transform: [
{
translateY: translateYInterpolate
}
],
opacity: animatedOpacity,
}
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
:
TextInput