Skip to content

Commit 575ce18

Browse files
authored
Merge pull request #466 from jemise111/add-close-all-open-rows
Add closeAllOpenRows function
2 parents eae3492 + 47b2d95 commit 575ce18

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

components/SwipeListView.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ class SwipeListView extends PureComponent {
149149
this.props.listViewRef && this.props.listViewRef(ref);
150150
}
151151

152+
closeAllOpenRows() {
153+
Object.keys(this._rows).forEach(rowKey => {
154+
const row = this._rows[rowKey];
155+
const rowTranslateX = Math.round(row.currentTranslateX || 0);
156+
if (row.closeRow && rowTranslateX !== 0) {
157+
row.closeRow();
158+
}
159+
});
160+
}
161+
152162
renderCell(VisibleComponent, HiddenComponent, key, item, shouldPreviewRow) {
153163
if (!HiddenComponent) {
154164
return React.cloneElement(VisibleComponent, {

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,5 +501,6 @@ interface IUseFlatListProps<T> extends FlatListPropsOverride<T>, IPropsSwipeList
501501
}
502502

503503
export class SwipeListView<T> extends Component<Partial<IUseSectionListProps<T>> | Partial<IUseFlatListProps<T>>> {
504+
closeAllOpenRows: () => void;
504505
render(): JSX.Element;
505506
}

0 commit comments

Comments
 (0)