问题描述
下面的代码是使用Touchable
Transform
渲染一个Animation
按钮。
const { scrollY,headerScrollDistance } = this.state;
const profileImageTranslateX = scrollY.interpolate({
inputRange: [0,headerScrollDistance],outputRange: [0,-(ScreenWidth /2) + 32],extrapolate: 'clamp',});
const profileImageTranslateY = scrollY.interpolate({
inputRange: [0,-11],});
const profileImageScale = scrollY.interpolate({
inputRange: [0,headerScrollDistance / 2,outputRange: [1,0.8,0.6],});
return (
<Animated.View
style={[
Styles.animatedView.profileStyle,{
transform: [
{ translateX: profileImageTranslateX },{ translateY: profileImageTranslateY },{ scale: profileImageScale }
]
}
]}
>
<TouchableOpacity activeOpacity={0.5} onPress={() => this.props.history.push('./profilePhotoChanger')}>
<ImageComp profileImageUrl={profileimageurl} imageStyle={Styles.homePageImageStyle} />
</TouchableOpacity>
</Animated.View>
);
随着页面滚动,Animation
应用于可触摸按钮。不应用变换动画时,按钮将按预期工作。但是在应用动画时不起作用。如果页面返回到正常状态(即向后滚动),则按钮将按预期工作。
应用动画后react-native
TouchableOpacity's
不起作用是onPress
的正常行为吗?还是我的代码有问题?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)