@tamagui/react-native-use-responder-events 1.61.2 → 1.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ResponderSystem.js +75 -243
- package/dist/cjs/ResponderSystem.js.map +1 -1
- package/dist/cjs/ResponderSystem.native.js +222 -0
- package/dist/cjs/ResponderSystem.native.js.map +6 -0
- package/dist/cjs/ResponderTouchHistoryStore.js +48 -115
- package/dist/cjs/ResponderTouchHistoryStore.js.map +1 -1
- package/dist/cjs/ResponderTouchHistoryStore.native.js +124 -0
- package/dist/cjs/ResponderTouchHistoryStore.native.js.map +6 -0
- package/dist/cjs/createResponderEvent.js +33 -61
- package/dist/cjs/createResponderEvent.js.map +1 -1
- package/dist/cjs/createResponderEvent.native.js +122 -0
- package/dist/cjs/createResponderEvent.native.js.map +6 -0
- package/dist/cjs/index.js +4 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +20 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.js +6 -23
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/types.native.js +82 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/cjs/useResponderEvents.js +18 -44
- package/dist/cjs/useResponderEvents.js.map +1 -1
- package/dist/cjs/useResponderEvents.native.js +56 -0
- package/dist/cjs/useResponderEvents.native.js.map +6 -0
- package/dist/cjs/utils.js +36 -95
- package/dist/cjs/utils.js.map +1 -1
- package/dist/cjs/utils.native.js +116 -0
- package/dist/cjs/utils.native.js.map +6 -0
- package/dist/esm/ResponderSystem.js +67 -225
- package/dist/esm/ResponderSystem.js.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.js +43 -106
- package/dist/esm/ResponderTouchHistoryStore.js.map +1 -1
- package/dist/esm/createResponderEvent.js +28 -52
- package/dist/esm/createResponderEvent.js.map +1 -1
- package/dist/esm/types.js +1 -14
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/useResponderEvents.js +9 -26
- package/dist/esm/useResponderEvents.js.map +1 -1
- package/dist/esm/utils.js +31 -86
- package/dist/esm/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -17,34 +17,26 @@ import {
|
|
|
17
17
|
isPrimaryPointerDown,
|
|
18
18
|
setResponderId
|
|
19
19
|
} from "./utils";
|
|
20
|
-
const emptyObject = {}
|
|
21
|
-
const startRegistration = [
|
|
20
|
+
const emptyObject = {}, startRegistration = [
|
|
22
21
|
"onStartShouldSetResponderCapture",
|
|
23
22
|
"onStartShouldSetResponder",
|
|
24
|
-
{ bubbles:
|
|
25
|
-
]
|
|
26
|
-
const moveRegistration = [
|
|
23
|
+
{ bubbles: !0 }
|
|
24
|
+
], moveRegistration = [
|
|
27
25
|
"onMoveShouldSetResponderCapture",
|
|
28
26
|
"onMoveShouldSetResponder",
|
|
29
|
-
{ bubbles:
|
|
30
|
-
]
|
|
31
|
-
const scrollRegistration = [
|
|
27
|
+
{ bubbles: !0 }
|
|
28
|
+
], scrollRegistration = [
|
|
32
29
|
"onScrollShouldSetResponderCapture",
|
|
33
30
|
"onScrollShouldSetResponder",
|
|
34
|
-
{ bubbles:
|
|
35
|
-
]
|
|
36
|
-
const shouldSetResponderEvents = {
|
|
31
|
+
{ bubbles: !1 }
|
|
32
|
+
], shouldSetResponderEvents = {
|
|
37
33
|
touchstart: startRegistration,
|
|
38
34
|
mousedown: startRegistration,
|
|
39
35
|
touchmove: moveRegistration,
|
|
40
36
|
mousemove: moveRegistration,
|
|
41
37
|
scroll: scrollRegistration
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const responderListenersMap = /* @__PURE__ */ new Map();
|
|
45
|
-
let isEmulatingMouseEvents = false;
|
|
46
|
-
let trackedTouchCount = 0;
|
|
47
|
-
let currentResponder = {
|
|
38
|
+
}, emptyResponder = { id: null, idPath: null, node: null }, responderListenersMap = /* @__PURE__ */ new Map();
|
|
39
|
+
let isEmulatingMouseEvents = !1, trackedTouchCount = 0, currentResponder = {
|
|
48
40
|
id: null,
|
|
49
41
|
node: null,
|
|
50
42
|
idPath: null
|
|
@@ -55,84 +47,44 @@ function changeCurrentResponder(responder) {
|
|
|
55
47
|
}
|
|
56
48
|
function getResponderConfig(id) {
|
|
57
49
|
const config = responderListenersMap.get(id);
|
|
58
|
-
return config
|
|
50
|
+
return config ?? emptyObject;
|
|
59
51
|
}
|
|
60
52
|
function eventListener(domEvent) {
|
|
61
|
-
const eventType = domEvent.type;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
if (eventType === "touchmove" || trackedTouchCount > 1) {
|
|
67
|
-
isEmulatingMouseEvents = false;
|
|
68
|
-
}
|
|
69
|
-
if (
|
|
70
|
-
// Ignore browser emulated mouse events
|
|
71
|
-
eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents || // Ignore mousemove if a mousedown didn't occur first
|
|
72
|
-
eventType === "mousemove" && trackedTouchCount < 1
|
|
73
|
-
) {
|
|
53
|
+
const eventType = domEvent.type, eventTarget = domEvent.target;
|
|
54
|
+
if (eventType === "touchstart" && (isEmulatingMouseEvents = !0), (eventType === "touchmove" || trackedTouchCount > 1) && (isEmulatingMouseEvents = !1), // Ignore browser emulated mouse events
|
|
55
|
+
eventType === "mousedown" && isEmulatingMouseEvents || eventType === "mousemove" && isEmulatingMouseEvents || // Ignore mousemove if a mousedown didn't occur first
|
|
56
|
+
eventType === "mousemove" && trackedTouchCount < 1)
|
|
74
57
|
return;
|
|
75
|
-
}
|
|
76
58
|
if (isEmulatingMouseEvents && eventType === "mouseup") {
|
|
77
|
-
|
|
78
|
-
isEmulatingMouseEvents = false;
|
|
79
|
-
}
|
|
59
|
+
trackedTouchCount === 0 && (isEmulatingMouseEvents = !1);
|
|
80
60
|
return;
|
|
81
61
|
}
|
|
82
|
-
const isStartEvent = isStartish(eventType) && isPrimaryPointerDown(domEvent);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (isStartEvent || isMoveEvent || isEndEvent) {
|
|
89
|
-
if (domEvent.touches) {
|
|
90
|
-
trackedTouchCount = domEvent.touches.length;
|
|
91
|
-
} else {
|
|
92
|
-
if (isStartEvent) {
|
|
93
|
-
trackedTouchCount = 1;
|
|
94
|
-
} else if (isEndEvent) {
|
|
95
|
-
trackedTouchCount = 0;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
responderTouchHistoryStore.recordTouchTrack(
|
|
99
|
-
eventType,
|
|
100
|
-
responderEvent.nativeEvent
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
let eventPaths = getResponderPaths(domEvent);
|
|
104
|
-
let wasNegotiated = false;
|
|
105
|
-
let wantsResponder;
|
|
62
|
+
const isStartEvent = isStartish(eventType) && isPrimaryPointerDown(domEvent), isMoveEvent = isMoveish(eventType), isEndEvent = isEndish(eventType), isScrollEvent = isScroll(eventType), isSelectionChangeEvent = isSelectionChange(eventType), responderEvent = createResponderEvent(domEvent, responderTouchHistoryStore);
|
|
63
|
+
(isStartEvent || isMoveEvent || isEndEvent) && (domEvent.touches ? trackedTouchCount = domEvent.touches.length : isStartEvent ? trackedTouchCount = 1 : isEndEvent && (trackedTouchCount = 0), responderTouchHistoryStore.recordTouchTrack(
|
|
64
|
+
eventType,
|
|
65
|
+
responderEvent.nativeEvent
|
|
66
|
+
));
|
|
67
|
+
let eventPaths = getResponderPaths(domEvent), wasNegotiated = !1, wantsResponder;
|
|
106
68
|
if (isStartEvent || isMoveEvent || isScrollEvent && trackedTouchCount > 0) {
|
|
107
|
-
const currentResponderIdPath = currentResponder.idPath;
|
|
108
|
-
const eventIdPath = eventPaths.idPath;
|
|
69
|
+
const currentResponderIdPath = currentResponder.idPath, eventIdPath = eventPaths.idPath;
|
|
109
70
|
if (currentResponderIdPath != null && eventIdPath != null) {
|
|
110
71
|
const lowestCommonAncestor = getLowestCommonAncestor(
|
|
111
72
|
currentResponderIdPath,
|
|
112
73
|
eventIdPath
|
|
113
74
|
);
|
|
114
75
|
if (lowestCommonAncestor != null) {
|
|
115
|
-
const
|
|
116
|
-
const index = indexOfLowestCommonAncestor + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
76
|
+
const index = eventIdPath.indexOf(lowestCommonAncestor) + (lowestCommonAncestor === currentResponder.id ? 1 : 0);
|
|
117
77
|
eventPaths = {
|
|
118
78
|
idPath: eventIdPath.slice(index),
|
|
119
79
|
nodePath: eventPaths.nodePath.slice(index)
|
|
120
80
|
};
|
|
121
|
-
} else
|
|
81
|
+
} else
|
|
122
82
|
eventPaths = null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (eventPaths != null) {
|
|
126
|
-
wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent);
|
|
127
|
-
if (wantsResponder != null) {
|
|
128
|
-
attemptTransfer(responderEvent, wantsResponder);
|
|
129
|
-
wasNegotiated = true;
|
|
130
|
-
}
|
|
131
83
|
}
|
|
84
|
+
eventPaths != null && (wantsResponder = findWantsResponder(eventPaths, domEvent, responderEvent), wantsResponder != null && (attemptTransfer(responderEvent, wantsResponder), wasNegotiated = !0));
|
|
132
85
|
}
|
|
133
86
|
if (currentResponder.id != null && currentResponder.node != null) {
|
|
134
|
-
const { id, node } = currentResponder
|
|
135
|
-
const {
|
|
87
|
+
const { id, node } = currentResponder, {
|
|
136
88
|
onResponderStart,
|
|
137
89
|
onResponderMove,
|
|
138
90
|
onResponderEnd,
|
|
@@ -140,62 +92,21 @@ function eventListener(domEvent) {
|
|
|
140
92
|
onResponderTerminate,
|
|
141
93
|
onResponderTerminationRequest
|
|
142
94
|
} = getResponderConfig(id);
|
|
143
|
-
responderEvent.bubbles =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
responderEvent.dispatchConfig.registrationName = "onResponderStart";
|
|
149
|
-
onResponderStart(responderEvent);
|
|
150
|
-
}
|
|
151
|
-
} else if (isMoveEvent) {
|
|
152
|
-
if (onResponderMove != null) {
|
|
153
|
-
responderEvent.dispatchConfig.registrationName = "onResponderMove";
|
|
154
|
-
onResponderMove(responderEvent);
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
95
|
+
if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, isStartEvent)
|
|
96
|
+
onResponderStart != null && (responderEvent.dispatchConfig.registrationName = "onResponderStart", onResponderStart(responderEvent));
|
|
97
|
+
else if (isMoveEvent)
|
|
98
|
+
onResponderMove != null && (responderEvent.dispatchConfig.registrationName = "onResponderMove", onResponderMove(responderEvent));
|
|
99
|
+
else {
|
|
157
100
|
const isTerminateEvent = isCancelish(eventType) || // native context menu
|
|
158
101
|
eventType === "contextmenu" || // window blur
|
|
159
102
|
eventType === "blur" && eventTarget === window || // responder (or ancestors) blur
|
|
160
103
|
eventType === "blur" && eventTarget.contains(node) && domEvent.relatedTarget !== node || // native scroll without using a pointer
|
|
161
104
|
isScrollEvent && trackedTouchCount === 0 || // native scroll on node that is parent of the responder (allow siblings to scroll)
|
|
162
105
|
isScrollEvent && eventTarget.contains(node) && eventTarget !== node || // native select/selectionchange on node
|
|
163
|
-
isSelectionChangeEvent && hasValidSelection(domEvent);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
responderEvent.dispatchConfig.registrationName = "onResponderEnd";
|
|
168
|
-
onResponderEnd(responderEvent);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (isReleaseEvent) {
|
|
172
|
-
if (onResponderRelease != null) {
|
|
173
|
-
responderEvent.dispatchConfig.registrationName = "onResponderRelease";
|
|
174
|
-
onResponderRelease(responderEvent);
|
|
175
|
-
}
|
|
176
|
-
changeCurrentResponder(emptyResponder);
|
|
177
|
-
}
|
|
178
|
-
if (isTerminateEvent) {
|
|
179
|
-
let shouldTerminate = true;
|
|
180
|
-
if (eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") {
|
|
181
|
-
if (wasNegotiated) {
|
|
182
|
-
shouldTerminate = false;
|
|
183
|
-
} else if (onResponderTerminationRequest != null) {
|
|
184
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest";
|
|
185
|
-
if (onResponderTerminationRequest(responderEvent) === false) {
|
|
186
|
-
shouldTerminate = false;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (shouldTerminate) {
|
|
191
|
-
if (onResponderTerminate != null) {
|
|
192
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminate";
|
|
193
|
-
onResponderTerminate(responderEvent);
|
|
194
|
-
}
|
|
195
|
-
changeCurrentResponder(emptyResponder);
|
|
196
|
-
isEmulatingMouseEvents = false;
|
|
197
|
-
trackedTouchCount = 0;
|
|
198
|
-
}
|
|
106
|
+
isSelectionChangeEvent && hasValidSelection(domEvent), isReleaseEvent = isEndEvent && !isTerminateEvent && !hasTargetTouches(node, domEvent.touches);
|
|
107
|
+
if (isEndEvent && onResponderEnd != null && (responderEvent.dispatchConfig.registrationName = "onResponderEnd", onResponderEnd(responderEvent)), isReleaseEvent && (onResponderRelease != null && (responderEvent.dispatchConfig.registrationName = "onResponderRelease", onResponderRelease(responderEvent)), changeCurrentResponder(emptyResponder)), isTerminateEvent) {
|
|
108
|
+
let shouldTerminate = !0;
|
|
109
|
+
(eventType === "contextmenu" || eventType === "scroll" || eventType === "selectionchange") && (wasNegotiated ? shouldTerminate = !1 : onResponderTerminationRequest != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (shouldTerminate = !1))), shouldTerminate && (onResponderTerminate != null && (responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), changeCurrentResponder(emptyResponder), isEmulatingMouseEvents = !1, trackedTouchCount = 0);
|
|
199
110
|
}
|
|
200
111
|
}
|
|
201
112
|
}
|
|
@@ -203,101 +114,46 @@ function eventListener(domEvent) {
|
|
|
203
114
|
function findWantsResponder(eventPaths, domEvent, responderEvent) {
|
|
204
115
|
const shouldSetCallbacks = shouldSetResponderEvents[domEvent.type];
|
|
205
116
|
if (shouldSetCallbacks != null) {
|
|
206
|
-
const { idPath, nodePath } = eventPaths
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
const config = getResponderConfig(id);
|
|
212
|
-
const shouldSetCallback = config[callbackName];
|
|
213
|
-
if (shouldSetCallback != null) {
|
|
214
|
-
responderEvent.currentTarget = node;
|
|
215
|
-
if (shouldSetCallback(responderEvent) === true) {
|
|
216
|
-
const prunedIdPath = idPath.slice(idPath.indexOf(id));
|
|
217
|
-
return { id, node, idPath: prunedIdPath };
|
|
218
|
-
}
|
|
117
|
+
const { idPath, nodePath } = eventPaths, shouldSetCallbackCaptureName = shouldSetCallbacks[0], shouldSetCallbackBubbleName = shouldSetCallbacks[1], { bubbles } = shouldSetCallbacks[2], check = function(id, node, callbackName) {
|
|
118
|
+
const shouldSetCallback = getResponderConfig(id)[callbackName];
|
|
119
|
+
if (shouldSetCallback != null && (responderEvent.currentTarget = node, shouldSetCallback(responderEvent) === !0)) {
|
|
120
|
+
const prunedIdPath = idPath.slice(idPath.indexOf(id));
|
|
121
|
+
return { id, node, idPath: prunedIdPath };
|
|
219
122
|
}
|
|
220
123
|
};
|
|
221
124
|
for (let i = idPath.length - 1; i >= 0; i--) {
|
|
222
|
-
const id = idPath[i];
|
|
223
|
-
|
|
224
|
-
const result = check(id, node, shouldSetCallbackCaptureName);
|
|
225
|
-
if (result != null) {
|
|
125
|
+
const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackCaptureName);
|
|
126
|
+
if (result != null)
|
|
226
127
|
return result;
|
|
227
|
-
|
|
228
|
-
if (responderEvent.isPropagationStopped() === true) {
|
|
128
|
+
if (responderEvent.isPropagationStopped() === !0)
|
|
229
129
|
return;
|
|
230
|
-
}
|
|
231
130
|
}
|
|
232
|
-
if (bubbles)
|
|
131
|
+
if (bubbles)
|
|
233
132
|
for (let i = 0; i < idPath.length; i++) {
|
|
234
|
-
const id = idPath[i];
|
|
235
|
-
|
|
236
|
-
const result = check(id, node, shouldSetCallbackBubbleName);
|
|
237
|
-
if (result != null) {
|
|
133
|
+
const id = idPath[i], node = nodePath[i], result = check(id, node, shouldSetCallbackBubbleName);
|
|
134
|
+
if (result != null)
|
|
238
135
|
return result;
|
|
239
|
-
|
|
240
|
-
if (responderEvent.isPropagationStopped() === true) {
|
|
136
|
+
if (responderEvent.isPropagationStopped() === !0)
|
|
241
137
|
return;
|
|
242
|
-
}
|
|
243
138
|
}
|
|
244
|
-
|
|
245
|
-
const id = idPath[0];
|
|
246
|
-
|
|
247
|
-
const target = domEvent.target;
|
|
248
|
-
if (target === node) {
|
|
139
|
+
else {
|
|
140
|
+
const id = idPath[0], node = nodePath[0];
|
|
141
|
+
if (domEvent.target === node)
|
|
249
142
|
return check(id, node, shouldSetCallbackBubbleName);
|
|
250
|
-
}
|
|
251
143
|
}
|
|
252
144
|
}
|
|
253
145
|
}
|
|
254
146
|
function attemptTransfer(responderEvent, wantsResponder) {
|
|
255
|
-
const { id: currentId, node: currentNode } = currentResponder;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
responderEvent.cancelable = false;
|
|
260
|
-
responderEvent.currentTarget = node;
|
|
261
|
-
if (currentId == null) {
|
|
262
|
-
if (onResponderGrant != null) {
|
|
263
|
-
responderEvent.currentTarget = node;
|
|
264
|
-
responderEvent.dispatchConfig.registrationName = "onResponderGrant";
|
|
265
|
-
onResponderGrant(responderEvent);
|
|
266
|
-
}
|
|
267
|
-
changeCurrentResponder(wantsResponder);
|
|
268
|
-
} else {
|
|
147
|
+
const { id: currentId, node: currentNode } = currentResponder, { id, node } = wantsResponder, { onResponderGrant, onResponderReject } = getResponderConfig(id);
|
|
148
|
+
if (responderEvent.bubbles = !1, responderEvent.cancelable = !1, responderEvent.currentTarget = node, currentId == null)
|
|
149
|
+
onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder);
|
|
150
|
+
else {
|
|
269
151
|
const { onResponderTerminate, onResponderTerminationRequest } = getResponderConfig(currentId);
|
|
270
|
-
let allowTransfer =
|
|
271
|
-
|
|
272
|
-
responderEvent.currentTarget = currentNode;
|
|
273
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest";
|
|
274
|
-
if (onResponderTerminationRequest(responderEvent) === false) {
|
|
275
|
-
allowTransfer = false;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
if (allowTransfer) {
|
|
279
|
-
if (onResponderTerminate != null) {
|
|
280
|
-
responderEvent.currentTarget = currentNode;
|
|
281
|
-
responderEvent.dispatchConfig.registrationName = "onResponderTerminate";
|
|
282
|
-
onResponderTerminate(responderEvent);
|
|
283
|
-
}
|
|
284
|
-
if (onResponderGrant != null) {
|
|
285
|
-
responderEvent.currentTarget = node;
|
|
286
|
-
responderEvent.dispatchConfig.registrationName = "onResponderGrant";
|
|
287
|
-
onResponderGrant(responderEvent);
|
|
288
|
-
}
|
|
289
|
-
changeCurrentResponder(wantsResponder);
|
|
290
|
-
} else {
|
|
291
|
-
if (onResponderReject != null) {
|
|
292
|
-
responderEvent.currentTarget = node;
|
|
293
|
-
responderEvent.dispatchConfig.registrationName = "onResponderReject";
|
|
294
|
-
onResponderReject(responderEvent);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
152
|
+
let allowTransfer = !0;
|
|
153
|
+
onResponderTerminationRequest != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminationRequest", onResponderTerminationRequest(responderEvent) === !1 && (allowTransfer = !1)), allowTransfer ? (onResponderTerminate != null && (responderEvent.currentTarget = currentNode, responderEvent.dispatchConfig.registrationName = "onResponderTerminate", onResponderTerminate(responderEvent)), onResponderGrant != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderGrant", onResponderGrant(responderEvent)), changeCurrentResponder(wantsResponder)) : onResponderReject != null && (responderEvent.currentTarget = node, responderEvent.dispatchConfig.registrationName = "onResponderReject", onResponderReject(responderEvent));
|
|
297
154
|
}
|
|
298
155
|
}
|
|
299
|
-
const documentEventsCapturePhase = ["blur", "scroll"]
|
|
300
|
-
const documentEventsBubblePhase = [
|
|
156
|
+
const documentEventsCapturePhase = ["blur", "scroll"], documentEventsBubblePhase = [
|
|
301
157
|
// mouse
|
|
302
158
|
"mousedown",
|
|
303
159
|
"mousemove",
|
|
@@ -312,31 +168,19 @@ const documentEventsBubblePhase = [
|
|
|
312
168
|
"contextmenu",
|
|
313
169
|
"select",
|
|
314
170
|
"selectionchange"
|
|
315
|
-
];
|
|
316
|
-
const isTamaguiResponderActive = Symbol();
|
|
171
|
+
], isTamaguiResponderActive = Symbol();
|
|
317
172
|
function attachListeners() {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
documentEventsCapturePhase.forEach((eventType) => {
|
|
324
|
-
document.addEventListener(eventType, eventListener, true);
|
|
325
|
-
});
|
|
326
|
-
window[isTamaguiResponderActive] = true;
|
|
327
|
-
}
|
|
173
|
+
canUseDOM && !window[isTamaguiResponderActive] && (window.addEventListener("blur", eventListener), documentEventsBubblePhase.forEach((eventType) => {
|
|
174
|
+
document.addEventListener(eventType, eventListener);
|
|
175
|
+
}), documentEventsCapturePhase.forEach((eventType) => {
|
|
176
|
+
document.addEventListener(eventType, eventListener, !0);
|
|
177
|
+
}), window[isTamaguiResponderActive] = !0);
|
|
328
178
|
}
|
|
329
179
|
function addNode(id, node, config) {
|
|
330
|
-
setResponderId(node, id);
|
|
331
|
-
responderListenersMap.set(id, config);
|
|
180
|
+
setResponderId(node, id), responderListenersMap.set(id, config);
|
|
332
181
|
}
|
|
333
182
|
function removeNode(id) {
|
|
334
|
-
|
|
335
|
-
terminateResponder();
|
|
336
|
-
}
|
|
337
|
-
if (responderListenersMap.has(id)) {
|
|
338
|
-
responderListenersMap.delete(id);
|
|
339
|
-
}
|
|
183
|
+
currentResponder.id === id && terminateResponder(), responderListenersMap.has(id) && responderListenersMap.delete(id);
|
|
340
184
|
}
|
|
341
185
|
function terminateResponder() {
|
|
342
186
|
const { id, node } = currentResponder;
|
|
@@ -344,13 +188,11 @@ function terminateResponder() {
|
|
|
344
188
|
const { onResponderTerminate } = getResponderConfig(id);
|
|
345
189
|
if (onResponderTerminate != null) {
|
|
346
190
|
const event = createResponderEvent({}, responderTouchHistoryStore);
|
|
347
|
-
event.currentTarget = node;
|
|
348
|
-
onResponderTerminate(event);
|
|
191
|
+
event.currentTarget = node, onResponderTerminate(event);
|
|
349
192
|
}
|
|
350
193
|
changeCurrentResponder(emptyResponder);
|
|
351
194
|
}
|
|
352
|
-
isEmulatingMouseEvents =
|
|
353
|
-
trackedTouchCount = 0;
|
|
195
|
+
isEmulatingMouseEvents = !1, trackedTouchCount = 0;
|
|
354
196
|
}
|
|
355
197
|
function getResponderNode() {
|
|
356
198
|
return currentResponder.node;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ResponderSystem.ts"],
|
|
4
|
-
"mappings": "AAOA,OAAO,0BAA0B;AACjC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4CP,MAAM,cAAc,CAAC
|
|
4
|
+
"mappings": "AAOA,OAAO,0BAA0B;AACjC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B;AAAA,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,KAAK,IAAI;AACrB,MAAI,MAAM,QAAQ,QAAQ,MAAM;AAC9B,UAAM,EAAE,qBAAqB,IAAI,mBAAmB,EAAE;AACtD,QAAI,wBAAwB,MAAM;AAChC,YAAM,QAAQ,qBAAqB,CAAC,GAAG,0BAA0B;AACjE,YAAM,gBAAgB,MACtB,qBAAqB,KAAK;AAAA,IAC5B;AACA,2BAAuB,cAAc;AAAA,EACvC;AACA,2BAAyB,IACzB,oBAAoB;AACtB;AAMO,SAAS,mBAAwB;AACtC,SAAO,iBAAiB;AAC1B;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isEndish, isMoveish, isStartish } from "./types";
|
|
2
2
|
const MAX_TOUCH_BANK = 20;
|
|
3
3
|
function timestampForTouch(touch) {
|
|
4
|
-
return touch
|
|
4
|
+
return touch.timeStamp || touch.timestamp;
|
|
5
5
|
}
|
|
6
6
|
function createTouchRecord(touch) {
|
|
7
7
|
return {
|
|
8
|
-
touchActive:
|
|
8
|
+
touchActive: !0,
|
|
9
9
|
startPageX: touch.pageX,
|
|
10
10
|
startPageY: touch.pageY,
|
|
11
11
|
startTimeStamp: timestampForTouch(touch),
|
|
@@ -18,81 +18,38 @@ function createTouchRecord(touch) {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
function resetTouchRecord(touchRecord, touch) {
|
|
21
|
-
touchRecord.touchActive =
|
|
22
|
-
touchRecord.startPageX = touch.pageX;
|
|
23
|
-
touchRecord.startPageY = touch.pageY;
|
|
24
|
-
touchRecord.startTimeStamp = timestampForTouch(touch);
|
|
25
|
-
touchRecord.currentPageX = touch.pageX;
|
|
26
|
-
touchRecord.currentPageY = touch.pageY;
|
|
27
|
-
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
28
|
-
touchRecord.previousPageX = touch.pageX;
|
|
29
|
-
touchRecord.previousPageY = touch.pageY;
|
|
30
|
-
touchRecord.previousTimeStamp = timestampForTouch(touch);
|
|
21
|
+
touchRecord.touchActive = !0, touchRecord.startPageX = touch.pageX, touchRecord.startPageY = touch.pageY, touchRecord.startTimeStamp = timestampForTouch(touch), touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchRecord.previousPageX = touch.pageX, touchRecord.previousPageY = touch.pageY, touchRecord.previousTimeStamp = timestampForTouch(touch);
|
|
31
22
|
}
|
|
32
23
|
function getTouchIdentifier({ identifier }) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
console.error(
|
|
39
|
-
"Touch identifier %s is greater than maximum supported %s which causes performance issues backfilling array locations for all of the indices.",
|
|
40
|
-
identifier,
|
|
41
|
-
MAX_TOUCH_BANK
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return identifier;
|
|
24
|
+
return identifier == null && console.error("Touch object is missing identifier."), process.env.NODE_ENV === "development" && identifier > MAX_TOUCH_BANK && console.error(
|
|
25
|
+
"Touch identifier %s is greater than maximum supported %s which causes performance issues backfilling array locations for all of the indices.",
|
|
26
|
+
identifier,
|
|
27
|
+
MAX_TOUCH_BANK
|
|
28
|
+
), identifier;
|
|
46
29
|
}
|
|
47
30
|
function recordTouchStart(touch, touchHistory) {
|
|
48
|
-
const identifier = getTouchIdentifier(touch);
|
|
49
|
-
|
|
50
|
-
if (touchRecord) {
|
|
51
|
-
resetTouchRecord(touchRecord, touch);
|
|
52
|
-
} else {
|
|
53
|
-
touchHistory.touchBank[identifier] = createTouchRecord(touch);
|
|
54
|
-
}
|
|
55
|
-
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
31
|
+
const identifier = getTouchIdentifier(touch), touchRecord = touchHistory.touchBank[identifier];
|
|
32
|
+
touchRecord ? resetTouchRecord(touchRecord, touch) : touchHistory.touchBank[identifier] = createTouchRecord(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
56
33
|
}
|
|
57
34
|
function recordTouchMove(touch, touchHistory) {
|
|
58
35
|
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
62
|
-
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
63
|
-
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
64
|
-
touchRecord.currentPageX = touch.pageX;
|
|
65
|
-
touchRecord.currentPageY = touch.pageY;
|
|
66
|
-
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
67
|
-
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
68
|
-
} else {
|
|
69
|
-
console.warn(
|
|
70
|
-
"Cannot record touch move without a touch start.\n",
|
|
71
|
-
`Touch Move: ${printTouch(touch)}
|
|
36
|
+
touchRecord ? (touchRecord.touchActive = !0, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(
|
|
37
|
+
`Cannot record touch move without a touch start.
|
|
72
38
|
`,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
39
|
+
`Touch Move: ${printTouch(touch)}
|
|
40
|
+
`,
|
|
41
|
+
`Touch Bank: ${printTouchBank(touchHistory)}`
|
|
42
|
+
);
|
|
76
43
|
}
|
|
77
44
|
function recordTouchEnd(touch, touchHistory) {
|
|
78
45
|
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
82
|
-
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
83
|
-
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
84
|
-
touchRecord.currentPageX = touch.pageX;
|
|
85
|
-
touchRecord.currentPageY = touch.pageY;
|
|
86
|
-
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
87
|
-
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
88
|
-
} else {
|
|
89
|
-
console.warn(
|
|
90
|
-
"Cannot record touch end without a touch start.\n",
|
|
91
|
-
`Touch End: ${printTouch(touch)}
|
|
46
|
+
touchRecord ? (touchRecord.touchActive = !1, touchRecord.previousPageX = touchRecord.currentPageX, touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp, touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.warn(
|
|
47
|
+
`Cannot record touch end without a touch start.
|
|
92
48
|
`,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
49
|
+
`Touch End: ${printTouch(touch)}
|
|
50
|
+
`,
|
|
51
|
+
`Touch Bank: ${printTouchBank(touchHistory)}`
|
|
52
|
+
);
|
|
96
53
|
}
|
|
97
54
|
function printTouch(touch) {
|
|
98
55
|
return JSON.stringify({
|
|
@@ -105,53 +62,33 @@ function printTouch(touch) {
|
|
|
105
62
|
function printTouchBank(touchHistory) {
|
|
106
63
|
const { touchBank } = touchHistory;
|
|
107
64
|
let printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
108
|
-
|
|
109
|
-
printed += ` (original size: ${touchBank.length})`;
|
|
110
|
-
}
|
|
111
|
-
return printed;
|
|
65
|
+
return touchBank.length > MAX_TOUCH_BANK && (printed += ` (original size: ${touchBank.length})`), printed;
|
|
112
66
|
}
|
|
113
67
|
class ResponderTouchHistoryStore {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
}
|
|
68
|
+
_touchHistory = {
|
|
69
|
+
touchBank: [],
|
|
70
|
+
//Array<TouchRecord>
|
|
71
|
+
numberActiveTouches: 0,
|
|
72
|
+
// If there is only one active touch, we remember its location. This prevents
|
|
73
|
+
// us having to loop through all of the touches all the time in the most
|
|
74
|
+
// common case.
|
|
75
|
+
indexOfSingleActiveTouch: -1,
|
|
76
|
+
mostRecentTimeStamp: 0
|
|
77
|
+
};
|
|
126
78
|
recordTouchTrack(topLevelType, nativeEvent) {
|
|
127
79
|
const touchHistory = this._touchHistory;
|
|
128
|
-
if (isMoveish(topLevelType))
|
|
80
|
+
if (isMoveish(topLevelType))
|
|
129
81
|
nativeEvent.changedTouches.forEach((touch) => recordTouchMove(touch, touchHistory));
|
|
130
|
-
|
|
131
|
-
nativeEvent.changedTouches.forEach((touch) => recordTouchStart(touch, touchHistory));
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
139
|
-
if (touchHistory.numberActiveTouches === 1) {
|
|
140
|
-
const { touchBank } = touchHistory;
|
|
141
|
-
for (let i = 0; i < touchBank.length; i++) {
|
|
142
|
-
const touchTrackToCheck = touchBank[i];
|
|
143
|
-
if (touchTrackToCheck == null ? void 0 : touchTrackToCheck.touchActive) {
|
|
144
|
-
touchHistory.indexOfSingleActiveTouch = i;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (process.env.NODE_ENV === "development") {
|
|
149
|
-
const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
|
150
|
-
if (!(activeRecord == null ? void 0 : activeRecord.touchActive)) {
|
|
151
|
-
console.error("Cannot find single active touch.");
|
|
152
|
-
}
|
|
82
|
+
else if (isStartish(topLevelType))
|
|
83
|
+
nativeEvent.changedTouches.forEach((touch) => recordTouchStart(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1 && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier);
|
|
84
|
+
else if (isEndish(topLevelType) && (nativeEvent.changedTouches.forEach((touch) => recordTouchEnd(touch, touchHistory)), touchHistory.numberActiveTouches = nativeEvent.touches.length, touchHistory.numberActiveTouches === 1)) {
|
|
85
|
+
const { touchBank } = touchHistory;
|
|
86
|
+
for (let i = 0; i < touchBank.length; i++)
|
|
87
|
+
if (touchBank[i]?.touchActive) {
|
|
88
|
+
touchHistory.indexOfSingleActiveTouch = i;
|
|
89
|
+
break;
|
|
153
90
|
}
|
|
154
|
-
|
|
91
|
+
process.env.NODE_ENV === "development" && (touchBank[touchHistory.indexOfSingleActiveTouch]?.touchActive || console.error("Cannot find single active touch."));
|
|
155
92
|
}
|
|
156
93
|
}
|
|
157
94
|
get touchHistory() {
|