检测可触摸可触摸的反馈长新闻稿



我如何检测何时释放longpress(不是通过拖动(。onPressOut确实说了它何时发布,但是当手指从按钮上拖走时,它也会触发。

  <TouchableWithoutFeedback
    onLongPress={() => this.onLongPress()}
    onPressOut={() => this.onCancel()}
    onPressIn={() => this.onHover()}
    onPress={() => this.onPress()}
  >

添加庞大的(比屏幕更大(prestRetentionOffset怎么样?除非您发布,否则这将阻止触摸取消。

<TouchableWithoutFeedback
    ...
    pressRetentionOffset={{ top: 1000, left: 1000, bottom: 1000, right: 1000 }}
>

您确定应该这样做吗?

取消能力 - 在做出操作时,用户应该能够通过将手指拖走

中的中间触发

来自Facebook的最佳实践部分:https://facebook.github.io/reaect-native/docs/gesture-responder-system.html#best-practices

如果您仍然需要这样做,则可能需要使用View.props.onResponderMoveView.props.onResponderRelease

实现自定义触摸

请参阅文档:https://facebook.github.io/reaect-native/docs/gesture-responder-system.html#responder-lifecycle

最新更新