-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Types.js
61 lines (56 loc) · 2.15 KB
/
Types.js
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
/* @flow */
// === basic reused types ===
// type of the second parameter of `spring(val, config)` all fields are optional
export type SpringHelperConfig = {
stiffness?: number,
damping?: number,
precision?: number,
};
// the object returned by `spring(value, yourConfig)`. Used internally only!
export type OpaqueConfig = {
val: number,
stiffness: number,
damping: number,
precision: number,
};
// your typical style object given in props. Maps to a number or a spring config
export type Style = {[key: string]: number | OpaqueConfig};
// the interpolating style object, with the same keys as the above Style object,
// with the values mapped to numbers, naturally
export type PlainStyle = {[key: string]: number};
// internal velocity object. Similar to PlainStyle, but whose numbers represent
// speed. Might be exposed one day.
export type Velocity = {[key: string]: number};
// === Motion ===
export type MotionProps = {
defaultStyle?: PlainStyle,
style: Style,
children: (interpolatedStyle: PlainStyle) => ReactElement,
};
// === StaggeredMotion ===
export type StaggeredProps = {
defaultStyles?: Array<PlainStyle>,
styles: (previousInterpolatedStyles: ?Array<PlainStyle>) => Array<Style>,
children: (interpolatedStyles: Array<PlainStyle>) => ReactElement,
};
// === TransitionMotion ===
export type TransitionStyle = {
key: any, // unique ID to identify component across render animations
data?: any, // optional data you want to carry along the style, e.g. itemText
style: Style, // actual style you're passing
};
export type TransitionPlainStyle = {
key: any,
data?: any,
// same as TransitionStyle, passed as argument to style/children function
style: PlainStyle,
};
export type WillEnter = (styleThatEntered: TransitionStyle) => PlainStyle;
export type WillLeave = (styleThatLeft: TransitionStyle) => ?Style;
export type TransitionProps = {
defaultStyles?: Array<TransitionPlainStyle>,
styles: Array<TransitionStyle> | (previousInterpolatedStyles: ?Array<TransitionPlainStyle>) => Array<TransitionStyle>,
children: (interpolatedStyles: Array<TransitionPlainStyle>) => ReactElement,
willEnter?: WillEnter,
willLeave?: WillLeave,
};