This commit is contained in:
Marshall Roch 2015-03-25 10:23:17 -07:00
Родитель 972bbd7adf
Коммит 0315719507
2 изменённых файлов: 29 добавлений и 11 удалений

Просмотреть файл

@ -12,7 +12,7 @@
.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js
.*/node_modules/react-tools/src/browser/.*
.*/node_modules/react-tools/src/core/ReactInstanceHandles.js
.*/node_modules/react-tools/src/event/.*
.*/node_modules/react-tools/src/event/EventPropagators.js
# Ignore jest
.*/react-native/node_modules/jest-cli/.*

Просмотреть файл

@ -7,7 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule ReactIOSEventEmitter
* @typechecks static-only
* @flow
*/
"use strict";
@ -57,21 +57,27 @@ var touchSubsequence = function(touches, indices) {
* @param {Array<number>} indices Indices to remove from `touches`.
* @return {Array<Touch>} Subsequence of removed touch objects.
*/
var removeTouchesAtIndices = function(touches, indices) {
var removeTouchesAtIndices = function(
touches: Array<Object>,
indices: Array<number>
): Array<Object> {
var rippedOut = [];
// use an unsafe downcast to alias to nullable elements,
// so we can delete and then compact.
var temp: Array<?Object> = (touches: Array<any>);
for (var i = 0; i < indices.length; i++) {
var index = indices[i];
rippedOut.push(touches[index]);
touches[index] = null;
temp[index] = null;
}
var fillAt = 0;
for (var j = 0; j < touches.length; j++) {
var cur = touches[j];
for (var j = 0; j < temp.length; j++) {
var cur = temp[j];
if (cur !== null) {
touches[fillAt++] = cur;
temp[fillAt++] = cur;
}
}
touches.length = fillAt;
temp.length = fillAt;
return rippedOut;
};
@ -106,7 +112,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, {
* @param {TopLevelType} topLevelType Top level type of event.
* @param {object} nativeEventParam Object passed from native.
*/
_receiveRootNodeIDEvent: function(rootNodeID, topLevelType, nativeEventParam) {
_receiveRootNodeIDEvent: function(
rootNodeID: ?string,
topLevelType: string,
nativeEventParam: Object
) {
var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT;
ReactIOSEventEmitter.handleTopLevel(
topLevelType,
@ -123,7 +133,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, {
* @param {TopLevelType} topLevelType Top level type of event.
* @param {object} nativeEventParam Object passed from native.
*/
receiveEvent: function(tag, topLevelType, nativeEventParam) {
receiveEvent: function(
tag: number,
topLevelType: string,
nativeEventParam: Object
) {
var rootNodeID = ReactIOSTagHandles.tagToRootNodeID[tag];
ReactIOSEventEmitter._receiveRootNodeIDEvent(
rootNodeID,
@ -156,7 +170,11 @@ var ReactIOSEventEmitter = merge(ReactEventEmitterMixin, {
* Web desktop polyfills only need to construct a fake touch event with
* identifier 0, also abandoning traditional click handlers.
*/
receiveTouches: function(eventTopLevelType, touches, changedIndices) {
receiveTouches: function(
eventTopLevelType: string,
touches: Array<Object>,
changedIndices: Array<number>
) {
var changedTouches =
eventTopLevelType === topLevelTypes.topTouchEnd ||
eventTopLevelType === topLevelTypes.topTouchCancel ?