2

我正在制作一个类似火种卡的系统,你可以左右滑动,但现在我想添加一种点击方式。当我添加一个 touchableOpacity 时,我不能再移动它了,因为当我将手指放在它上面时,它会改变视图的不透明度并被阻塞。

基本上我尝试使用 touchableHighlight 但没有任何改变

所以我有 :

<Animated.View>
  <TouchableOpacity>
    //Stuff here
  </TouchableOpacity>
</Animated.View>

我希望卡片仍然能够移动,并且只有在我真的想点击时才触发点击

4

1 回答 1

0

有一个现有的组件 react-native-swipe-gestures 用于处理上下左右方向的滑动手势,请参阅https://github.com/glepur/react-native-swipe-gestures

所以直接不是,但您可以使用以下代码作为参考:

 <GestureRecognizer
        onSwipe={(direction, state) => this.onSwipe(direction, state)}
        onSwipeUp={(state) => this.onSwipeUp(state)}
        onSwipeDown={(state) => this.onSwipeDown(state)}
        onSwipeLeft={(state) => this.onSwipeLeft(state)}
        onSwipeRight={(state) => this.onSwipeRight(state)}
        config={config}
        style={{
          flex: 1,
          backgroundColor: this.state.backgroundColor
        }}
        >
         // enter code here
      </GestureRecognizer>
于 2019-05-19T18:40:55.040 回答