1.1.1 • Published 7 months ago

react-native-reanimated-swipeable v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

👉 React Native Reanimated Swipeable 💨

A performant and configurable swipeable row using Reanimated and React Native Gesture Handler

Installation

This package has only two dependencies, Reanimated and React Native Gesture Handler. You are likely already using these packages however, and you will be able to use this package even if you are using Expo Go!

npm install react-native-reanimated-swipeable
# or
yarn add react-native-reanimated-swipeable

In favor of allowing this package to be used by Expo Go users, no haptics functionality is included. However, it is highly recommended. Depending on your setup, you can either use Expo Haptics or React Native Haptic Feedback.

Usage

Swipeable

PropType
leftActionGroupISwipeableActionGroup
rightActionGroupISwipeableActionGroup
options?ISwipeableOptions

Options

OptionTypeDefaultDescription
iconPopScalenumber1.2The scale to animate the icon to when the user swipes past a trigger threshold.
onHitStep?() => unknownundefinedThe function to call when the user swipes past a trigger threshold.
animationOptionsSpringConfigSee Spring ConfigThe configuration for the spring animation when closing the row.

Spring Config

OptionTypeDefaultDescription
dampingnumber5The damping of the spring animation.
massnumber1The mass of the spring animation.
stiffnessnumber100The stiffness of the spring animation.
overshootClampingbooleantrueWhether or not to clamp the spring animation.
restSpeedThresholdnumber0.01The speed threshold of the spring animation.
restDisplacementThresholdnumber0.01The displacement threshold of the spring animation.

For more information, see the Reanimated documentation.

Action Group Options

OptionTypeDescription
firstStepISwipeableActionThe first action to display for the side.
secondStepISwipeableActionThe second action to display for the side.

Action Options

OptionTypeDescription
icon() => React.ReactNodeThe icon to display for the action
backgroundColorstringThe background color of the action
triggerThresholdnumberThe threshold in pixels that the user must swipe past in order to trigger the action. This number should always be positive, regardless of which side it is on.
onAction() => unknownThe function to call when the action is pressed. If you do not pass this function, the action will not be pressable.

Example

<Swipeable
  leftActionGroup={{
    firstStep: {
      icon: () => <Icon name="trash" />,
      backgroundColor: 'red',
      triggerThreshold: 50,
      onAction: () => console.log('first step pressed'),
    },
    secondStep: {
      icon: () => <Icon name="archive" />,
      backgroundColor: 'blue',
      triggerThreshold: 100,
      onAction: () => console.log('second step pressed'),
    },
  }}
  rightActionGroup={{
    firstStep: {
      icon: () => <Icon name="trash" />,
      backgroundColor: 'red',
      triggerThreshold: 50,
      onAction: () => console.log('first step pressed'),
    },
    secondStep: {
      icon: () => <Icon name="archive" />,
      backgroundColor: 'blue',
      triggerThreshold: 100,
      onAction: () => console.log('second step pressed'),
    },
  }}
>
  <View style={{ height: 100, width: '100%', backgroundColor: 'green'}}>
    <Text>Hello! I am a row! Give me a quick swipe!</Text>
  </View>
</Swipeable>

Made with create-react-native-library

1.1.1

7 months ago

1.1.0

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago