【发布时间】:2019-09-27 08:38:49
【问题描述】:
我正在尝试向当前事件值添加新事件值,而不是替换它们。
此代码将 touchX 和 touchY 值替换为 translationX 和 translationX
Animated.event(
[
{
nativeEvent: {
translationX: this.touchX,
translationY: this.touchY
}
}
],
{
useNativeDriver: false
}
)(event);
我已经厌倦了运行这段代码来实现它
this.touchX.setValue(
Animated.add(this.touchX, new Animated.Value(translationX))
);
this.touchY.setValue(
Animated.add(this.touchY, new Animated.Value(translationY))
);
不幸的是,当尝试将touchX 应用于我的动画组件Transform with key of "translateX" must be a number: {"translateX":"[object Object]0"} 时,这会导致错误
我希望 touchX 在每个事件之后等于 this.touchX + translationX。
【问题讨论】:
标签: javascript react-native animation