-
Notifications
You must be signed in to change notification settings - Fork 110
/
index.d.ts
91 lines (75 loc) · 4.03 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import React from 'react'
declare type Direction = 'left' | 'right' | 'up' | 'down'
declare type SwipeHandler = (direction: Direction) => void
declare type CardLeftScreenHandler = (direction: Direction) => void
declare type SwipeRequirementFufillUpdate = (direction: Direction) => void
declare type SwipeRequirementUnfufillUpdate = () => void
declare interface API {
/**
* Programmatically trigger a swipe of the card in one of the valid directions `'left'`, `'right'`, `'up'` and `'down'`. This function, `swipe`, can be called on a reference of the TinderCard instance. Check the [example](https://github.com/3DJakob/react-tinder-card-demo/blob/master/src/examples/Advanced.js) code for more details on how to use this.
*
* @param dir The direction in which the card should be swiped. One of: `'left'`, `'right'`, `'up'` and `'down'`.
*/
swipe(dir?: Direction): Promise<void>
/**
* Restore swiped-card state. Use this function if you want to undo a swiped-card (e.g. you have a back button that shows last swiped card or you have a reset button. The promise is resolved once the card is returned
*/
restoreCard (): Promise<void>
}
declare interface Props {
ref?: React.Ref<API>
/**
* Whether or not to let the element be flicked away off-screen after a swipe.
*
* @default true
*/
flickOnSwipe?: boolean
/**
* Callback that will be executed when a swipe has been completed. It will be called with a single string denoting which direction the swipe was in: `'left'`, `'right'`, `'up'` or `'down'`.
*/
onSwipe?: SwipeHandler
/**
* Callback that will be executed when a `TinderCard` has left the screen. It will be called with a single string denoting which direction the swipe was in: `'left'`, `'right'`, `'up'` or `'down'`.
*/
onCardLeftScreen?: CardLeftScreenHandler
/**
* An array of directions for which to prevent swiping out of screen. Valid arguments are `'left'`, `'right'`, `'up'` and `'down'`.
*
* @default []
*/
preventSwipe?: string[]
/**
* What method to evaluate what direction to throw the card on release. 'velocity' will evaluate direction based on the direction of the swiping movement. 'position' will evaluate direction based on the position the card has on the screen like in the app tinder.
* If set to position it is recommended to manually set swipeThreshold based on the screen size as not all devices will accommodate the default distance of 300px and the default native swipeThreshold is 1px which most likely is undesirably low.
*
* @default 'velocity'
*/
swipeRequirementType?: 'velocity' | 'position'
/**
* The threshold of which to accept swipes. If swipeRequirementType is set to velocity it is the velocity threshold and if set to position it is the position threshold.
* On native the default value is 1 as the physics works differently there.
* If swipeRequirementType is set to position it is recommended to set this based on the screen width so cards can be swiped on all screen sizes.
*
* @default 300
*/
swipeThreshold?: number
/**
* Callback that will be executed when a `TinderCard` has fulfilled the requirement necessary to be swiped in a direction on release. This in combination with `onSwipeRequirementUnfulfilled` is useful for displaying user feedback on the card. When using this it is recommended to use `swipeRequirementType='position'` as this will fire a lot otherwise.
* It will be called with a single string denoting which direction the user is swiping: `'left'`, `'right'`, `'up'` or `'down'`.
*/
onSwipeRequirementFulfilled?: SwipeRequirementFufillUpdate
/**
* Callback that will be executed when a `TinderCard` has unfulfilled the requirement necessary to be swiped in a direction on release.
*/
onSwipeRequirementUnfulfilled?: SwipeRequirementUnfufillUpdate
/**
* HTML attribute class
*/
className?: string
/**
* The children passed in is what will be rendered as the actual Tinder-style card.
*/
children?: React.ReactNode
}
declare const TinderCard: React.FC<Props>
export = TinderCard