Skip to content

Commit 928d8f2

Browse files
committed
Added translateX to swipeGestureEnded method
1 parent 858fdd5 commit 928d8f2

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

components/SwipeListView.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ class SwipeListView extends PureComponent {
8282
}
8383
}
8484

85-
rowSwipeGestureEnded(key) {
85+
rowSwipeGestureEnded(key, data) {
8686
if (this.props.swipeGestureEnded) {
87-
this.props.swipeGestureEnded(key);
87+
this.props.swipeGestureEnded(key, data);
8888
}
8989
}
9090

@@ -183,7 +183,9 @@ class SwipeListView extends PureComponent {
183183
}
184184
ref={row => (this._rows[key] = row)}
185185
swipeGestureBegan={() => this.rowSwipeGestureBegan(key)}
186-
swipeGestureEnded={() => this.rowSwipeGestureEnded(key)}
186+
swipeGestureEnded={data =>
187+
this.rowSwipeGestureEnded(key, data)
188+
}
187189
onRowOpen={toValue => this.onRowOpen(key, toValue)}
188190
onRowDidOpen={toValue =>
189191
this.props.onRowDidOpen &&

components/SwipeRow.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,10 @@ class SwipeRow extends Component {
340340
};
341341

342342
handlePanResponderRelease(e, gestureState) {
343-
this.props.swipeGestureEnded && this.props.swipeGestureEnded();
343+
this.props.swipeGestureEnded &&
344+
this.props.swipeGestureEnded({
345+
translateX: this.currentTranslateX,
346+
});
344347
this.handlePanResponderEnd(e, gestureState);
345348
}
346349

docs/SwipeListView.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ A List that renders `<SwipeRow />`s
3333
| `swipeToOpenVelocityContribution` | Describes how much the ending velocity of the gesture affects whether the swipe will result in the item being closed or open. A velocity factor of 0 (the default) means that the velocity will have no bearing on whether the swipe settles on a closed or open position and it'll just take into consideration the swipeToOpenPercent. Ideal values for this prop tend to be between 5 and 15. | `number` | | `0` |
3434
| `recalculateHiddenLayout` | Enable hidden row onLayout calculations to run always. By default, hidden row size calculations are only done on the first onLayout event for performance reasons. Passing ```true``` here will cause calculations to run on every onLayout event. You may want to do this if your rows' sizes can change. One case is a SwipeListView with rows of different heights and an options to delete rows. | `bool` | | `false` |
3535
| `swipeGestureBegan` | Called when a swipe row is animating swipe | `func` | `{ rowKey: string } : void` |
36-
| `swipeGestureEnded` | Called when user has ended their swipe gesture | `func` | `{ rowKey: string } : void` |
36+
| `swipeGestureEnded` | Called when user has ended their swipe gesture | `func` | `{ rowKey: string, data: { translateX: number; } } : void` |
3737
| `onRowOpen` | Called when a swipe row is animating open. This has a param of `toValue` which is the new X value the row (after it has opened). This can be used to calculate which direction the row has been swiped open. | `func` | `{ rowKey: string, rowMap: { string: SwipeRowRef }, toValue: number } : void` |
3838
| `onRowDidOpen` | Called when a swipe row has animated open | `func` | `{ rowKey: string, rowMap: { string: SwipeRowRef }, toValue: number } : void` |
3939
| `onRowClose` | Called when a swipe row is animating closed | `func` | `{ rowKey: string, rowMap: { string: SwipeRowRef } } : void` |

docs/SwipeRow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ e.g.
5454
| `previewOpenValue` | TranslateX value for the slide out preview animation | `number` | | 0.5 * props.rightOpenValue |
5555
| `onSwipeValueChange` | Callback invoked any time the translateX value of the row changes | `func` | <code>{ swipeData: { key: string, value: number, direction: 'left' &#124; 'right', isOpen: bool } } : void</code> |
5656
| `swipeGestureBegan` | Called when the row is animating swipe | `func` | `{ } : void` |
57-
| `swipeGestureEnded` | Called when user has ended their swipe gesture | `func` | `{ } : void`
57+
| `swipeGestureEnded` | Called when user has ended their swipe gesture | `func` | `{ data: { translateX: number; } } : void`
5858
| `swipeToOpenVelocityContribution` | Describes how much the ending velocity of the gesture affects whether the swipe will result in the item being closed or open. A velocity factor of 0 (the default) means that the velocity will have no bearing on whether the swipe settles on a closed or open position and it'll just take into consideration the swipeToOpenPercent. Ideal values for this prop tend to be between 5 and 15. | `number` | | `0` |
5959
| `shouldItemUpdate` | Callback to determine whether component should update | `func` | `{ currentItem: any, newItem: any }` |
6060
| `forceCloseToLeftThreshold` | TranslateX amount(not value!) threshold that triggers force-closing the row to the Left End (positive number) | `number` |

types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface IPropsSwipeRow<T> {
1414
/**
1515
* Called when user has ended their swipe gesture
1616
*/
17-
swipeGestureEnded(): void;
17+
swipeGestureEnded(data: { translateX: number; }): void;
1818
/**
1919
* Called when a swipe row is animating open. Used by the SwipeListView
2020
* to keep references to open rows.
@@ -327,7 +327,7 @@ interface IPropsSwipeListView<T> {
327327
/**
328328
* Called when user has ended their swipe gesture
329329
*/
330-
swipeGestureEnded(rowKey: string): void;
330+
swipeGestureEnded(rowKey: string, data: { translateX: number; }): void;
331331
/**
332332
* Called when a swipe row is animating open
333333
*/

0 commit comments

Comments
 (0)