@tamagui/react-native-use-responder-events 2.0.0-rc.8 → 2.0.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.cjs +293 -152
- package/dist/cjs/ResponderSystem.native.js +312 -170
- package/dist/cjs/ResponderSystem.native.js.map +1 -1
- package/dist/cjs/ResponderTouchHistoryStore.cjs +97 -30
- package/dist/cjs/ResponderTouchHistoryStore.native.js +144 -68
- package/dist/cjs/ResponderTouchHistoryStore.native.js.map +1 -1
- package/dist/cjs/createResponderEvent.cjs +66 -52
- package/dist/cjs/createResponderEvent.native.js +51 -39
- package/dist/cjs/createResponderEvent.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/types.cjs +26 -24
- package/dist/cjs/types.native.js +26 -24
- package/dist/cjs/types.native.js.map +1 -1
- package/dist/cjs/useResponderEvents.cjs +49 -37
- package/dist/cjs/useResponderEvents.native.js +53 -42
- package/dist/cjs/useResponderEvents.native.js.map +1 -1
- package/dist/cjs/utils.cjs +101 -58
- package/dist/cjs/utils.native.js +104 -57
- package/dist/cjs/utils.native.js.map +1 -1
- package/dist/esm/ResponderSystem.mjs +276 -137
- package/dist/esm/ResponderSystem.mjs.map +1 -1
- package/dist/esm/ResponderSystem.native.js +295 -155
- package/dist/esm/ResponderSystem.native.js.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.mjs +85 -20
- package/dist/esm/ResponderTouchHistoryStore.mjs.map +1 -1
- package/dist/esm/ResponderTouchHistoryStore.native.js +132 -58
- package/dist/esm/ResponderTouchHistoryStore.native.js.map +1 -1
- package/dist/esm/createResponderEvent.mjs +54 -42
- package/dist/esm/createResponderEvent.mjs.map +1 -1
- package/dist/esm/createResponderEvent.native.js +38 -28
- package/dist/esm/createResponderEvent.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/types.mjs +14 -14
- package/dist/esm/types.mjs.map +1 -1
- package/dist/esm/types.native.js +14 -14
- package/dist/esm/types.native.js.map +1 -1
- package/dist/esm/useResponderEvents.mjs +21 -11
- package/dist/esm/useResponderEvents.mjs.map +1 -1
- package/dist/esm/useResponderEvents.native.js +25 -16
- package/dist/esm/useResponderEvents.native.js.map +1 -1
- package/dist/esm/utils.mjs +89 -48
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/utils.native.js +92 -47
- package/dist/esm/utils.native.js.map +1 -1
- package/package.json +5 -8
- package/dist/cjs/ResponderSystem.js +0 -205
- package/dist/cjs/ResponderSystem.js.map +0 -6
- package/dist/cjs/ResponderTouchHistoryStore.js +0 -117
- package/dist/cjs/ResponderTouchHistoryStore.js.map +0 -6
- package/dist/cjs/createResponderEvent.js +0 -121
- package/dist/cjs/createResponderEvent.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/types.js +0 -58
- package/dist/cjs/types.js.map +0 -6
- package/dist/cjs/useResponderEvents.js +0 -81
- package/dist/cjs/useResponderEvents.js.map +0 -6
- package/dist/cjs/utils.js +0 -102
- package/dist/cjs/utils.js.map +0 -6
- package/dist/esm/ResponderSystem.js +0 -207
- package/dist/esm/ResponderSystem.js.map +0 -6
- package/dist/esm/ResponderTouchHistoryStore.js +0 -101
- package/dist/esm/ResponderTouchHistoryStore.js.map +0 -6
- package/dist/esm/createResponderEvent.js +0 -105
- package/dist/esm/createResponderEvent.js.map +0 -6
- package/dist/esm/types.js +0 -42
- package/dist/esm/types.js.map +0 -6
- package/dist/esm/useResponderEvents.js +0 -59
- package/dist/esm/useResponderEvents.js.map +0 -6
- package/dist/esm/utils.js +0 -86
- package/dist/esm/utils.js.map +0 -6
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var ResponderTouchHistoryStore_exports = {};
|
|
22
24
|
__export(ResponderTouchHistoryStore_exports, {
|
|
@@ -37,15 +39,35 @@ class ResponderTouchHistoryStore {
|
|
|
37
39
|
};
|
|
38
40
|
recordTouchTrack(topLevelType, nativeEvent) {
|
|
39
41
|
const touchHistory = this._touchHistory;
|
|
40
|
-
if ((0, import_types.isMoveish)(topLevelType))
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
if ((0, import_types.isMoveish)(topLevelType)) {
|
|
43
|
+
nativeEvent.changedTouches.forEach(touch => recordTouchMove(touch, touchHistory));
|
|
44
|
+
} else if ((0, import_types.isStartish)(topLevelType)) {
|
|
45
|
+
nativeEvent.changedTouches.forEach(touch => recordTouchStart(touch, touchHistory));
|
|
46
|
+
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
47
|
+
if (touchHistory.numberActiveTouches === 1) {
|
|
48
|
+
touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
|
49
|
+
}
|
|
50
|
+
} else if ((0, import_types.isEndish)(topLevelType)) {
|
|
51
|
+
nativeEvent.changedTouches.forEach(touch => recordTouchEnd(touch, touchHistory));
|
|
52
|
+
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
53
|
+
if (touchHistory.numberActiveTouches === 1) {
|
|
54
|
+
const {
|
|
55
|
+
touchBank
|
|
56
|
+
} = touchHistory;
|
|
57
|
+
for (let i = 0; i < touchBank.length; i++) {
|
|
58
|
+
const touchTrackToCheck = touchBank[i];
|
|
59
|
+
if (touchTrackToCheck?.touchActive) {
|
|
60
|
+
touchHistory.indexOfSingleActiveTouch = i;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (process.env.NODE_ENV === "development") {
|
|
65
|
+
const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
|
66
|
+
if (!activeRecord?.touchActive) {
|
|
67
|
+
console.error("Cannot find single active touch.");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
47
70
|
}
|
|
48
|
-
process.env.NODE_ENV === "development" && (touchBank[touchHistory.indexOfSingleActiveTouch]?.touchActive || console.error("Cannot find single active touch."));
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
73
|
get touchHistory() {
|
|
@@ -54,11 +76,11 @@ class ResponderTouchHistoryStore {
|
|
|
54
76
|
}
|
|
55
77
|
const MAX_TOUCH_BANK = 20;
|
|
56
78
|
function timestampForTouch(touch) {
|
|
57
|
-
return touch
|
|
79
|
+
return touch["timeStamp"] || touch.timestamp;
|
|
58
80
|
}
|
|
59
81
|
function createTouchRecord(touch) {
|
|
60
82
|
return {
|
|
61
|
-
touchActive:
|
|
83
|
+
touchActive: true,
|
|
62
84
|
startPageX: touch.pageX,
|
|
63
85
|
startPageY: touch.pageY,
|
|
64
86
|
startTimeStamp: timestampForTouch(touch),
|
|
@@ -71,29 +93,71 @@ function createTouchRecord(touch) {
|
|
|
71
93
|
};
|
|
72
94
|
}
|
|
73
95
|
function resetTouchRecord(touchRecord, touch) {
|
|
74
|
-
touchRecord.touchActive =
|
|
96
|
+
touchRecord.touchActive = true;
|
|
97
|
+
touchRecord.startPageX = touch.pageX;
|
|
98
|
+
touchRecord.startPageY = touch.pageY;
|
|
99
|
+
touchRecord.startTimeStamp = timestampForTouch(touch);
|
|
100
|
+
touchRecord.currentPageX = touch.pageX;
|
|
101
|
+
touchRecord.currentPageY = touch.pageY;
|
|
102
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
103
|
+
touchRecord.previousPageX = touch.pageX;
|
|
104
|
+
touchRecord.previousPageY = touch.pageY;
|
|
105
|
+
touchRecord.previousTimeStamp = timestampForTouch(touch);
|
|
75
106
|
}
|
|
76
107
|
function getTouchIdentifier({
|
|
77
108
|
identifier
|
|
78
109
|
}) {
|
|
79
|
-
|
|
110
|
+
if (identifier == null) {
|
|
111
|
+
console.error("Touch object is missing identifier.");
|
|
112
|
+
}
|
|
113
|
+
if (process.env.NODE_ENV === "development") {
|
|
114
|
+
if (identifier > MAX_TOUCH_BANK) {
|
|
115
|
+
console.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);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return identifier;
|
|
80
119
|
}
|
|
81
120
|
function recordTouchStart(touch, touchHistory) {
|
|
82
|
-
const identifier = getTouchIdentifier(touch)
|
|
83
|
-
|
|
84
|
-
|
|
121
|
+
const identifier = getTouchIdentifier(touch);
|
|
122
|
+
const touchRecord = touchHistory.touchBank[identifier];
|
|
123
|
+
if (touchRecord) {
|
|
124
|
+
resetTouchRecord(touchRecord, touch);
|
|
125
|
+
} else {
|
|
126
|
+
touchHistory.touchBank[identifier] = createTouchRecord(touch);
|
|
127
|
+
}
|
|
128
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
85
129
|
}
|
|
86
130
|
function recordTouchMove(touch, touchHistory) {
|
|
87
131
|
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
88
|
-
|
|
89
|
-
|
|
132
|
+
if (touchRecord) {
|
|
133
|
+
touchRecord.touchActive = true;
|
|
134
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
135
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
136
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
137
|
+
touchRecord.currentPageX = touch.pageX;
|
|
138
|
+
touchRecord.currentPageY = touch.pageY;
|
|
139
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
140
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
141
|
+
} else {
|
|
142
|
+
console.warn("Cannot record touch move without a touch start.\n", `Touch Move: ${printTouch(touch)}
|
|
90
143
|
`, `Touch Bank: ${printTouchBank(touchHistory)}`);
|
|
144
|
+
}
|
|
91
145
|
}
|
|
92
146
|
function recordTouchEnd(touch, touchHistory) {
|
|
93
147
|
const touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
94
|
-
|
|
95
|
-
|
|
148
|
+
if (touchRecord) {
|
|
149
|
+
touchRecord.touchActive = false;
|
|
150
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
151
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
152
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
153
|
+
touchRecord.currentPageX = touch.pageX;
|
|
154
|
+
touchRecord.currentPageY = touch.pageY;
|
|
155
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
156
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
157
|
+
} else {
|
|
158
|
+
console.warn("Cannot record touch end without a touch start.\n", `Touch End: ${printTouch(touch)}
|
|
96
159
|
`, `Touch Bank: ${printTouchBank(touchHistory)}`);
|
|
160
|
+
}
|
|
97
161
|
}
|
|
98
162
|
function printTouch(touch) {
|
|
99
163
|
return JSON.stringify({
|
|
@@ -108,5 +172,8 @@ function printTouchBank(touchHistory) {
|
|
|
108
172
|
touchBank
|
|
109
173
|
} = touchHistory;
|
|
110
174
|
let printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
111
|
-
|
|
175
|
+
if (touchBank.length > MAX_TOUCH_BANK) {
|
|
176
|
+
printed += ` (original size: ${touchBank.length})`;
|
|
177
|
+
}
|
|
178
|
+
return printed;
|
|
112
179
|
}
|
|
@@ -5,20 +5,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var ResponderTouchHistoryStore_exports = {};
|
|
24
26
|
__export(ResponderTouchHistoryStore_exports, {
|
|
@@ -27,80 +29,109 @@ __export(ResponderTouchHistoryStore_exports, {
|
|
|
27
29
|
module.exports = __toCommonJS(ResponderTouchHistoryStore_exports);
|
|
28
30
|
var import_types = require("./types.native.js");
|
|
29
31
|
function _class_call_check(instance, Constructor) {
|
|
30
|
-
if (!(instance instanceof Constructor))
|
|
32
|
+
if (!(instance instanceof Constructor)) {
|
|
33
|
+
throw new TypeError("Cannot call a class as a function");
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
function _defineProperties(target, props) {
|
|
33
37
|
for (var i = 0; i < props.length; i++) {
|
|
34
38
|
var descriptor = props[i];
|
|
35
|
-
descriptor.enumerable = descriptor.enumerable ||
|
|
39
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
40
|
+
descriptor.configurable = true;
|
|
41
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
42
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
36
43
|
}
|
|
37
44
|
}
|
|
38
45
|
function _create_class(Constructor, protoProps, staticProps) {
|
|
39
|
-
|
|
46
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
47
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
48
|
+
return Constructor;
|
|
40
49
|
}
|
|
41
50
|
function _define_property(obj, key, value) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
if (key in obj) {
|
|
52
|
+
Object.defineProperty(obj, key, {
|
|
53
|
+
value,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
} else {
|
|
59
|
+
obj[key] = value;
|
|
60
|
+
}
|
|
61
|
+
return obj;
|
|
48
62
|
}
|
|
49
63
|
var ResponderTouchHistoryStore = /* @__PURE__ */function () {
|
|
50
|
-
|
|
64
|
+
"use strict";
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
function ResponderTouchHistoryStore2() {
|
|
67
|
+
_class_call_check(this, ResponderTouchHistoryStore2);
|
|
68
|
+
_define_property(this, "_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
|
+
});
|
|
78
|
+
}
|
|
79
|
+
_create_class(ResponderTouchHistoryStore2, [{
|
|
80
|
+
key: "recordTouchTrack",
|
|
81
|
+
value: function recordTouchTrack(topLevelType, nativeEvent) {
|
|
82
|
+
var touchHistory = this._touchHistory;
|
|
83
|
+
if ((0, import_types.isMoveish)(topLevelType)) {
|
|
84
|
+
nativeEvent.changedTouches.forEach(function (touch) {
|
|
69
85
|
return recordTouchMove(touch, touchHistory);
|
|
70
|
-
});
|
|
86
|
+
});
|
|
87
|
+
} else if ((0, import_types.isStartish)(topLevelType)) {
|
|
88
|
+
nativeEvent.changedTouches.forEach(function (touch) {
|
|
71
89
|
return recordTouchStart(touch, touchHistory);
|
|
72
|
-
})
|
|
90
|
+
});
|
|
91
|
+
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
92
|
+
if (touchHistory.numberActiveTouches === 1) {
|
|
93
|
+
touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
|
94
|
+
}
|
|
95
|
+
} else if ((0, import_types.isEndish)(topLevelType)) {
|
|
96
|
+
nativeEvent.changedTouches.forEach(function (touch) {
|
|
73
97
|
return recordTouchEnd(touch, touchHistory);
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
});
|
|
99
|
+
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
100
|
+
if (touchHistory.numberActiveTouches === 1) {
|
|
101
|
+
var {
|
|
102
|
+
touchBank
|
|
103
|
+
} = touchHistory;
|
|
104
|
+
for (var i = 0; i < touchBank.length; i++) {
|
|
78
105
|
var touchTrackToCheck = touchBank[i];
|
|
79
|
-
if (touchTrackToCheck
|
|
106
|
+
if (touchTrackToCheck === null || touchTrackToCheck === void 0 ? void 0 : touchTrackToCheck.touchActive) {
|
|
80
107
|
touchHistory.indexOfSingleActiveTouch = i;
|
|
81
108
|
break;
|
|
82
109
|
}
|
|
83
110
|
}
|
|
84
111
|
if (process.env.NODE_ENV === "development") {
|
|
85
112
|
var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
|
86
|
-
activeRecord
|
|
113
|
+
if (!(activeRecord === null || activeRecord === void 0 ? void 0 : activeRecord.touchActive)) {
|
|
114
|
+
console.error("Cannot find single active touch.");
|
|
115
|
+
}
|
|
87
116
|
}
|
|
88
117
|
}
|
|
89
118
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
119
|
+
}
|
|
120
|
+
}, {
|
|
121
|
+
key: "touchHistory",
|
|
122
|
+
get: function get() {
|
|
123
|
+
return this._touchHistory;
|
|
124
|
+
}
|
|
125
|
+
}]);
|
|
126
|
+
return ResponderTouchHistoryStore2;
|
|
127
|
+
}();
|
|
128
|
+
var MAX_TOUCH_BANK = 20;
|
|
98
129
|
function timestampForTouch(touch) {
|
|
99
|
-
return touch
|
|
130
|
+
return touch["timeStamp"] || touch.timestamp;
|
|
100
131
|
}
|
|
101
132
|
function createTouchRecord(touch) {
|
|
102
133
|
return {
|
|
103
|
-
touchActive:
|
|
134
|
+
touchActive: true,
|
|
104
135
|
startPageX: touch.pageX,
|
|
105
136
|
startPageY: touch.pageY,
|
|
106
137
|
startTimeStamp: timestampForTouch(touch),
|
|
@@ -113,30 +144,72 @@ function createTouchRecord(touch) {
|
|
|
113
144
|
};
|
|
114
145
|
}
|
|
115
146
|
function resetTouchRecord(touchRecord, touch) {
|
|
116
|
-
touchRecord.touchActive =
|
|
147
|
+
touchRecord.touchActive = true;
|
|
148
|
+
touchRecord.startPageX = touch.pageX;
|
|
149
|
+
touchRecord.startPageY = touch.pageY;
|
|
150
|
+
touchRecord.startTimeStamp = timestampForTouch(touch);
|
|
151
|
+
touchRecord.currentPageX = touch.pageX;
|
|
152
|
+
touchRecord.currentPageY = touch.pageY;
|
|
153
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
154
|
+
touchRecord.previousPageX = touch.pageX;
|
|
155
|
+
touchRecord.previousPageY = touch.pageY;
|
|
156
|
+
touchRecord.previousTimeStamp = timestampForTouch(touch);
|
|
117
157
|
}
|
|
118
158
|
function getTouchIdentifier(param) {
|
|
119
159
|
var {
|
|
120
160
|
identifier
|
|
121
161
|
} = param;
|
|
122
|
-
|
|
162
|
+
if (identifier == null) {
|
|
163
|
+
console.error("Touch object is missing identifier.");
|
|
164
|
+
}
|
|
165
|
+
if (process.env.NODE_ENV === "development") {
|
|
166
|
+
if (identifier > MAX_TOUCH_BANK) {
|
|
167
|
+
console.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);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return identifier;
|
|
123
171
|
}
|
|
124
172
|
function recordTouchStart(touch, touchHistory) {
|
|
125
|
-
var identifier = getTouchIdentifier(touch)
|
|
126
|
-
|
|
127
|
-
|
|
173
|
+
var identifier = getTouchIdentifier(touch);
|
|
174
|
+
var touchRecord = touchHistory.touchBank[identifier];
|
|
175
|
+
if (touchRecord) {
|
|
176
|
+
resetTouchRecord(touchRecord, touch);
|
|
177
|
+
} else {
|
|
178
|
+
touchHistory.touchBank[identifier] = createTouchRecord(touch);
|
|
179
|
+
}
|
|
180
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
128
181
|
}
|
|
129
182
|
function recordTouchMove(touch, touchHistory) {
|
|
130
183
|
var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
131
|
-
|
|
132
|
-
|
|
184
|
+
if (touchRecord) {
|
|
185
|
+
touchRecord.touchActive = true;
|
|
186
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
187
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
188
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
189
|
+
touchRecord.currentPageX = touch.pageX;
|
|
190
|
+
touchRecord.currentPageY = touch.pageY;
|
|
191
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
192
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
193
|
+
} else {
|
|
194
|
+
console.warn("Cannot record touch move without a touch start.\n", `Touch Move: ${printTouch(touch)}
|
|
133
195
|
`, `Touch Bank: ${printTouchBank(touchHistory)}`);
|
|
196
|
+
}
|
|
134
197
|
}
|
|
135
198
|
function recordTouchEnd(touch, touchHistory) {
|
|
136
199
|
var touchRecord = touchHistory.touchBank[getTouchIdentifier(touch)];
|
|
137
|
-
|
|
138
|
-
|
|
200
|
+
if (touchRecord) {
|
|
201
|
+
touchRecord.touchActive = false;
|
|
202
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
203
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
204
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
205
|
+
touchRecord.currentPageX = touch.pageX;
|
|
206
|
+
touchRecord.currentPageY = touch.pageY;
|
|
207
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
208
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
209
|
+
} else {
|
|
210
|
+
console.warn("Cannot record touch end without a touch start.\n", `Touch End: ${printTouch(touch)}
|
|
139
211
|
`, `Touch Bank: ${printTouchBank(touchHistory)}`);
|
|
212
|
+
}
|
|
140
213
|
}
|
|
141
214
|
function printTouch(touch) {
|
|
142
215
|
return JSON.stringify({
|
|
@@ -148,9 +221,12 @@ function printTouch(touch) {
|
|
|
148
221
|
}
|
|
149
222
|
function printTouchBank(touchHistory) {
|
|
150
223
|
var {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
224
|
+
touchBank
|
|
225
|
+
} = touchHistory;
|
|
226
|
+
var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
227
|
+
if (touchBank.length > MAX_TOUCH_BANK) {
|
|
228
|
+
printed += ` (original size: ${touchBank.length})`;
|
|
229
|
+
}
|
|
230
|
+
return printed;
|
|
155
231
|
}
|
|
156
232
|
//# sourceMappingURL=ResponderTouchHistoryStore.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ResponderTouchHistoryStore_exports","__export","ResponderTouchHistoryStore","module","exports","import_types","require","_class_call_check","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","prototype","_define_property","obj","ResponderTouchHistoryStore2","touchBank","numberActiveTouches","indexOfSingleActiveTouch","mostRecentTimeStamp","topLevelType","nativeEvent","touchHistory","_touchHistory","isMoveish","changedTouches","forEach","touch","recordTouchMove","isStartish","recordTouchStart","touches","identifier","isEndish","recordTouchEnd","touchTrackToCheck","touchActive","process","env","NODE_ENV","activeRecord","console","error","get","MAX_TOUCH_BANK","timestampForTouch","
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","ResponderTouchHistoryStore_exports","__export","ResponderTouchHistoryStore","module","exports","import_types","require","_class_call_check","instance","Constructor","TypeError","_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_create_class","protoProps","staticProps","prototype","_define_property","obj","ResponderTouchHistoryStore2","touchBank","numberActiveTouches","indexOfSingleActiveTouch","mostRecentTimeStamp","recordTouchTrack","topLevelType","nativeEvent","touchHistory","_touchHistory","isMoveish","changedTouches","forEach","touch","recordTouchMove","isStartish","recordTouchStart","touches","identifier","isEndish","recordTouchEnd","touchTrackToCheck","touchActive","process","env","NODE_ENV","activeRecord","console","error","get","MAX_TOUCH_BANK","timestampForTouch","timestamp","createTouchRecord","startPageX","pageX","startPageY","pageY","startTimeStamp","currentPageX","currentPageY","currentTimeStamp","previousPageX","previousPageY","previousTimeStamp","resetTouchRecord","touchRecord","getTouchIdentifier","param"],"sources":["../../src/ResponderTouchHistoryStore.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,kCAAA;AAAAC,QAAA,CAAAD,kCAAA;EAAAE,0BAAA,EAAAA,CAAA,KAAAA;AAAA;AAQAC,MAAA,CAAAC,OAAA,GAAAT,YAAgD,CAAAK,kCAAA;AAEzC,IAAAK,YAAM,GAAAC,OAAA,oBAA2B;AAAA,SACtCC,iBAAgBA,CAAAC,QAAA,EAAAC,WAAA;EAAA,IACd,EAAAD,QAAY,YAAAC,WAAA;IAAA,UAAAC,SAAA;EAAA;AACS;AAAA,SAAAC,kBAAAC,MAAA,EAAAC,KAAA;EAAA,SAAAC,CAAA,MAAAA,CAAA,GAAAD,KAAA,CAAAE,MAAA,EAAAD,CAAA;IAIrB,IAAAE,UAAA,GAAAH,KAAA,CAAAC,CAAA;IACAE,UAAA,CAAAC,UAAqB,GAAAD,UAAA,CAAAC,UAAA;IACvBD,UAAA,CAAAE,YAAA;IAEA,eAAiBF,UAAA,EA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