当我从左侧滑动时如何在本机反应中获得可滑动手势值 下面的代码
<Swipeable
renderLeftActions={LeftActions}
onSwipeableLeftOpen={onSwipeFromLeft}
renderRightActions={(progress, dragX) => (
<RightActions progress={progress} dragX={dragX} onPress=
{onRightPress} />
)}
>
答案 0 :(得分:1)
我使用了react-native-swipe-gestures
(https://github.com/glepur/react-native-swipe-gestures),它在基本的4个方向滑动(上,下,左,右)上提供了良好的支持
您可以这样使用它:
import GestureRecognizer from 'react-native-swipe-gestures';
<GestureRecognizer
onSwipe={swipeHandler}
onSwipeLeft={leftSwipeHandler}
onSwipeRight={rightSwipeHandler}
onSwipeUp={upSwipeHandler}
onSwipeDown={downSwipeHandler}
>
...swipable area...
</GestureRecognizer>
“ onSwipe”方法调用带有参数(gestureName, gestureState)
的函数,并用于所有滑动动作。所有其他一个特定于方向的onSwipe方法都使用gestureState
参数调用函数。
gestureName是您可以用来判断已向哪个方向滑动的基本信息,它可以是以下任意值:SWIPE_UP,SWIPE_DOWN,SWIPE_LEFT,SWIPE_RIGHT和null(对于任何其他类型的滑动)