1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | (function (global, factory) {
|
13 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('react-dom'), require('react')) :
|
14 | typeof define === 'function' && define.amd ? define(['react-dom', 'react'], factory) :
|
15 | (global = global || self, global.ReactDOMUnstableNativeDependencies = factory(global.ReactDOM, global.React));
|
16 | }(this, (function (ReactDOM, React) { 'use strict';
|
17 |
|
18 | var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
19 |
|
20 |
|
21 |
|
22 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentDispatcher')) {
|
23 | ReactSharedInternals.ReactCurrentDispatcher = {
|
24 | current: null
|
25 | };
|
26 | }
|
27 |
|
28 | if (!ReactSharedInternals.hasOwnProperty('ReactCurrentBatchConfig')) {
|
29 | ReactSharedInternals.ReactCurrentBatchConfig = {
|
30 | suspense: null
|
31 | };
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | function warn(format) {
|
40 | {
|
41 | for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
42 | args[_key - 1] = arguments[_key];
|
43 | }
|
44 |
|
45 | printWarning('warn', format, args);
|
46 | }
|
47 | }
|
48 | function error(format) {
|
49 | {
|
50 | for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
51 | args[_key2 - 1] = arguments[_key2];
|
52 | }
|
53 |
|
54 | printWarning('error', format, args);
|
55 | }
|
56 | }
|
57 |
|
58 | function printWarning(level, format, args) {
|
59 |
|
60 |
|
61 | {
|
62 | var hasExistingStack = args.length > 0 && typeof args[args.length - 1] === 'string' && args[args.length - 1].indexOf('\n in') === 0;
|
63 |
|
64 | if (!hasExistingStack) {
|
65 | var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
66 | var stack = ReactDebugCurrentFrame.getStackAddendum();
|
67 |
|
68 | if (stack !== '') {
|
69 | format += '%s';
|
70 | args = args.concat([stack]);
|
71 | }
|
72 | }
|
73 |
|
74 | var argsWithFormat = args.map(function (item) {
|
75 | return '' + item;
|
76 | });
|
77 |
|
78 | argsWithFormat.unshift('Warning: ' + format);
|
79 |
|
80 |
|
81 |
|
82 | Function.prototype.apply.call(console[level], console, argsWithFormat);
|
83 |
|
84 | try {
|
85 |
|
86 |
|
87 |
|
88 | var argIndex = 0;
|
89 | var message = 'Warning: ' + format.replace(/%s/g, function () {
|
90 | return args[argIndex++];
|
91 | });
|
92 | throw new Error(message);
|
93 | } catch (x) {}
|
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 | if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
|
119 | var fakeNode = document.createElement('react');
|
120 | }
|
121 | }
|
122 |
|
123 | var getFiberCurrentPropsFromNode = null;
|
124 | var getInstanceFromNode = null;
|
125 | var getNodeFromInstance = null;
|
126 | function setComponentTree(getFiberCurrentPropsFromNodeImpl, getInstanceFromNodeImpl, getNodeFromInstanceImpl) {
|
127 | getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl;
|
128 | getInstanceFromNode = getInstanceFromNodeImpl;
|
129 | getNodeFromInstance = getNodeFromInstanceImpl;
|
130 |
|
131 | {
|
132 | if (!getNodeFromInstance || !getInstanceFromNode) {
|
133 | error('EventPluginUtils.setComponentTree(...): Injected ' + 'module is missing getNodeFromInstance or getInstanceFromNode.');
|
134 | }
|
135 | }
|
136 | }
|
137 | var validateEventDispatches;
|
138 |
|
139 | {
|
140 | validateEventDispatches = function (event) {
|
141 | var dispatchListeners = event._dispatchListeners;
|
142 | var dispatchInstances = event._dispatchInstances;
|
143 | var listenersIsArr = Array.isArray(dispatchListeners);
|
144 | var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
|
145 | var instancesIsArr = Array.isArray(dispatchInstances);
|
146 | var instancesLen = instancesIsArr ? dispatchInstances.length : dispatchInstances ? 1 : 0;
|
147 |
|
148 | if (instancesIsArr !== listenersIsArr || instancesLen !== listenersLen) {
|
149 | error('EventPluginUtils: Invalid `event`.');
|
150 | }
|
151 | };
|
152 | }
|
153 | |
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 | function executeDispatchesInOrderStopAtTrueImpl(event) {
|
162 | var dispatchListeners = event._dispatchListeners;
|
163 | var dispatchInstances = event._dispatchInstances;
|
164 |
|
165 | {
|
166 | validateEventDispatches(event);
|
167 | }
|
168 |
|
169 | if (Array.isArray(dispatchListeners)) {
|
170 | for (var i = 0; i < dispatchListeners.length; i++) {
|
171 | if (event.isPropagationStopped()) {
|
172 | break;
|
173 | }
|
174 |
|
175 |
|
176 | if (dispatchListeners[i](event, dispatchInstances[i])) {
|
177 | return dispatchInstances[i];
|
178 | }
|
179 | }
|
180 | } else if (dispatchListeners) {
|
181 | if (dispatchListeners(event, dispatchInstances)) {
|
182 | return dispatchInstances;
|
183 | }
|
184 | }
|
185 |
|
186 | return null;
|
187 | }
|
188 | |
189 |
|
190 |
|
191 |
|
192 |
|
193 | function executeDispatchesInOrderStopAtTrue(event) {
|
194 | var ret = executeDispatchesInOrderStopAtTrueImpl(event);
|
195 | event._dispatchInstances = null;
|
196 | event._dispatchListeners = null;
|
197 | return ret;
|
198 | }
|
199 | |
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 | function executeDirectDispatch(event) {
|
210 | {
|
211 | validateEventDispatches(event);
|
212 | }
|
213 |
|
214 | var dispatchListener = event._dispatchListeners;
|
215 | var dispatchInstance = event._dispatchInstances;
|
216 |
|
217 | if (!!Array.isArray(dispatchListener)) {
|
218 | {
|
219 | throw Error( "executeDirectDispatch(...): Invalid `event`." );
|
220 | }
|
221 | }
|
222 |
|
223 | event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null;
|
224 | var res = dispatchListener ? dispatchListener(event) : null;
|
225 | event.currentTarget = null;
|
226 | event._dispatchListeners = null;
|
227 | event._dispatchInstances = null;
|
228 | return res;
|
229 | }
|
230 | |
231 |
|
232 |
|
233 |
|
234 |
|
235 | function hasDispatches(event) {
|
236 | return !!event._dispatchListeners;
|
237 | }
|
238 |
|
239 | var HostComponent = 5;
|
240 |
|
241 | function getParent(inst) {
|
242 | do {
|
243 | inst = inst.return;
|
244 |
|
245 |
|
246 |
|
247 |
|
248 | } while (inst && inst.tag !== HostComponent);
|
249 |
|
250 | if (inst) {
|
251 | return inst;
|
252 | }
|
253 |
|
254 | return null;
|
255 | }
|
256 | |
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 | function getLowestCommonAncestor(instA, instB) {
|
263 | var depthA = 0;
|
264 |
|
265 | for (var tempA = instA; tempA; tempA = getParent(tempA)) {
|
266 | depthA++;
|
267 | }
|
268 |
|
269 | var depthB = 0;
|
270 |
|
271 | for (var tempB = instB; tempB; tempB = getParent(tempB)) {
|
272 | depthB++;
|
273 | }
|
274 |
|
275 |
|
276 | while (depthA - depthB > 0) {
|
277 | instA = getParent(instA);
|
278 | depthA--;
|
279 | }
|
280 |
|
281 |
|
282 | while (depthB - depthA > 0) {
|
283 | instB = getParent(instB);
|
284 | depthB--;
|
285 | }
|
286 |
|
287 |
|
288 | var depth = depthA;
|
289 |
|
290 | while (depth--) {
|
291 | if (instA === instB || instA === instB.alternate) {
|
292 | return instA;
|
293 | }
|
294 |
|
295 | instA = getParent(instA);
|
296 | instB = getParent(instB);
|
297 | }
|
298 |
|
299 | return null;
|
300 | }
|
301 | |
302 |
|
303 |
|
304 |
|
305 | function isAncestor(instA, instB) {
|
306 | while (instB) {
|
307 | if (instA === instB || instA === instB.alternate) {
|
308 | return true;
|
309 | }
|
310 |
|
311 | instB = getParent(instB);
|
312 | }
|
313 |
|
314 | return false;
|
315 | }
|
316 | |
317 |
|
318 |
|
319 |
|
320 | function getParentInstance(inst) {
|
321 | return getParent(inst);
|
322 | }
|
323 | |
324 |
|
325 |
|
326 |
|
327 | function traverseTwoPhase(inst, fn, arg) {
|
328 | var path = [];
|
329 |
|
330 | while (inst) {
|
331 | path.push(inst);
|
332 | inst = getParent(inst);
|
333 | }
|
334 |
|
335 | var i;
|
336 |
|
337 | for (i = path.length; i-- > 0;) {
|
338 | fn(path[i], 'captured', arg);
|
339 | }
|
340 |
|
341 | for (i = 0; i < path.length; i++) {
|
342 | fn(path[i], 'bubbled', arg);
|
343 | }
|
344 | }
|
345 |
|
346 | function isInteractive(tag) {
|
347 | return tag === 'button' || tag === 'input' || tag === 'select' || tag === 'textarea';
|
348 | }
|
349 |
|
350 | function shouldPreventMouseEvent(name, type, props) {
|
351 | switch (name) {
|
352 | case 'onClick':
|
353 | case 'onClickCapture':
|
354 | case 'onDoubleClick':
|
355 | case 'onDoubleClickCapture':
|
356 | case 'onMouseDown':
|
357 | case 'onMouseDownCapture':
|
358 | case 'onMouseMove':
|
359 | case 'onMouseMoveCapture':
|
360 | case 'onMouseUp':
|
361 | case 'onMouseUpCapture':
|
362 | case 'onMouseEnter':
|
363 | return !!(props.disabled && isInteractive(type));
|
364 |
|
365 | default:
|
366 | return false;
|
367 | }
|
368 | }
|
369 | |
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | function getListener(inst, registrationName) {
|
377 | var listener;
|
378 |
|
379 |
|
380 | var stateNode = inst.stateNode;
|
381 |
|
382 | if (!stateNode) {
|
383 |
|
384 | return null;
|
385 | }
|
386 |
|
387 | var props = getFiberCurrentPropsFromNode(stateNode);
|
388 |
|
389 | if (!props) {
|
390 |
|
391 | return null;
|
392 | }
|
393 |
|
394 | listener = props[registrationName];
|
395 |
|
396 | if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
397 | return null;
|
398 | }
|
399 |
|
400 | if (!(!listener || typeof listener === 'function')) {
|
401 | {
|
402 | throw Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type." );
|
403 | }
|
404 | }
|
405 |
|
406 | return listener;
|
407 | }
|
408 |
|
409 | |
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | function accumulateInto(current, next) {
|
423 | if (!(next != null)) {
|
424 | {
|
425 | throw Error( "accumulateInto(...): Accumulated items must not be null or undefined." );
|
426 | }
|
427 | }
|
428 |
|
429 | if (current == null) {
|
430 | return next;
|
431 | }
|
432 |
|
433 |
|
434 |
|
435 | if (Array.isArray(current)) {
|
436 | if (Array.isArray(next)) {
|
437 | current.push.apply(current, next);
|
438 | return current;
|
439 | }
|
440 |
|
441 | current.push(next);
|
442 | return current;
|
443 | }
|
444 |
|
445 | if (Array.isArray(next)) {
|
446 |
|
447 | return [current].concat(next);
|
448 | }
|
449 |
|
450 | return [current, next];
|
451 | }
|
452 |
|
453 | |
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 | function forEachAccumulated(arr, cb, scope) {
|
463 | if (Array.isArray(arr)) {
|
464 | arr.forEach(cb, scope);
|
465 | } else if (arr) {
|
466 | cb.call(scope, arr);
|
467 | }
|
468 | }
|
469 |
|
470 | |
471 |
|
472 |
|
473 |
|
474 | function listenerAtPhase(inst, event, propagationPhase) {
|
475 | var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
|
476 | return getListener(inst, registrationName);
|
477 | }
|
478 | |
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 | |
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 | function accumulateDirectionalDispatches(inst, phase, event) {
|
497 | {
|
498 | if (!inst) {
|
499 | error('Dispatching inst must not be null');
|
500 | }
|
501 | }
|
502 |
|
503 | var listener = listenerAtPhase(inst, event, phase);
|
504 |
|
505 | if (listener) {
|
506 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
507 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
508 | }
|
509 | }
|
510 | |
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 | function accumulateTwoPhaseDispatchesSingle(event) {
|
520 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
521 | traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event);
|
522 | }
|
523 | }
|
524 | |
525 |
|
526 |
|
527 |
|
528 |
|
529 | function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
530 | if (event && event.dispatchConfig.phasedRegistrationNames) {
|
531 | var targetInst = event._targetInst;
|
532 | var parentInst = targetInst ? getParentInstance(targetInst) : null;
|
533 | traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event);
|
534 | }
|
535 | }
|
536 | |
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 | function accumulateDispatches(inst, ignoredDirection, event) {
|
544 | if (inst && event && event.dispatchConfig.registrationName) {
|
545 | var registrationName = event.dispatchConfig.registrationName;
|
546 | var listener = getListener(inst, registrationName);
|
547 |
|
548 | if (listener) {
|
549 | event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
|
550 | event._dispatchInstances = accumulateInto(event._dispatchInstances, inst);
|
551 | }
|
552 | }
|
553 | }
|
554 | |
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 | function accumulateDirectDispatchesSingle(event) {
|
562 | if (event && event.dispatchConfig.registrationName) {
|
563 | accumulateDispatches(event._targetInst, null, event);
|
564 | }
|
565 | }
|
566 |
|
567 | function accumulateTwoPhaseDispatches(events) {
|
568 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
|
569 | }
|
570 | function accumulateTwoPhaseDispatchesSkipTarget(events) {
|
571 | forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
|
572 | }
|
573 | function accumulateDirectDispatches(events) {
|
574 | forEachAccumulated(events, accumulateDirectDispatchesSingle);
|
575 | }
|
576 |
|
577 | var ReactInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
578 | var _assign = ReactInternals.assign;
|
579 |
|
580 | var EVENT_POOL_SIZE = 10;
|
581 | |
582 |
|
583 |
|
584 |
|
585 |
|
586 | var EventInterface = {
|
587 | type: null,
|
588 | target: null,
|
589 |
|
590 | currentTarget: function () {
|
591 | return null;
|
592 | },
|
593 | eventPhase: null,
|
594 | bubbles: null,
|
595 | cancelable: null,
|
596 | timeStamp: function (event) {
|
597 | return event.timeStamp || Date.now();
|
598 | },
|
599 | defaultPrevented: null,
|
600 | isTrusted: null
|
601 | };
|
602 |
|
603 | function functionThatReturnsTrue() {
|
604 | return true;
|
605 | }
|
606 |
|
607 | function functionThatReturnsFalse() {
|
608 | return false;
|
609 | }
|
610 | |
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 | function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarget) {
|
631 | {
|
632 |
|
633 | delete this.nativeEvent;
|
634 | delete this.preventDefault;
|
635 | delete this.stopPropagation;
|
636 | delete this.isDefaultPrevented;
|
637 | delete this.isPropagationStopped;
|
638 | }
|
639 |
|
640 | this.dispatchConfig = dispatchConfig;
|
641 | this._targetInst = targetInst;
|
642 | this.nativeEvent = nativeEvent;
|
643 | var Interface = this.constructor.Interface;
|
644 |
|
645 | for (var propName in Interface) {
|
646 | if (!Interface.hasOwnProperty(propName)) {
|
647 | continue;
|
648 | }
|
649 |
|
650 | {
|
651 | delete this[propName];
|
652 | }
|
653 |
|
654 | var normalize = Interface[propName];
|
655 |
|
656 | if (normalize) {
|
657 | this[propName] = normalize(nativeEvent);
|
658 | } else {
|
659 | if (propName === 'target') {
|
660 | this.target = nativeEventTarget;
|
661 | } else {
|
662 | this[propName] = nativeEvent[propName];
|
663 | }
|
664 | }
|
665 | }
|
666 |
|
667 | var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
668 |
|
669 | if (defaultPrevented) {
|
670 | this.isDefaultPrevented = functionThatReturnsTrue;
|
671 | } else {
|
672 | this.isDefaultPrevented = functionThatReturnsFalse;
|
673 | }
|
674 |
|
675 | this.isPropagationStopped = functionThatReturnsFalse;
|
676 | return this;
|
677 | }
|
678 |
|
679 | _assign(SyntheticEvent.prototype, {
|
680 | preventDefault: function () {
|
681 | this.defaultPrevented = true;
|
682 | var event = this.nativeEvent;
|
683 |
|
684 | if (!event) {
|
685 | return;
|
686 | }
|
687 |
|
688 | if (event.preventDefault) {
|
689 | event.preventDefault();
|
690 | } else if (typeof event.returnValue !== 'unknown') {
|
691 | event.returnValue = false;
|
692 | }
|
693 |
|
694 | this.isDefaultPrevented = functionThatReturnsTrue;
|
695 | },
|
696 | stopPropagation: function () {
|
697 | var event = this.nativeEvent;
|
698 |
|
699 | if (!event) {
|
700 | return;
|
701 | }
|
702 |
|
703 | if (event.stopPropagation) {
|
704 | event.stopPropagation();
|
705 | } else if (typeof event.cancelBubble !== 'unknown') {
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 | event.cancelBubble = true;
|
712 | }
|
713 |
|
714 | this.isPropagationStopped = functionThatReturnsTrue;
|
715 | },
|
716 |
|
717 | |
718 |
|
719 |
|
720 |
|
721 |
|
722 | persist: function () {
|
723 | this.isPersistent = functionThatReturnsTrue;
|
724 | },
|
725 |
|
726 | |
727 |
|
728 |
|
729 |
|
730 |
|
731 | isPersistent: functionThatReturnsFalse,
|
732 |
|
733 | |
734 |
|
735 |
|
736 | destructor: function () {
|
737 | var Interface = this.constructor.Interface;
|
738 |
|
739 | for (var propName in Interface) {
|
740 | {
|
741 | Object.defineProperty(this, propName, getPooledWarningPropertyDefinition(propName, Interface[propName]));
|
742 | }
|
743 | }
|
744 |
|
745 | this.dispatchConfig = null;
|
746 | this._targetInst = null;
|
747 | this.nativeEvent = null;
|
748 | this.isDefaultPrevented = functionThatReturnsFalse;
|
749 | this.isPropagationStopped = functionThatReturnsFalse;
|
750 | this._dispatchListeners = null;
|
751 | this._dispatchInstances = null;
|
752 |
|
753 | {
|
754 | Object.defineProperty(this, 'nativeEvent', getPooledWarningPropertyDefinition('nativeEvent', null));
|
755 | Object.defineProperty(this, 'isDefaultPrevented', getPooledWarningPropertyDefinition('isDefaultPrevented', functionThatReturnsFalse));
|
756 | Object.defineProperty(this, 'isPropagationStopped', getPooledWarningPropertyDefinition('isPropagationStopped', functionThatReturnsFalse));
|
757 | Object.defineProperty(this, 'preventDefault', getPooledWarningPropertyDefinition('preventDefault', function () {}));
|
758 | Object.defineProperty(this, 'stopPropagation', getPooledWarningPropertyDefinition('stopPropagation', function () {}));
|
759 | }
|
760 | }
|
761 | });
|
762 |
|
763 | SyntheticEvent.Interface = EventInterface;
|
764 | |
765 |
|
766 |
|
767 |
|
768 | SyntheticEvent.extend = function (Interface) {
|
769 | var Super = this;
|
770 |
|
771 | var E = function () {};
|
772 |
|
773 | E.prototype = Super.prototype;
|
774 | var prototype = new E();
|
775 |
|
776 | function Class() {
|
777 | return Super.apply(this, arguments);
|
778 | }
|
779 |
|
780 | _assign(prototype, Class.prototype);
|
781 |
|
782 | Class.prototype = prototype;
|
783 | Class.prototype.constructor = Class;
|
784 | Class.Interface = _assign({}, Super.Interface, Interface);
|
785 | Class.extend = Super.extend;
|
786 | addEventPoolingTo(Class);
|
787 | return Class;
|
788 | };
|
789 |
|
790 | addEventPoolingTo(SyntheticEvent);
|
791 | |
792 |
|
793 |
|
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 | function getPooledWarningPropertyDefinition(propName, getVal) {
|
800 | var isFunction = typeof getVal === 'function';
|
801 | return {
|
802 | configurable: true,
|
803 | set: set,
|
804 | get: get
|
805 | };
|
806 |
|
807 | function set(val) {
|
808 | var action = isFunction ? 'setting the method' : 'setting the property';
|
809 | warn(action, 'This is effectively a no-op');
|
810 | return val;
|
811 | }
|
812 |
|
813 | function get() {
|
814 | var action = isFunction ? 'accessing the method' : 'accessing the property';
|
815 | var result = isFunction ? 'This is a no-op function' : 'This is set to null';
|
816 | warn(action, result);
|
817 | return getVal;
|
818 | }
|
819 |
|
820 | function warn(action, result) {
|
821 | {
|
822 | error("This synthetic event is reused for performance reasons. If you're seeing this, " + "you're %s `%s` on a released/nullified synthetic event. %s. " + 'If you must keep the original synthetic event around, use event.persist(). ' + 'See https://fb.me/react-event-pooling for more information.', action, propName, result);
|
823 | }
|
824 | }
|
825 | }
|
826 |
|
827 | function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
|
828 | var EventConstructor = this;
|
829 |
|
830 | if (EventConstructor.eventPool.length) {
|
831 | var instance = EventConstructor.eventPool.pop();
|
832 | EventConstructor.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst);
|
833 | return instance;
|
834 | }
|
835 |
|
836 | return new EventConstructor(dispatchConfig, targetInst, nativeEvent, nativeInst);
|
837 | }
|
838 |
|
839 | function releasePooledEvent(event) {
|
840 | var EventConstructor = this;
|
841 |
|
842 | if (!(event instanceof EventConstructor)) {
|
843 | {
|
844 | throw Error( "Trying to release an event instance into a pool of a different type." );
|
845 | }
|
846 | }
|
847 |
|
848 | event.destructor();
|
849 |
|
850 | if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
|
851 | EventConstructor.eventPool.push(event);
|
852 | }
|
853 | }
|
854 |
|
855 | function addEventPoolingTo(EventConstructor) {
|
856 | EventConstructor.eventPool = [];
|
857 | EventConstructor.getPooled = getPooledEvent;
|
858 | EventConstructor.release = releasePooledEvent;
|
859 | }
|
860 |
|
861 | |
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 | var ResponderSyntheticEvent = SyntheticEvent.extend({
|
868 | touchHistory: function (nativeEvent) {
|
869 | return null;
|
870 | }
|
871 | });
|
872 |
|
873 |
|
874 |
|
875 | var TOP_TOUCH_START = 'touchstart';
|
876 | var TOP_TOUCH_MOVE = 'touchmove';
|
877 | var TOP_TOUCH_END = 'touchend';
|
878 | var TOP_TOUCH_CANCEL = 'touchcancel';
|
879 | var TOP_SCROLL = 'scroll';
|
880 | var TOP_SELECTION_CHANGE = 'selectionchange';
|
881 | var TOP_MOUSE_DOWN = 'mousedown';
|
882 | var TOP_MOUSE_MOVE = 'mousemove';
|
883 | var TOP_MOUSE_UP = 'mouseup';
|
884 | function isStartish(topLevelType) {
|
885 | return topLevelType === TOP_TOUCH_START || topLevelType === TOP_MOUSE_DOWN;
|
886 | }
|
887 | function isMoveish(topLevelType) {
|
888 | return topLevelType === TOP_TOUCH_MOVE || topLevelType === TOP_MOUSE_MOVE;
|
889 | }
|
890 | function isEndish(topLevelType) {
|
891 | return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL || topLevelType === TOP_MOUSE_UP;
|
892 | }
|
893 | var startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN];
|
894 | var moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE];
|
895 | var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP];
|
896 |
|
897 | |
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 | var MAX_TOUCH_BANK = 20;
|
904 | var touchBank = [];
|
905 | var touchHistory = {
|
906 | touchBank: touchBank,
|
907 | numberActiveTouches: 0,
|
908 |
|
909 |
|
910 |
|
911 | indexOfSingleActiveTouch: -1,
|
912 | mostRecentTimeStamp: 0
|
913 | };
|
914 |
|
915 | function timestampForTouch(touch) {
|
916 |
|
917 |
|
918 |
|
919 | return touch.timeStamp || touch.timestamp;
|
920 | }
|
921 | |
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 | function createTouchRecord(touch) {
|
928 | return {
|
929 | touchActive: true,
|
930 | startPageX: touch.pageX,
|
931 | startPageY: touch.pageY,
|
932 | startTimeStamp: timestampForTouch(touch),
|
933 | currentPageX: touch.pageX,
|
934 | currentPageY: touch.pageY,
|
935 | currentTimeStamp: timestampForTouch(touch),
|
936 | previousPageX: touch.pageX,
|
937 | previousPageY: touch.pageY,
|
938 | previousTimeStamp: timestampForTouch(touch)
|
939 | };
|
940 | }
|
941 |
|
942 | function resetTouchRecord(touchRecord, touch) {
|
943 | touchRecord.touchActive = true;
|
944 | touchRecord.startPageX = touch.pageX;
|
945 | touchRecord.startPageY = touch.pageY;
|
946 | touchRecord.startTimeStamp = timestampForTouch(touch);
|
947 | touchRecord.currentPageX = touch.pageX;
|
948 | touchRecord.currentPageY = touch.pageY;
|
949 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
950 | touchRecord.previousPageX = touch.pageX;
|
951 | touchRecord.previousPageY = touch.pageY;
|
952 | touchRecord.previousTimeStamp = timestampForTouch(touch);
|
953 | }
|
954 |
|
955 | function getTouchIdentifier(_ref) {
|
956 | var identifier = _ref.identifier;
|
957 |
|
958 | if (!(identifier != null)) {
|
959 | {
|
960 | throw Error( "Touch object is missing identifier." );
|
961 | }
|
962 | }
|
963 |
|
964 | {
|
965 | if (identifier > MAX_TOUCH_BANK) {
|
966 | error('Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK);
|
967 | }
|
968 | }
|
969 |
|
970 | return identifier;
|
971 | }
|
972 |
|
973 | function recordTouchStart(touch) {
|
974 | var identifier = getTouchIdentifier(touch);
|
975 | var touchRecord = touchBank[identifier];
|
976 |
|
977 | if (touchRecord) {
|
978 | resetTouchRecord(touchRecord, touch);
|
979 | } else {
|
980 | touchBank[identifier] = createTouchRecord(touch);
|
981 | }
|
982 |
|
983 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
984 | }
|
985 |
|
986 | function recordTouchMove(touch) {
|
987 | var touchRecord = touchBank[getTouchIdentifier(touch)];
|
988 |
|
989 | if (touchRecord) {
|
990 | touchRecord.touchActive = true;
|
991 | touchRecord.previousPageX = touchRecord.currentPageX;
|
992 | touchRecord.previousPageY = touchRecord.currentPageY;
|
993 | touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
994 | touchRecord.currentPageX = touch.pageX;
|
995 | touchRecord.currentPageY = touch.pageY;
|
996 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
997 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
998 | } else {
|
999 | {
|
1000 | warn('Cannot record touch move without a touch start.\n' + 'Touch Move: %s\n' + 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
1001 | }
|
1002 | }
|
1003 | }
|
1004 |
|
1005 | function recordTouchEnd(touch) {
|
1006 | var touchRecord = touchBank[getTouchIdentifier(touch)];
|
1007 |
|
1008 | if (touchRecord) {
|
1009 | touchRecord.touchActive = false;
|
1010 | touchRecord.previousPageX = touchRecord.currentPageX;
|
1011 | touchRecord.previousPageY = touchRecord.currentPageY;
|
1012 | touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
1013 | touchRecord.currentPageX = touch.pageX;
|
1014 | touchRecord.currentPageY = touch.pageY;
|
1015 | touchRecord.currentTimeStamp = timestampForTouch(touch);
|
1016 | touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
1017 | } else {
|
1018 | {
|
1019 | warn('Cannot record touch end without a touch start.\n' + 'Touch End: %s\n' + 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
1020 | }
|
1021 | }
|
1022 | }
|
1023 |
|
1024 | function printTouch(touch) {
|
1025 | return JSON.stringify({
|
1026 | identifier: touch.identifier,
|
1027 | pageX: touch.pageX,
|
1028 | pageY: touch.pageY,
|
1029 | timestamp: timestampForTouch(touch)
|
1030 | });
|
1031 | }
|
1032 |
|
1033 | function printTouchBank() {
|
1034 | var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
1035 |
|
1036 | if (touchBank.length > MAX_TOUCH_BANK) {
|
1037 | printed += ' (original size: ' + touchBank.length + ')';
|
1038 | }
|
1039 |
|
1040 | return printed;
|
1041 | }
|
1042 |
|
1043 | var ResponderTouchHistoryStore = {
|
1044 | recordTouchTrack: function (topLevelType, nativeEvent) {
|
1045 | if (isMoveish(topLevelType)) {
|
1046 | nativeEvent.changedTouches.forEach(recordTouchMove);
|
1047 | } else if (isStartish(topLevelType)) {
|
1048 | nativeEvent.changedTouches.forEach(recordTouchStart);
|
1049 | touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
1050 |
|
1051 | if (touchHistory.numberActiveTouches === 1) {
|
1052 | touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
1053 | }
|
1054 | } else if (isEndish(topLevelType)) {
|
1055 | nativeEvent.changedTouches.forEach(recordTouchEnd);
|
1056 | touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
1057 |
|
1058 | if (touchHistory.numberActiveTouches === 1) {
|
1059 | for (var i = 0; i < touchBank.length; i++) {
|
1060 | var touchTrackToCheck = touchBank[i];
|
1061 |
|
1062 | if (touchTrackToCheck != null && touchTrackToCheck.touchActive) {
|
1063 | touchHistory.indexOfSingleActiveTouch = i;
|
1064 | break;
|
1065 | }
|
1066 | }
|
1067 |
|
1068 | {
|
1069 | var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
1070 |
|
1071 | if (activeRecord == null || !activeRecord.touchActive) {
|
1072 | error('Cannot find single active touch.');
|
1073 | }
|
1074 | }
|
1075 | }
|
1076 | }
|
1077 | },
|
1078 | touchHistory: touchHistory
|
1079 | };
|
1080 |
|
1081 | |
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 | function accumulate(current, next) {
|
1090 | if (!(next != null)) {
|
1091 | {
|
1092 | throw Error( "accumulate(...): Accumulated items must not be null or undefined." );
|
1093 | }
|
1094 | }
|
1095 |
|
1096 | if (current == null) {
|
1097 | return next;
|
1098 | }
|
1099 |
|
1100 |
|
1101 |
|
1102 | if (Array.isArray(current)) {
|
1103 | return current.concat(next);
|
1104 | }
|
1105 |
|
1106 | if (Array.isArray(next)) {
|
1107 | return [current].concat(next);
|
1108 | }
|
1109 |
|
1110 | return [current, next];
|
1111 | }
|
1112 |
|
1113 | |
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 | var responderInst = null;
|
1119 | |
1120 |
|
1121 |
|
1122 |
|
1123 |
|
1124 | var trackedTouchCount = 0;
|
1125 |
|
1126 | var changeResponder = function (nextResponderInst, blockHostResponder) {
|
1127 | var oldResponderInst = responderInst;
|
1128 | responderInst = nextResponderInst;
|
1129 |
|
1130 | if (ResponderEventPlugin.GlobalResponderHandler !== null) {
|
1131 | ResponderEventPlugin.GlobalResponderHandler.onChange(oldResponderInst, nextResponderInst, blockHostResponder);
|
1132 | }
|
1133 | };
|
1134 |
|
1135 | var eventTypes = {
|
1136 | |
1137 |
|
1138 |
|
1139 |
|
1140 | startShouldSetResponder: {
|
1141 | phasedRegistrationNames: {
|
1142 | bubbled: 'onStartShouldSetResponder',
|
1143 | captured: 'onStartShouldSetResponderCapture'
|
1144 | },
|
1145 | dependencies: startDependencies
|
1146 | },
|
1147 |
|
1148 | |
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 | scrollShouldSetResponder: {
|
1158 | phasedRegistrationNames: {
|
1159 | bubbled: 'onScrollShouldSetResponder',
|
1160 | captured: 'onScrollShouldSetResponderCapture'
|
1161 | },
|
1162 | dependencies: [TOP_SCROLL]
|
1163 | },
|
1164 |
|
1165 | |
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 | selectionChangeShouldSetResponder: {
|
1173 | phasedRegistrationNames: {
|
1174 | bubbled: 'onSelectionChangeShouldSetResponder',
|
1175 | captured: 'onSelectionChangeShouldSetResponderCapture'
|
1176 | },
|
1177 | dependencies: [TOP_SELECTION_CHANGE]
|
1178 | },
|
1179 |
|
1180 | |
1181 |
|
1182 |
|
1183 |
|
1184 | moveShouldSetResponder: {
|
1185 | phasedRegistrationNames: {
|
1186 | bubbled: 'onMoveShouldSetResponder',
|
1187 | captured: 'onMoveShouldSetResponderCapture'
|
1188 | },
|
1189 | dependencies: moveDependencies
|
1190 | },
|
1191 |
|
1192 | |
1193 |
|
1194 |
|
1195 | responderStart: {
|
1196 | registrationName: 'onResponderStart',
|
1197 | dependencies: startDependencies
|
1198 | },
|
1199 | responderMove: {
|
1200 | registrationName: 'onResponderMove',
|
1201 | dependencies: moveDependencies
|
1202 | },
|
1203 | responderEnd: {
|
1204 | registrationName: 'onResponderEnd',
|
1205 | dependencies: endDependencies
|
1206 | },
|
1207 | responderRelease: {
|
1208 | registrationName: 'onResponderRelease',
|
1209 | dependencies: endDependencies
|
1210 | },
|
1211 | responderTerminationRequest: {
|
1212 | registrationName: 'onResponderTerminationRequest',
|
1213 | dependencies: []
|
1214 | },
|
1215 | responderGrant: {
|
1216 | registrationName: 'onResponderGrant',
|
1217 | dependencies: []
|
1218 | },
|
1219 | responderReject: {
|
1220 | registrationName: 'onResponderReject',
|
1221 | dependencies: []
|
1222 | },
|
1223 | responderTerminate: {
|
1224 | registrationName: 'onResponderTerminate',
|
1225 | dependencies: []
|
1226 | }
|
1227 | };
|
1228 | |
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 |
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 | |
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 |
|
1294 |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 |
|
1346 |
|
1347 |
|
1348 |
|
1349 |
|
1350 |
|
1351 |
|
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 | |
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 |
|
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 | function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
1419 | var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : topLevelType === TOP_SELECTION_CHANGE ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder;
|
1420 |
|
1421 | var bubbleShouldSetFrom = !responderInst ? targetInst : getLowestCommonAncestor(responderInst, targetInst);
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 | var skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst;
|
1427 | var shouldSetEvent = ResponderSyntheticEvent.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
1428 | shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1429 |
|
1430 | if (skipOverBubbleShouldSetFrom) {
|
1431 | accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent);
|
1432 | } else {
|
1433 | accumulateTwoPhaseDispatches(shouldSetEvent);
|
1434 | }
|
1435 |
|
1436 | var wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent);
|
1437 |
|
1438 | if (!shouldSetEvent.isPersistent()) {
|
1439 | shouldSetEvent.constructor.release(shouldSetEvent);
|
1440 | }
|
1441 |
|
1442 | if (!wantsResponderInst || wantsResponderInst === responderInst) {
|
1443 | return null;
|
1444 | }
|
1445 |
|
1446 | var extracted;
|
1447 | var grantEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
|
1448 | grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1449 | accumulateDirectDispatches(grantEvent);
|
1450 | var blockHostResponder = executeDirectDispatch(grantEvent) === true;
|
1451 |
|
1452 | if (responderInst) {
|
1453 | var terminationRequestEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
|
1454 | terminationRequestEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1455 | accumulateDirectDispatches(terminationRequestEvent);
|
1456 | var shouldSwitch = !hasDispatches(terminationRequestEvent) || executeDirectDispatch(terminationRequestEvent);
|
1457 |
|
1458 | if (!terminationRequestEvent.isPersistent()) {
|
1459 | terminationRequestEvent.constructor.release(terminationRequestEvent);
|
1460 | }
|
1461 |
|
1462 | if (shouldSwitch) {
|
1463 | var terminateEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
|
1464 | terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1465 | accumulateDirectDispatches(terminateEvent);
|
1466 | extracted = accumulate(extracted, [grantEvent, terminateEvent]);
|
1467 | changeResponder(wantsResponderInst, blockHostResponder);
|
1468 | } else {
|
1469 | var rejectEvent = ResponderSyntheticEvent.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
|
1470 | rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1471 | accumulateDirectDispatches(rejectEvent);
|
1472 | extracted = accumulate(extracted, rejectEvent);
|
1473 | }
|
1474 | } else {
|
1475 | extracted = accumulate(extracted, grantEvent);
|
1476 | changeResponder(wantsResponderInst, blockHostResponder);
|
1477 | }
|
1478 |
|
1479 | return extracted;
|
1480 | }
|
1481 | |
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 | function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) {
|
1492 | return topLevelInst && (
|
1493 |
|
1494 |
|
1495 | topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll || trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE || isStartish(topLevelType) || isMoveish(topLevelType));
|
1496 | }
|
1497 | |
1498 |
|
1499 |
|
1500 |
|
1501 |
|
1502 |
|
1503 |
|
1504 |
|
1505 |
|
1506 | function noResponderTouches(nativeEvent) {
|
1507 | var touches = nativeEvent.touches;
|
1508 |
|
1509 | if (!touches || touches.length === 0) {
|
1510 | return true;
|
1511 | }
|
1512 |
|
1513 | for (var i = 0; i < touches.length; i++) {
|
1514 | var activeTouch = touches[i];
|
1515 | var target = activeTouch.target;
|
1516 |
|
1517 | if (target !== null && target !== undefined && target !== 0) {
|
1518 |
|
1519 | var targetInst = getInstanceFromNode(target);
|
1520 |
|
1521 | if (isAncestor(responderInst, targetInst)) {
|
1522 | return false;
|
1523 | }
|
1524 | }
|
1525 | }
|
1526 |
|
1527 | return true;
|
1528 | }
|
1529 |
|
1530 | var ResponderEventPlugin = {
|
1531 |
|
1532 | _getResponder: function () {
|
1533 | return responderInst;
|
1534 | },
|
1535 | eventTypes: eventTypes,
|
1536 |
|
1537 | |
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 | extractEvents: function (topLevelType, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags) {
|
1543 | if (isStartish(topLevelType)) {
|
1544 | trackedTouchCount += 1;
|
1545 | } else if (isEndish(topLevelType)) {
|
1546 | if (trackedTouchCount >= 0) {
|
1547 | trackedTouchCount -= 1;
|
1548 | } else {
|
1549 | {
|
1550 | warn('Ended a touch event which was not counted in `trackedTouchCount`.');
|
1551 | }
|
1552 |
|
1553 | return null;
|
1554 | }
|
1555 | }
|
1556 |
|
1557 | ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
|
1558 | var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
|
1559 |
|
1560 |
|
1561 |
|
1562 |
|
1563 |
|
1564 |
|
1565 |
|
1566 |
|
1567 |
|
1568 |
|
1569 | var isResponderTouchStart = responderInst && isStartish(topLevelType);
|
1570 | var isResponderTouchMove = responderInst && isMoveish(topLevelType);
|
1571 | var isResponderTouchEnd = responderInst && isEndish(topLevelType);
|
1572 | var incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
|
1573 |
|
1574 | if (incrementalTouch) {
|
1575 | var gesture = ResponderSyntheticEvent.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
|
1576 | gesture.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1577 | accumulateDirectDispatches(gesture);
|
1578 | extracted = accumulate(extracted, gesture);
|
1579 | }
|
1580 |
|
1581 | var isResponderTerminate = responderInst && topLevelType === TOP_TOUCH_CANCEL;
|
1582 | var isResponderRelease = responderInst && !isResponderTerminate && isEndish(topLevelType) && noResponderTouches(nativeEvent);
|
1583 | var finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
1584 |
|
1585 | if (finalTouch) {
|
1586 | var finalEvent = ResponderSyntheticEvent.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
|
1587 | finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory;
|
1588 | accumulateDirectDispatches(finalEvent);
|
1589 | extracted = accumulate(extracted, finalEvent);
|
1590 | changeResponder(null);
|
1591 | }
|
1592 |
|
1593 | return extracted;
|
1594 | },
|
1595 | GlobalResponderHandler: null,
|
1596 | injection: {
|
1597 | |
1598 |
|
1599 |
|
1600 |
|
1601 |
|
1602 | injectGlobalResponderHandler: function (GlobalResponderHandler) {
|
1603 | ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler;
|
1604 | }
|
1605 | }
|
1606 | };
|
1607 |
|
1608 |
|
1609 |
|
1610 | var _ReactDOM$__SECRET_IN = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Events,
|
1611 | getInstanceFromNode$1 = _ReactDOM$__SECRET_IN[0],
|
1612 | getNodeFromInstance$1 = _ReactDOM$__SECRET_IN[1],
|
1613 | getFiberCurrentPropsFromNode$1 = _ReactDOM$__SECRET_IN[2],
|
1614 | injectEventPluginsByName = _ReactDOM$__SECRET_IN[3];
|
1615 | setComponentTree(getFiberCurrentPropsFromNode$1, getInstanceFromNode$1, getNodeFromInstance$1);
|
1616 |
|
1617 | var ReactDOMUnstableNativeDependencies = Object.freeze({
|
1618 | __proto__: null,
|
1619 | ResponderEventPlugin: ResponderEventPlugin,
|
1620 | ResponderTouchHistoryStore: ResponderTouchHistoryStore,
|
1621 | injectEventPluginsByName: injectEventPluginsByName
|
1622 | });
|
1623 |
|
1624 | var unstableNativeDependencies = ReactDOMUnstableNativeDependencies;
|
1625 |
|
1626 | return unstableNativeDependencies;
|
1627 |
|
1628 | })));
|