Skip to content

Commit ea53e88

Browse files
author
Marek Rozmus
committed
Merge branch 'update_readme_and_example'
2 parents c2a2704 + 5ce88ee commit ea53e88

File tree

5 files changed

+83
-28
lines changed

5 files changed

+83
-28
lines changed

.all-contributorsrc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
"imageSize": 100,
66
"commit": false,
77
"contributors": [
8+
{
9+
"login": "sandstreamdevelopment",
10+
"name": "sandstreamdevelopment",
11+
"avatar_url": "https://avatars2.githubusercontent.com/u/44231396?v=4",
12+
"profile": "https://github.com/sandstreamdevelopment",
13+
"contributions": [
14+
"business",
15+
"financial",
16+
"ideas"
17+
]
18+
},
819
{
920
"login": "marekrozmus",
1021
"name": "marekrozmus",
@@ -25,17 +36,6 @@
2536
"review",
2637
"ideas"
2738
]
28-
},
29-
{
30-
"login": "sandstreamdevelopment",
31-
"name": "sandstreamdevelopment",
32-
"avatar_url": "https://avatars2.githubusercontent.com/u/44231396?v=4",
33-
"profile": "https://github.com/sandstreamdevelopment",
34-
"contributions": [
35-
"business",
36-
"financial",
37-
"ideas"
38-
]
3939
}
4040
],
4141
"contributorsPerLine": 7,

README.md

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
1-
# react-swipeable-list
2-
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)
3-
4-
<h3 align="center">
5-
Swipeable list component for React.
6-
</h3>
1+
<h1 align="center">react-swipeable-list</h1>
2+
<h4 align="center" >Swipeable list component for React.</h4>
3+
<div align="center">
4+
<img src="docs/example.gif"></img>
5+
</div>
76

87
<p align="center">
9-
<strong>
10-
<a href="https://sandstreamdev.github.io/react-swipeable-list/">Demo</a>
11-
</strong>
8+
<a href="https://sandstreamdev.github.io/react-swipeable-list/">Demo</a> •
9+
<a href="#installation">Installation</a> •
10+
<a href="#usage">Usage</a> •
11+
<a href="#contributors-">Contributors</a> •
12+
<a href="#license">License</a>
1213
</p>
1314

15+
<hr />
16+
17+
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors)
18+
19+
## React Swipeable List component
20+
21+
A control to render list with swipeable items. Items can have action on left and right swipe. Swipe action triggering can be configured.
22+
1423
## Installation
1524

1625
```bash
@@ -21,7 +30,7 @@ yarn add sandstreamdev/react-swipeable-list
2130

2231
## Usage
2332

24-
```javascript jsx
33+
```jsx
2534
<SwipeableList>
2635
<SwipeableListItem
2736
swipeLeft={{
@@ -38,9 +47,48 @@ yarn add sandstreamdev/react-swipeable-list
3847
</SwipeableList>
3948
```
4049

41-
## License
50+
NOTE: `SwipeableListItem` can be used without `SwipeableList` but swipe blocking on scroll needs to be handled.
4251

43-
[MIT](LICENSE).
52+
## SwipeableList Props
53+
54+
### threshold
55+
56+
Type: `number`
57+
58+
How far swipe needs to be done to trigger attached action. `0.5` means that item needs to be swiped to half of its width, `0.25` - one-quarter of width.
59+
60+
## SwipeableListItem Props
61+
62+
### blockSwipe
63+
64+
Type: `boolean` (default: `false`)
65+
66+
If set to `true` all defined swipe actions are blocked. This is done by `SwipeableList` during scroll to prevent mouse move events to cause accidental swiping acitions.
67+
68+
### swipeLeft
69+
70+
Type: `Object`
71+
72+
Data for defining left swipe action and rendering content after item is swiped. The object requires following structure:
73+
74+
```js
75+
{
76+
action, // required: swipe action (function)
77+
content, // required: HTML or React component
78+
}
79+
```
80+
81+
### swipeRight
82+
83+
Same as `swipeLeft` but to right. :wink:
84+
85+
Type: `Object`
86+
87+
### threshold
88+
89+
Type: `number` (default: `0.5`)
90+
91+
Can be set for whole list or for every item. See `threshold` for `SwipeableList`.
4492

