Skip to content

Commit 1de6c73

Browse files
authored
Merge pull request #539 from jemise111/on-preview-end
Add onPreviewEnd prop
2 parents c9bbdc9 + 8277dd7 commit 1de6c73

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

components/SwipeListView.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ class SwipeListView extends PureComponent {
236236
item.leftActionValue || this.props.leftActionValue || 0
237237
}
238238
rightActionValue={
239-
item.rightActionValue || this.props.rightActionValue || 0
239+
item.rightActionValue ||
240+
this.props.rightActionValue ||
241+
0
240242
}
241243
initialLeftActionState={
242244
item.initialLeftActionState ||
@@ -332,6 +334,7 @@ class SwipeListView extends PureComponent {
332334
swipeToClosePercent={this.props.swipeToClosePercent}
333335
item={item} // used for should item update comparisons
334336
useNativeDriver={this.props.useNativeDriver}
337+
onPreviewEnd={this.props.onPreviewEnd}
335338
>
336339
{HiddenComponent}
337340
{VisibleComponent}
@@ -684,6 +687,10 @@ SwipeListView.propTypes = {
684687
* keyExtractor: function to generate key value for each row in the list
685688
*/
686689
keyExtractor: PropTypes.func,
690+
/**
691+
* Callback that runs after row swipe preview is finished
692+
*/
693+
onPreviewEnd: PropTypes.func,
687694
};
688695

689696
SwipeListView.defaultProps = {

components/SwipeRow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ class SwipeRow extends Component {
253253
previewOpenValue,
254254
this.props.previewOpenDelay
255255
).start(() => {
256-
this.getPreviewAnimation(0, PREVIEW_CLOSE_DELAY).start();
256+
this.getPreviewAnimation(0, PREVIEW_CLOSE_DELAY).start(() => {
257+
this.props.onPreviewEnd && this.props.onPreviewEnd();
258+
});
257259
});
258260
}
259261

@@ -910,6 +912,10 @@ SwipeRow.propTypes = {
910912
* Key used to identify rows on swipe value changes
911913
*/
912914
swipeKey: PropTypes.string,
915+
/**
916+
* Callback that runs after row swipe preview is finished
917+
*/
918+
onPreviewEnd: PropTypes.func,
913919
};
914920

915921
SwipeRow.defaultProps = {

docs/SwipeListView.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ A List that renders `<SwipeRow />`s
6262
| `shouldItemUpdate` | Callback to determine whether component should update | `func` | `{ currentItem: any, newItem: any }` |
6363
| `useNativeDriver` | useNativeDriver: `true` for all animations | `bool` | `true` |
6464
| `useAnimatedList` | Use Animated.Flatlist or Animated.Sectionlist | `bool` | `false` |
65+
| `onPreviewEnd` | Callback that runs after row swipe preview is finished | `func` | `{ } : void` |
6566

6667
See [FlatList](https://reactnative.dev/docs/flatlist) for all other inherited props

docs/SwipeRow.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ e.g.
6565
| `onForceCloseToRightEnd` | Callback invoked when row has finished force closing to the Right End | `func` |
6666
| `useNativeDriver` | useNativeDriver: `true` for all animations | `bool` | `true` |
6767
| `swipeKey` | Optional key to identify a standalone row, used in the `onSwipeValueChange` callback | `string` |
68+
| `onPreviewEnd` | Callback that runs after row swipe preview is finished | `func` | `{ } : void` |

0 commit comments

Comments
 (0)