1 | # react-native-swipe-card
|
2 |
|
3 | 一个支持手势切换的卡片组,支持依次返回切掉的卡片
|
4 |
|
5 | ## Preview
|
6 |
|
7 | ![预览图](./SwipeCard.gif)
|
8 |
|
9 | ## 使用 Demo
|
10 |
|
11 | ```
|
12 | import { CardStack, Card } from '../components/SwipeCard'
|
13 |
|
14 |
|
15 | <CardStack
|
16 | ref={ref => (this.cardStack = ref)}
|
17 | style={styles.container}
|
18 | handleCurCard={this.getCurIndex}
|
19 | renderNoMoreCards={() => <Text>再也没有了!!</Text>}
|
20 | >
|
21 | {clothes.map((cloth, index) => (
|
22 | <Card style={[styles.card]} key={index}>
|
23 | <Image source={cloth} style={{ width: windowWidth - 20, height: 500 }} />
|
24 | </Card>
|
25 | ))}
|
26 | </CardStack>
|
27 | ```
|
28 |
|
29 | ## Props
|
30 |
|
31 | ### CardStack
|
32 | | Props | type | description | required | default |
|
33 | | ------------------- | ------ | -------------------------------------------- | -------- | ------- |
|
34 | | verticalThreshold | number | 垂直方向,滑动距离超过该值时,card才会被移除 | No | |
|
35 | | horizontalThreshold | number | 水平方向,滑动距离超过该值时,card才会被移除 | No | |
|
36 | | renderNoMoreCards | func | 当没有 Card 之后,显示的样式 | No | |
|
37 | | handleCurCard | func | 当切换Card之后,调用该函数 | No | |
|
38 |
|
39 |
|
40 | #### Card
|
41 | | Props | type | description | required | default |
|
42 | | -------- | ------ | ---------------- | -------- | ------- |
|
43 | | style | object | 单个卡片框的样式 | No | |
|
44 | | children | node | 卡片的内容 | Yes | | |
\ | No newline at end of file |