Add Hover,Focus,Press docs to REAMDE (#15328)
Nicolas Gallagher committed
Apr 5, 2019 at 03:58 UTC
c3cc936dae776e04d56e40b9062c4c25a666c07d
1 file changed
+141
-1
packages/react-events/README.md
+141
-1
@@ -1,3 +1,143 @@
1
# `react-events`
2
3
-This is package is intended for use with the experimental React events API.
\ No newline at end of file
3
+*This package is experimental. It is intended for use with the experimental React
4
+events API that is not available in open source builds.*
5
+
6
+
7
+## Focus
8
+
9
+The `Focus` module responds to focus and blur events on the element it wraps.
10
+Focus events are dispatched for `mouse`, `pen`, `touch`, and `keyboard`
11
+pointer types.
12
+
13
+```
14
+type FocusEvent = {}
15
+```
16
+
17
+### disabled: boolean
18
+
19
+Disables all `Focus` events.
20
+
21
+### onBlur: (e: FocusEvent) => void
22
+
23
+Called when the element loses focus.
24
+
25
+### onFocus: (e: FocusEvent) => void
26
+
27
+Called when the element gains focus.
28
+
29
+### onFocusChange: boolean => void
30
+
31
+Called when the element changes hover state (i.e., after `onBlur` and
32
+`onFocus`).
33
+
34
+
35
+## Hover
36
+
37
+The `Hover` module responds to hover events on the element it wraps. Hover
38
+events are only dispatched for `mouse` pointer types. Hover begins when the
39
+pointer enters the element's bounds and ends when the pointer leaves.
40
+
41
+```
42
+type HoverEvent = {}
43
+```
44
+
45
+### disabled: boolean
46
+
47
+Disables all `Hover` events.
48
+
49
+### onHoverStart: (e: HoverEvent) => void
50
+
51
+Called once the element is hovered. It will not be called if the pointer leaves
52
+the element before the `delayHoverStart` threshold is exceeded. And it will not
53
+be called more than once before `onHoverEnd` is called.
54
+
55
+### onHoverEnd: (e: HoverEvent) => void
56
+
57
+Called once the element is no longer hovered. It will be cancelled if the
58
+pointer leaves the element before the `delayHoverStart` threshold is exceeded.
59
+
60
+### onHoverChange: boolean => void
61
+
62
+Called when the element changes hover state (i.e., after `onHoverStart` and
63
+`onHoverEnd`).
64
+
65
+### delayHoverStart: number
66
+
67
+The duration of the delay between when hover starts and when `onHoverStart` is
68
+called.
69
+
70
+### delayHoverEnd: number
71
+
72
+The duration of the delay between when hover ends and when `onHoverEnd` is
73
+called.
74
+
75
+
76
+## Press
77
+
78
+The `Press` module responds to press events on the element it wraps. Press
79
+events are dispatched for `mouse`, `pen`, `touch`, and `keyboard` pointer types.
80
+
81
+```
82
+type PressEvent = {}
83
+```
84
+
85
+### disabled: boolean
86
+
87
+Disables all `Press` events.
88
+
89
+### onPressStart: (e: PressEvent) => void
90
+
91
+Called once the element is pressed down. If the press is released before the
92
+`delayPressStart` threshold is exceeded then the delay is cut short and
93
+`onPressStart` is called immediately.
94
+
95
+### onPressEnd: (e: PressEvent) => void
96
+
97
+Called once the element is no longer pressed. It will be cancelled if the press
98
+starts again before the `delayPressEnd` threshold is exceeded.
99
+
100
+### onPressChange: boolean => void
101
+
102
+Called when the element changes press state (i.e., after `onPressStart` and
103
+`onPressEnd`).
104
+
105
+### onLongPress: (e: PressEvent) => void
106
+
107
+Called once the element has been pressed for the length of `delayLongPress`.
108
+
109
+### onLongPressChange: boolean => void
110
+
111
+Called when the element changes long-press state.
112
+
113
+### onLongPressShouldCancelPress: () => boolean
114
+
115
+Determines whether calling `onPress` should be cancelled if `onLongPress` or
116
+`onLongPressChange` have already been called. Default is `false`.
117
+
118
+### onPress: (e: PressEvent) => void
119
+
120
+Called after `onPressEnd` only if `onLongPressShouldCancelPress` returns
121
+`false`.
122
+
123
+### delayPressStart: number
124
+
125
+The duration of a delay between when the press starts and when `onPressStart` is
126
+called. This delay is cut short if the press ends released before the threshold
127
+is exceeded.
128
+
129
+### delayPressEnd: number
130
+
131
+The duration of the delay between when the press ends and when `onPressEnd` is
132
+called.
133
+
134
+### delayLongPress: number = 500ms
135
+
136
+The duration of a press before `onLongPress` and `onLongPressChange` are called.
137
+
138
+### pressRententionOffset: { top: number, right: number, bottom: number, right: number }
139
+
140
+Defines how far the pointer (while held down) may move outside the bounds of the
141
+element before it is deactivated. Once deactivated, the pointer (still held
142
+down) can be moved back within the bounds of the element to reactivate it.
143
+Ensure you pass in a constant to reduce memory allocations.