Skip to content

Commit f71efa5

Browse files
authored
[README] Include OpenDirection enum
1 parent 2bac1a6 commit f71efa5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ type RenderOverlay<T> = (params: {
3131
openRight: () => Promise<void>;
3232
close: () => Promise<void>;
3333
}) => React.ReactNode;
34+
35+
enum OpenDirection {
36+
LEFT = "left",
37+
RIGHT = "right",
38+
NONE = 0
39+
}
3440
```
3541

3642
| Name | Type | Description |
@@ -40,15 +46,15 @@ type RenderOverlay<T> = (params: {
4046
| `underlayWidthLeft` | `number` | Width of left-swiped underlay. |
4147
| `underlayWidthRight` | `number` | Width of right-swiped underlay. |
4248
| `renderOverlay` | `RenderOverlay` | Component to be rendered on top. Use if you need access to programmatic open/close methods. May altenatively pass children to SwipeableItem. |
43-
| `onChange` | `(params: { open: "left" \| "right" \| "null" }) => void` | Called when row is opened or closed. |
49+
| `onChange` | `(params: { open: OpenDirection }) => void` | Called when row is opened or closed. |
4450
| `swipeEnabled` | `boolean` | Enable/disable swipe. Defaults to `true`. |
4551
| `activationThreshold` | `number` | Distance finger must travel before swipe engages. Defaults to 20. |
4652

4753
### Instance Methods
4854

4955
| Name | Type | Description |
5056
| :------ | :------------------------------------- | :--------------------------------------------------------------- |
51-
| `open` | `("left" \| "right") => Promise<void>` | Programmatically open left or right. Promise resolves once open. |
57+
| `open` | `(OpenDirection.LEFT \| OpenDirection.RIGHT) => Promise<void>` | Programmatically open left or right. Promise resolves once open. |
5258
| `close` | `() => Promise<void>` | Close all. Promise resolves once closed. |
5359

5460
```js
@@ -60,7 +66,7 @@ const itemRef: SwipeableItem | null = null
6066
<SwipeableItem ref={ref => itemRef = ref} />
6167

6268
...
63-
if (itemRef) itemRef.open("left")
69+
if (itemRef) itemRef.open(OpenDirection.LEFT)
6470
```
6571

6672
### Notes

0 commit comments

Comments
 (0)