4593
## Contributors ✨
4694

@@ -50,12 +98,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
5098
<!-- prettier-ignore -->
5199
<table>
52100
<tr>
101+
<td align="center"><a href="https://github.com/sandstreamdevelopment"><img src="https://avatars2.githubusercontent.com/u/44231396?v=4" width="100px;" alt="sandstreamdevelopment"/><br /><sub><b>sandstreamdevelopment</b></sub></a><br /><a href="#business-sandstreamdevelopment" title="Business development">💼</a> <a href="#financial-sandstreamdevelopment" title="Financial">💵</a> <a href="#ideas-sandstreamdevelopment" title="Ideas, Planning, & Feedback">🤔</a></td>
53102
<td align="center"><a href="https://github.com/marekrozmus"><img src="https://avatars3.githubusercontent.com/u/26272040?v=4" width="100px;" alt="marekrozmus"/><br /><sub><b>marekrozmus</b></sub></a><br /><a href="https://github.com/sandstreamdev/react-swipeable-list/commits?author=marekrozmus" title="Code">💻</a> <a href="https://github.com/sandstreamdev/react-swipeable-list/commits?author=marekrozmus" title="Documentation">📖</a> <a href="https://github.com/sandstreamdev/react-swipeable-list/commits?author=marekrozmus" title="Tests">⚠️</a></td>
54103
<td align="center"><a href="https://github.com/jakubbogacz"><img src="https://avatars3.githubusercontent.com/u/26272028?v=4" width="100px;" alt="jakubbogacz"/><br /><sub><b>jakubbogacz</b></sub></a><br /><a href="#review-jakubbogacz" title="Reviewed Pull Requests">👀</a> <a href="#ideas-jakubbogacz" title="Ideas, Planning, & Feedback">🤔</a></td>
55-
<td align="center"><a href="https://github.com/sandstreamdevelopment"><img src="https://avatars2.githubusercontent.com/u/44231396?v=4" width="100px;" alt="sandstreamdevelopment"/><br /><sub><b>sandstreamdevelopment</b></sub></a><br /><a href="#business-sandstreamdevelopment" title="Business development">💼</a> <a href="#financial-sandstreamdevelopment" title="Financial">💵</a> <a href="#ideas-sandstreamdevelopment" title="Ideas, Planning, & Feedback">🤔</a></td>
56104
</tr>
57105
</table>
58106

59107
<!-- ALL-CONTRIBUTORS-LIST:END -->
60108

61-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
109+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
110+
111+
## License
112+
113+
[MIT](LICENSE).

docs/example.gif

166 KB
Loading

examples/src/App.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function App() {
6666
<div className={styles.example}>
6767
<h3>react-swipeable-list example</h3>
6868
<h5>(try also mobile view in dev tools for touch events)</h5>
69-
<h3>Simple example</h3>
69+
<h3>Simple example (with default 0.5 action trigger threshold)</h3>
7070
<span className={styles.actionInfo}>{triggeredSimpleItemAction}</span>
7171
<div className={styles.listContainer}>
7272
<SwipeableList>
@@ -91,10 +91,12 @@ function App() {
9191
</SwipeableListItem>
9292
</SwipeableList>
9393
</div>
94-
<h3>More complex items and scroll</h3>
94+
<h3>
95+
More complex items and scroll (with 0.25 action trigger threshold)
96+
</h3>
9597
<span className={styles.actionInfo}>{triggeredComplexItemAction}</span>
9698
<div className={styles.complexListContainer}>
97-
<SwipeableList>
99+
<SwipeableList threshold={0.25}>
98100
<SwipeableListItem
99101
swipeLeft={swipeLeftDataComplex('First')}
100102
swipeRight={swipeRightDataComplex('First')}

examples/src/app.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ html {
44

55
h3 {
66
margin-bottom: 0;
7+
text-align: center;
78
}
89

910
body,

0 commit comments

Comments
 (0)