Actions allows you to make it easier to work with features such as "swipe to delete" or "swipe to cart". Also it makes easier to change the UI based on swipe state. No need to manage a list of animated values for all rows. Behavior can be controlled more granular.
With actions both visible and hidden component can react when you swipe a row for some value and show that some action is activated (i.e. expand delete button to full width or highlight button).
To configure actions you can use props below:
leftActivationValue
- TranslateX value for firingonLeftActionStatusChange
(positive number)rightActivationValue
- TranslateX value for firing -onRightActionStatusChange
(negative number)leftActionValue
- TranslateX value for left action to which the row will be shifted after gesture releaserightActionValue
- TranslateX value for right action to which the row will be shifted after gesture releaseinitialLeftActionState
- initial value for left action state (default is false)initialRightActionState
- initial value for right action state (default is false)
To react for actions use handlers:
onLeftAction
- fired when row shifted to -leftActivationValue
onRightAction
- fired when row shifted to -rightActivationValue
onLeftActionStatusChange
- fired once when swipe value reached theleftActivationValue
onRightActionStatusChange
- fired once when swipe value reached therightActivationValue
Also there is an additional props will be passed to Visible and Hidden row components:
swipeAnimatedValue
- swipeRow_translateX
animated valueleftActionActivated
- boolean value indicated that left action is currently activated/deactevatedrightActionActivated
- boolean value indicated that right action is currently activated/deactevatedleftActionState
- boolean value of left action staterightActionState
- boolean value of right action state
See the actions example for reference.