React native 有没有办法管理onPanResponderMove?
您好,我正在使用react native,我有这段代码来管理元素的拖放React native 有没有办法管理onPanResponderMove?,react-native,React Native,您好,我正在使用react native,我有这段代码来管理元素的拖放 this.panResponder = PanResponder.create({ onStartShouldSetPanResponder: () => true, onPanResponderMove : Animated.event([null, { dx: this.state.pan.x, dy: this.state.pan.y }]),
this.panResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onPanResponderMove :
Animated.event([null, {
dx: this.state.pan.x,
dy: this.state.pan.y
}]),
.
.
.
问题是,当我按下按钮时,我希望能够通过onPanResponderMove管理动画事件
差不多
如果我按下一个按钮,然后打开PanResponderMove,这样我就可以使用拖放
我真的不知道我该怎么做。有人有这个的钥匙吗 我不是100%确定,但您可能只需编辑
onStartShouldSetPanResponder:()=>true
。现在它总是返回true
,但正如函数名所说,无论您是否想启用它,您都必须返回
所以解决方案应该是这样的:
onStartShouldSetPanResponder: function () {
return this.state.panResponderEnabled
}
还有一个按钮带有onPress
属性(或类似属性),您可以在该按钮上实际更改状态