forked from pmndrs/react-spring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
248 lines (213 loc) · 5.83 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import {
Component,
PureComponent,
ReactNode,
ComponentClass,
ComponentType,
} from 'react'
export type SpringEasingFunc = (t: number) => number
export interface SpringConfig {
tension?: number
friction?: number
velocity?: number
overshootClamping?: number
restSpeedThreshold?: number
restDisplacementThreshold?: number
duration?: number
easing?: SpringEasingFunc
}
type SpringRendererFunc<S extends object, DS extends object = {}> = (
params: DS & S
) => ReactNode
interface SpringProps<S extends object, DS extends object = {}> {
/**
* Spring config ({ tension, friction })
* @default config.default
*/
config?: SpringConfig | ((key: string) => SpringConfig)
/**
* Will skip rendering the component if true and write to the dom directly
* @default false
*/
native?: boolean
/**
* Base styles
* @default {}
*/
from?: DS
/**
* Animates to...
* @default {}
*/
to: DS
/**
* Callback when the animation starts to animate
*/
onStart?: () => void
/**
* Callback when the animation comes to a still-stand
*/
onRest?: () => void
/**
* Frame by frame callback, first argument passed is the animated value
*/
onFrame?: () => void
/**
* Takes a function that receives interpolated styles
*/
children?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
/**
* Same as children, but takes precedence if present
*/
render?: SpringRendererFunc<S, DS>
/**
* Prevents animation if true, you can also pass individual keys
* @default false
*/
immediate?: boolean | string[] | ((key: string) => boolean)
/**
* When true it literally resets: from -> to
* @default false
*/
reset?: boolean
/**
* Animation implementation
* @default SpringAnimation
*/
impl?: any
/**
* Inject props
* @default undefined
*/
inject?: any
}
export const config: {
/** default: { tension: 170, friction: 26 } */
default: SpringConfig
/** gentle: { tension: 120, friction: 14 } */
gentle: SpringConfig
/** wobbly: { tension: 180, friction: 12 } */
wobbly: SpringConfig
/** stiff: { tension: 210, friction: 20 } */
stiff: SpringConfig
/** slow: { tension: 280, friction: 60 } */
slow: SpringConfig
}
export class Spring<S extends object, DS extends object> extends PureComponent<
SpringProps<S, DS>
> {}
export function interpolate(
parent: number[],
config: (...args: number[]) => any
): any
export const animated: {
[Tag in keyof JSX.IntrinsicElements]: ComponentClass<
JSX.IntrinsicElements[Tag]
>
}
type TransitionKeyProps = string | number
type TransitionItemProps = string | number | object
interface TransitionProps<S extends object, DS extends object = {}> {
/**
* Will skip rendering the component if true and write to the dom directly
* @default false
*/
native?: boolean
/**
* Spring config ({ tension, friction })
* @default config.default
*/
config?: SpringConfig | ((key: string) => SpringConfig)
/**
* Base styles
* @default {}
*/
from?: DS
/**
* Animated styles when the component is mounted
* @default {}
*/
enter?: DS
/**
* Unmount styles
* @default {}
*/
leave?: DS
update?: DS
/**
* A collection of unique keys that must match with the childrens order
* Can be omitted if children/render aren't an array
* Can be a function, which then acts as a key-accessor which is useful when you use the items prop
* @default {}
*/
keys?:
| ((params: TransitionItemProps) => TransitionKeyProps)
| Array<TransitionKeyProps>
| TransitionKeyProps
/**
* Optional. Let items refer to the actual data and from/enter/leaver/update can return per-object styles
* @default {}
*/
items?: Array<TransitionItemProps> | TransitionItemProps
children?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
render?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
}
export class Transition<
S extends object,
DS extends object
> extends PureComponent<TransitionProps<S, DS>> {}
type TrailKeyProps = string | number
type TrailKeyItemProps = string | number | object
interface TrailProps<S extends object, DS extends object = {}> {
native?: boolean
config?: SpringConfig | ((key: string) => SpringConfig)
from?: DS
to?: DS
keys?:
| ((params: TrailKeyItemProps) => TrailKeyProps)
| Array<TrailKeyProps>
| TrailKeyProps
children?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
render?: SpringRendererFunc<S, DS> | Array<SpringRendererFunc<S, DS>>
}
export class Trail<S extends object, DS extends object> extends PureComponent<
TrailProps<S, DS>
> {}
interface ParallaxProps<S extends object, DS extends object = {}> {
pages: number
config?: SpringConfig | ((key: string) => SpringConfig)
scrolling?: boolean
horizontal?: boolean
}
export class Parallax<
S extends object,
DS extends object
> extends PureComponent<ParallaxProps<S, DS>> {}
interface ParallaxLayerProps<S extends object, DS extends object = {}> {
factor?: number
offset?: number
speed?: number
}
export class ParallaxLayer<
S extends object,
DS extends object
> extends PureComponent<ParallaxLayerProps<S, DS>> {}
interface KeyframesProps<S extends object, DS extends object = {}> {
state: string
}
export class Keyframes<S extends object, DS extends object> extends Component<
KeyframesProps<S, DS>
> {
static create<S extends object, DS extends object>(
primitive: ComponentType
): (states: object) => (props: object) => Keyframes<S, DS>
static Spring<S extends object, DS extends object>(
states: object
): (props: object) => Keyframes<S, DS>
static Trail<S extends object, DS extends object>(
states: object
): (props: object) => Keyframes<S, DS>
static Transition<S extends object, DS extends object>(
states: object
): (props: object) => Keyframes<S, DS>
}