我是在React Native中使用PanResponder
的新手。我想制作可拖动组件(只能上下移动,因此我仅使用Y值)。在onPanResponderMove
中,我可以通过获得gestureState.dy
来获得Y的实时价值。
接下来,我创建了一个辅助函数,该函数调用onPanResponderRelease
以在关闭触摸时重置所拖动组件的位置。这是代码:
resetPosition() {
Animated.timing(
// Animate value over time
this.position, // The value to drive
{
toValue: { x: 0, y: 0 }, // Animate to final value of 1
duration: 350
},
).start();
}
我的问题是;当组件从上一个位置重置到重置位置时,如何获取实时Y值?