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