Javascript 如何获取AnimatedInterpolation的值
我的问题是如何在react native中检索AnimatedInterpolation的值,而不调用私有代码 我创建动画值,并将其包裹在插值中,如下所示:Javascript 如何获取AnimatedInterpolation的值,javascript,typescript,react-native,Javascript,Typescript,React Native,我的问题是如何在react native中检索AnimatedInterpolation的值,而不调用私有代码 我创建动画值,并将其包裹在插值中,如下所示: animated = new Animated.Value(); interpolated = this.animated.interpolate({ inputRange:[0, 1000], outputRange:[0, 500] }) 我按如下方式渲染动画: <Animated.View st
animated = new Animated.Value();
interpolated = this.animated.interpolate({
inputRange:[0, 1000],
outputRange:[0, 500]
})
我按如下方式渲染动画:
<Animated.View style={[{width: this.interpolated}]}/>
this.animated.stopAnimation(v => {
console.log(v, " ", this.interpolated.__getValue());
})
可运行的示例
我的问题是,
\uu getValue()
是AnimatedInterpolation的私有成员,在使用typescript时会出现错误。我正在寻找一种声音方式来检索值,类似于this.animated.stopAnimation
比this.animated.\uu getValue()
我不知道为什么animated.value
或animated.AnimatedInterpolation
没有公共\uu getValue()
等价物,或者为什么没有AnimatedInterpolation.addEventListener
方法,类似于Animated.Value.addEventListener
。对于一些效果,例如外部插值器,我还没有找到一种方法来使用\uu getValue
,这让人不安。