@react-native-oh-tpl/react-native-gesture-handler 2.12.6-1 → 2.12.9
Sign up to get free protection for your applications and to get access to all the features.
- package/harmony/gesture_handler/BuildProfile.ets +5 -0
- package/harmony/gesture_handler/build-profile.json5 +18 -7
- package/harmony/gesture_handler/hvigorfile.ts +2 -2
- package/harmony/gesture_handler/index.ets +3 -3
- package/harmony/gesture_handler/oh-package-lock.json5 +17 -0
- package/harmony/gesture_handler/oh-package.json5 +12 -11
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +103 -34
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +21 -15
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +36 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentInstance.h +27 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonJSIBinder.h +32 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +22 -17
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +15 -12
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerPackage.h +72 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +36 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentInstance.h +78 -0
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewJSIBinder.h +25 -0
- package/harmony/gesture_handler/src/main/ets/CircularBuffer.ts +42 -42
- package/harmony/gesture_handler/src/main/ets/Event.ts +67 -67
- package/harmony/gesture_handler/src/main/ets/EventDispatcher.ts +52 -37
- package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
- package/harmony/gesture_handler/src/main/ets/{GestureHandlerArkUIAdapter.ets → GestureHandlerArkUIAdapter.ts} +202 -201
- package/harmony/gesture_handler/src/main/ets/GestureHandlerFactory.ts +44 -44
- package/harmony/gesture_handler/src/main/ets/GestureHandlerOrchestrator.ts +280 -280
- package/harmony/gesture_handler/src/main/ets/GestureHandlerPackage.ts +22 -22
- package/harmony/gesture_handler/src/main/ets/GestureHandlerRegistry.ts +27 -27
- package/harmony/gesture_handler/src/main/ets/InteractionManager.ts +108 -108
- package/harmony/gesture_handler/src/main/ets/LeastSquareSolver.ts +182 -182
- package/harmony/gesture_handler/src/main/ets/NativeViewGestureHandler.ts +114 -114
- package/harmony/gesture_handler/src/main/ets/OutgoingEvent.ts +33 -33
- package/harmony/gesture_handler/src/main/ets/PanGestureHandler.ts +327 -327
- package/harmony/gesture_handler/src/main/ets/PointerTracker.ts +239 -239
- package/harmony/gesture_handler/src/main/ets/RNGHError.ts +4 -4
- package/harmony/gesture_handler/src/main/ets/RNGHLogger.ts +47 -28
- package/harmony/gesture_handler/src/main/ets/{RNGHRootTouchHandler.ets → RNGHRootTouchHandlerArkTS.ts} +59 -57
- package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandlerCAPI.ts +87 -0
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +37 -36
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +183 -125
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +52 -55
- package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +23 -11
- package/harmony/gesture_handler/src/main/ets/State.ts +46 -46
- package/harmony/gesture_handler/src/main/ets/TapGestureHandler.ts +205 -205
- package/harmony/gesture_handler/src/main/ets/Vector2D.ts +36 -36
- package/harmony/gesture_handler/src/main/ets/VelocityTracker.ts +98 -98
- package/harmony/gesture_handler/src/main/ets/View.ts +70 -70
- package/harmony/gesture_handler/src/main/ets/ViewRegistry.ts +42 -42
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerButton.ts +140 -0
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerModule.ts +25 -0
- package/harmony/gesture_handler/src/main/ets/namespace/RNGestureHandlerRootView.ts +101 -0
- package/harmony/gesture_handler/src/main/ets/namespace/ts.ts +3 -0
- package/harmony/gesture_handler/src/main/ets/pages/Index.ets +16 -16
- package/harmony/gesture_handler/src/main/ets/types.ts +25 -0
- package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
- package/harmony/gesture_handler/src/main/module.json5 +7 -7
- package/harmony/gesture_handler/src/main/resources/base/element/color.json +7 -7
- package/harmony/gesture_handler/src/main/resources/base/element/string.json +15 -15
- package/harmony/gesture_handler/src/main/resources/base/profile/main_pages.json +5 -5
- package/harmony/gesture_handler/src/main/resources/en_US/element/string.json +15 -15
- package/harmony/gesture_handler/src/main/resources/zh_CN/element/string.json +15 -15
- package/harmony/gesture_handler/ts.ts +2 -1
- package/harmony/gesture_handler.har +0 -0
- package/lib/commonjs/RNGestureHandlerModule.js +6 -3
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js +5 -13
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +31 -28
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/index.js +42 -19
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +10 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js +11 -0
- package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js +11 -0
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +3 -2
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js +3 -11
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/handlers/createHandler.js +20 -19
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/index.js +6 -14
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js +3 -0
- package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -0
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js +3 -0
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +2 -6
- package/lib/typescript/RNGestureHandlerModule.d.ts.map +1 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +6 -6
- package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
- package/lib/typescript/handlers/createHandler.d.ts +11 -11
- package/lib/typescript/handlers/createHandler.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +9 -8
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +15 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +15 -0
- package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +7 -0
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -0
- package/package.json +66 -70
- package/src/RNGestureHandlerModule.ts +5 -6
- package/src/components/GestureHandlerRootView.tsx +23 -34
- package/src/handlers/createHandler.tsx +534 -535
- package/src/index.ts +172 -172
- package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
- package/src/specs/RNGestureHandlerButtonNativeComponent.ts +18 -0
- package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -0
- package/README.md +0 -1
- package/lib/commonjs/components/GestureButtons.js +0 -186
- package/lib/commonjs/components/GestureButtons.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerButton.js +0 -9
- package/lib/commonjs/components/GestureHandlerButton.js.map +0 -1
- package/lib/commonjs/components/RNGestureHandlerButton.js +0 -23
- package/lib/commonjs/components/RNGestureHandlerButton.js.map +0 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +0 -247
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +0 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +0 -58
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +0 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js +0 -18
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +0 -1
- package/lib/commonjs/components/touchables/index.js +0 -21
- package/lib/commonjs/components/touchables/index.js.map +0 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +0 -19
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +0 -103
- package/lib/commonjs/handlers/PanGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/TapGestureHandler.js +0 -22
- package/lib/commonjs/handlers/TapGestureHandler.js.map +0 -1
- package/lib/commonjs/handlers/createNativeWrapper.js +0 -64
- package/lib/commonjs/handlers/createNativeWrapper.js.map +0 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +0 -22
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +0 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +0 -554
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/commonjs/init.js +0 -24
- package/lib/commonjs/init.js.map +0 -1
- package/lib/module/components/GestureButtons.js +0 -168
- package/lib/module/components/GestureButtons.js.map +0 -1
- package/lib/module/components/GestureHandlerButton.js +0 -3
- package/lib/module/components/GestureHandlerButton.js.map +0 -1
- package/lib/module/components/RNGestureHandlerButton.js +0 -17
- package/lib/module/components/RNGestureHandlerButton.js.map +0 -1
- package/lib/module/components/touchables/GenericTouchable.js +0 -238
- package/lib/module/components/touchables/GenericTouchable.js.map +0 -1
- package/lib/module/components/touchables/TouchableOpacity.js +0 -49
- package/lib/module/components/touchables/TouchableOpacity.js.map +0 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js +0 -9
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +0 -1
- package/lib/module/components/touchables/index.js +0 -8
- package/lib/module/components/touchables/index.js.map +0 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +0 -12
- package/lib/module/handlers/NativeViewGestureHandler.js.map +0 -1
- package/lib/module/handlers/PanGestureHandler.js +0 -92
- package/lib/module/handlers/PanGestureHandler.js.map +0 -1
- package/lib/module/handlers/TapGestureHandler.js +0 -14
- package/lib/module/handlers/TapGestureHandler.js.map +0 -1
- package/lib/module/handlers/createNativeWrapper.js +0 -57
- package/lib/module/handlers/createNativeWrapper.js.map +0 -1
- package/lib/module/handlers/gestureHandlerCommon.js +0 -15
- package/lib/module/handlers/gestureHandlerCommon.js.map +0 -1
- package/lib/module/handlers/gestures/GestureDetector.js +0 -543
- package/lib/module/handlers/gestures/GestureDetector.js.map +0 -1
- package/lib/module/init.js +0 -17
- package/lib/module/init.js.map +0 -1
- package/lib/typescript/components/GestureButtons.d.ts +0 -122
- package/lib/typescript/components/GestureButtons.d.ts.map +0 -1
- package/lib/typescript/components/GestureHandlerButton.d.ts +0 -5
- package/lib/typescript/components/GestureHandlerButton.d.ts.map +0 -1
- package/lib/typescript/components/RNGestureHandlerButton.d.ts +0 -2
- package/lib/typescript/components/RNGestureHandlerButton.d.ts.map +0 -1
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -68
- package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +0 -1
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -26
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts.map +0 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -8
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts.map +0 -1
- package/lib/typescript/components/touchables/index.d.ts +0 -4
- package/lib/typescript/components/touchables/index.d.ts.map +0 -1
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -29
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -140
- package/lib/typescript/handlers/PanGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -58
- package/lib/typescript/handlers/TapGestureHandler.d.ts.map +0 -1
- package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -4
- package/lib/typescript/handlers/createNativeWrapper.d.ts.map +0 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -2
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts.map +0 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -24
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts.map +0 -1
- package/lib/typescript/init.d.ts +0 -3
- package/lib/typescript/init.d.ts.map +0 -1
- package/src/components/GestureButtons.tsx +0 -334
- package/src/components/GestureHandlerButton.tsx +0 -5
- package/src/components/RNGestureHandlerButton.tsx +0 -23
- package/src/components/touchables/GenericTouchable.tsx +0 -301
- package/src/components/touchables/TouchableOpacity.tsx +0 -76
- package/src/components/touchables/TouchableWithoutFeedback.tsx +0 -14
- package/src/components/touchables/index.ts +0 -7
- package/src/handlers/NativeViewGestureHandler.ts +0 -55
- package/src/handlers/PanGestureHandler.ts +0 -327
- package/src/handlers/TapGestureHandler.ts +0 -95
- package/src/handlers/createNativeWrapper.tsx +0 -81
- package/src/handlers/gestureHandlerCommon.ts +0 -15
- package/src/handlers/gestures/GestureDetector.tsx +0 -823
- package/src/init.ts +0 -18
@@ -1,36 +1,36 @@
|
|
1
|
-
export class Vector2D {
|
2
|
-
constructor(
|
3
|
-
private val: {
|
4
|
-
x: number;
|
5
|
-
y: number;
|
6
|
-
} = {x: 0, y: 0},
|
7
|
-
) {}
|
8
|
-
|
9
|
-
get x() {
|
10
|
-
return this.val.x;
|
11
|
-
}
|
12
|
-
|
13
|
-
get y() {
|
14
|
-
return this.val.y;
|
15
|
-
}
|
16
|
-
|
17
|
-
get value() {
|
18
|
-
return {...this.val};
|
19
|
-
}
|
20
|
-
|
21
|
-
public clone() {
|
22
|
-
return new Vector2D({...this.val});
|
23
|
-
}
|
24
|
-
|
25
|
-
public subtract(vec: Vector2D) {
|
26
|
-
this.val.x -= vec.x;
|
27
|
-
this.val.y -= vec.y;
|
28
|
-
return this;
|
29
|
-
}
|
30
|
-
|
31
|
-
public add(vec: Vector2D) {
|
32
|
-
this.val.x += vec.x;
|
33
|
-
this.val.y += vec.y;
|
34
|
-
return this;
|
35
|
-
}
|
36
|
-
}
|
1
|
+
export class Vector2D {
|
2
|
+
constructor(
|
3
|
+
private val: {
|
4
|
+
x: number;
|
5
|
+
y: number;
|
6
|
+
} = {x: 0, y: 0},
|
7
|
+
) {}
|
8
|
+
|
9
|
+
get x() {
|
10
|
+
return this.val.x;
|
11
|
+
}
|
12
|
+
|
13
|
+
get y() {
|
14
|
+
return this.val.y;
|
15
|
+
}
|
16
|
+
|
17
|
+
get value() {
|
18
|
+
return {...this.val};
|
19
|
+
}
|
20
|
+
|
21
|
+
public clone() {
|
22
|
+
return new Vector2D({...this.val});
|
23
|
+
}
|
24
|
+
|
25
|
+
public subtract(vec: Vector2D) {
|
26
|
+
this.val.x -= vec.x;
|
27
|
+
this.val.y -= vec.y;
|
28
|
+
return this;
|
29
|
+
}
|
30
|
+
|
31
|
+
public add(vec: Vector2D) {
|
32
|
+
this.val.x += vec.x;
|
33
|
+
this.val.y += vec.y;
|
34
|
+
return this;
|
35
|
+
}
|
36
|
+
}
|
@@ -1,98 +1,98 @@
|
|
1
|
-
import { AdaptedEvent } from './Event';
|
2
|
-
import { CircularBuffer } from './CircularBuffer';
|
3
|
-
import { LeastSquareSolver } from './LeastSquareSolver';
|
4
|
-
|
5
|
-
export default class VelocityTracker {
|
6
|
-
private assumePointerMoveStoppedMilliseconds = 40;
|
7
|
-
private historySize = 20;
|
8
|
-
private horizonMilliseconds = 300;
|
9
|
-
private minSampleSize = 3;
|
10
|
-
|
11
|
-
private samples: CircularBuffer<AdaptedEvent>;
|
12
|
-
|
13
|
-
constructor() {
|
14
|
-
this.samples = new CircularBuffer<AdaptedEvent>(this.historySize);
|
15
|
-
}
|
16
|
-
|
17
|
-
public add(event: AdaptedEvent): void {
|
18
|
-
this.samples.push(event);
|
19
|
-
}
|
20
|
-
|
21
|
-
/// Returns an estimate of the velocity of the object being tracked by the
|
22
|
-
/// tracker given the current information available to the tracker.
|
23
|
-
///
|
24
|
-
/// Information is added using [addPosition].
|
25
|
-
///
|
26
|
-
/// Returns null if there is no data on which to base an estimate.
|
27
|
-
private getVelocityEstimate(): [number, number] | null {
|
28
|
-
const x = [];
|
29
|
-
const y = [];
|
30
|
-
const w = [];
|
31
|
-
const time = [];
|
32
|
-
|
33
|
-
let sampleCount = 0;
|
34
|
-
let index = this.samples.size - 1;
|
35
|
-
const newestSample = this.samples.get(index);
|
36
|
-
if (!newestSample) {
|
37
|
-
return null;
|
38
|
-
}
|
39
|
-
|
40
|
-
let previousSample = newestSample;
|
41
|
-
|
42
|
-
// Starting with the most recent PointAtTime sample, iterate backwards while
|
43
|
-
// the samples represent continuous motion.
|
44
|
-
while (sampleCount < this.samples.size) {
|
45
|
-
const sample = this.samples.get(index);
|
46
|
-
|
47
|
-
const age = newestSample.time - sample.time;
|
48
|
-
const delta = Math.abs(sample.time - previousSample.time);
|
49
|
-
previousSample = sample;
|
50
|
-
|
51
|
-
if (
|
52
|
-
age > this.horizonMilliseconds ||
|
53
|
-
delta > this.assumePointerMoveStoppedMilliseconds
|
54
|
-
) {
|
55
|
-
break;
|
56
|
-
}
|
57
|
-
|
58
|
-
x.push(sample.x);
|
59
|
-
y.push(sample.y);
|
60
|
-
w.push(1);
|
61
|
-
time.push(-age);
|
62
|
-
|
63
|
-
sampleCount++;
|
64
|
-
index--;
|
65
|
-
}
|
66
|
-
|
67
|
-
if (sampleCount >= this.minSampleSize) {
|
68
|
-
const xSolver = new LeastSquareSolver(time, x, w);
|
69
|
-
const xFit = xSolver.solve(2);
|
70
|
-
|
71
|
-
if (xFit !== null) {
|
72
|
-
const ySolver = new LeastSquareSolver(time, y, w);
|
73
|
-
const yFit = ySolver.solve(2);
|
74
|
-
|
75
|
-
if (yFit !== null) {
|
76
|
-
const xVelocity = xFit.coefficients[1] * 1000;
|
77
|
-
const yVelocity = yFit.coefficients[1] * 1000;
|
78
|
-
|
79
|
-
return [xVelocity, yVelocity];
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
return null;
|
85
|
-
}
|
86
|
-
|
87
|
-
public getVelocity(): [number, number] {
|
88
|
-
const estimate = this.getVelocityEstimate();
|
89
|
-
if (estimate !== null) {
|
90
|
-
return estimate;
|
91
|
-
}
|
92
|
-
return [0, 0];
|
93
|
-
}
|
94
|
-
|
95
|
-
public reset(): void {
|
96
|
-
this.samples.clear();
|
97
|
-
}
|
98
|
-
}
|
1
|
+
import { AdaptedEvent } from './Event';
|
2
|
+
import { CircularBuffer } from './CircularBuffer';
|
3
|
+
import { LeastSquareSolver } from './LeastSquareSolver';
|
4
|
+
|
5
|
+
export default class VelocityTracker {
|
6
|
+
private assumePointerMoveStoppedMilliseconds = 40;
|
7
|
+
private historySize = 20;
|
8
|
+
private horizonMilliseconds = 300;
|
9
|
+
private minSampleSize = 3;
|
10
|
+
|
11
|
+
private samples: CircularBuffer<AdaptedEvent>;
|
12
|
+
|
13
|
+
constructor() {
|
14
|
+
this.samples = new CircularBuffer<AdaptedEvent>(this.historySize);
|
15
|
+
}
|
16
|
+
|
17
|
+
public add(event: AdaptedEvent): void {
|
18
|
+
this.samples.push(event);
|
19
|
+
}
|
20
|
+
|
21
|
+
/// Returns an estimate of the velocity of the object being tracked by the
|
22
|
+
/// tracker given the current information available to the tracker.
|
23
|
+
///
|
24
|
+
/// Information is added using [addPosition].
|
25
|
+
///
|
26
|
+
/// Returns null if there is no data on which to base an estimate.
|
27
|
+
private getVelocityEstimate(): [number, number] | null {
|
28
|
+
const x = [];
|
29
|
+
const y = [];
|
30
|
+
const w = [];
|
31
|
+
const time = [];
|
32
|
+
|
33
|
+
let sampleCount = 0;
|
34
|
+
let index = this.samples.size - 1;
|
35
|
+
const newestSample = this.samples.get(index);
|
36
|
+
if (!newestSample) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
|
40
|
+
let previousSample = newestSample;
|
41
|
+
|
42
|
+
// Starting with the most recent PointAtTime sample, iterate backwards while
|
43
|
+
// the samples represent continuous motion.
|
44
|
+
while (sampleCount < this.samples.size) {
|
45
|
+
const sample = this.samples.get(index);
|
46
|
+
|
47
|
+
const age = newestSample.time - sample.time;
|
48
|
+
const delta = Math.abs(sample.time - previousSample.time);
|
49
|
+
previousSample = sample;
|
50
|
+
|
51
|
+
if (
|
52
|
+
age > this.horizonMilliseconds ||
|
53
|
+
delta > this.assumePointerMoveStoppedMilliseconds
|
54
|
+
) {
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
|
58
|
+
x.push(sample.x);
|
59
|
+
y.push(sample.y);
|
60
|
+
w.push(1);
|
61
|
+
time.push(-age);
|
62
|
+
|
63
|
+
sampleCount++;
|
64
|
+
index--;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (sampleCount >= this.minSampleSize) {
|
68
|
+
const xSolver = new LeastSquareSolver(time, x, w);
|
69
|
+
const xFit = xSolver.solve(2);
|
70
|
+
|
71
|
+
if (xFit !== null) {
|
72
|
+
const ySolver = new LeastSquareSolver(time, y, w);
|
73
|
+
const yFit = ySolver.solve(2);
|
74
|
+
|
75
|
+
if (yFit !== null) {
|
76
|
+
const xVelocity = xFit.coefficients[1] * 1000;
|
77
|
+
const yVelocity = yFit.coefficients[1] * 1000;
|
78
|
+
|
79
|
+
return [xVelocity, yVelocity];
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
return null;
|
85
|
+
}
|
86
|
+
|
87
|
+
public getVelocity(): [number, number] {
|
88
|
+
const estimate = this.getVelocityEstimate();
|
89
|
+
if (estimate !== null) {
|
90
|
+
return estimate;
|
91
|
+
}
|
92
|
+
return [0, 0];
|
93
|
+
}
|
94
|
+
|
95
|
+
public reset(): void {
|
96
|
+
this.samples.clear();
|
97
|
+
}
|
98
|
+
}
|
@@ -1,71 +1,71 @@
|
|
1
|
-
import { DescriptorRegistry, Descriptor, Tag } from "rnoh/ts"
|
2
|
-
import { Vector2D } from "./Vector2D"
|
3
|
-
|
4
|
-
export type BoundingBox = {
|
5
|
-
x: number,
|
6
|
-
y: number,
|
7
|
-
width: number,
|
8
|
-
height: number
|
9
|
-
}
|
10
|
-
|
11
|
-
export class View {
|
12
|
-
constructor(private descriptorRegistry: DescriptorRegistry, private viewTag: number) {
|
13
|
-
}
|
14
|
-
|
15
|
-
public getChildren() {
|
16
|
-
return this.getDescriptor().childrenTags.map(childrenTag => {
|
17
|
-
return new View(this.descriptorRegistry, childrenTag)
|
18
|
-
})
|
19
|
-
}
|
20
|
-
|
21
|
-
public getTag(): Tag {
|
22
|
-
return this.viewTag
|
23
|
-
}
|
24
|
-
|
25
|
-
public isPositionInBounds({x, y}: {
|
26
|
-
x: number,
|
27
|
-
y: number
|
28
|
-
}): boolean {
|
29
|
-
const rect = this.getBoundingRect()
|
30
|
-
return x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height);
|
31
|
-
}
|
32
|
-
|
33
|
-
public getBoundingRect(): BoundingBox {
|
34
|
-
const d = this.getDescriptor()
|
35
|
-
if (!d) {
|
36
|
-
return { x: 0, y: 0, width: 0, height: 0 }
|
37
|
-
}
|
38
|
-
const offsetToAbsolutePosition = this.getOffsetToAbsolutePosition()
|
39
|
-
return {
|
40
|
-
x: d.layoutMetrics.frame.origin.x - offsetToAbsolutePosition.x,
|
41
|
-
y: d.layoutMetrics.frame.origin.y - offsetToAbsolutePosition.y,
|
42
|
-
width: d.layoutMetrics.frame.size.width,
|
43
|
-
height: d.layoutMetrics.frame.size.height
|
44
|
-
}
|
45
|
-
}
|
46
|
-
|
47
|
-
private getDescriptor() {
|
48
|
-
return this.descriptorRegistry.getDescriptor(this.viewTag)
|
49
|
-
}
|
50
|
-
|
51
|
-
|
52
|
-
private getOffsetToAbsolutePosition(): Vector2D {
|
53
|
-
const currentOffset = new Vector2D()
|
54
|
-
let parentTag = this.getDescriptor()?.parentTag
|
55
|
-
while (parentTag !== undefined) {
|
56
|
-
const d = this.descriptorRegistry.getDescriptor(parentTag)
|
57
|
-
currentOffset.add(this.extractScrollOffsetFromDescriptor(d))
|
58
|
-
currentOffset.subtract(new Vector2D(d.layoutMetrics.frame.origin))
|
59
|
-
parentTag = d.parentTag
|
60
|
-
}
|
61
|
-
return currentOffset
|
62
|
-
}
|
63
|
-
|
64
|
-
private extractScrollOffsetFromDescriptor(descriptor: Descriptor<any>) {
|
65
|
-
if (descriptor.type !== "ScrollView") {
|
66
|
-
return new Vector2D();
|
67
|
-
}
|
68
|
-
const scrollViewState: any = descriptor.state;
|
69
|
-
return new Vector2D({ x: scrollViewState.contentOffsetX, y: scrollViewState.contentOffsetY })
|
70
|
-
}
|
1
|
+
import { DescriptorRegistry, Descriptor, Tag } from "@rnoh/react-native-openharmony/ts"
|
2
|
+
import { Vector2D } from "./Vector2D"
|
3
|
+
|
4
|
+
export type BoundingBox = {
|
5
|
+
x: number,
|
6
|
+
y: number,
|
7
|
+
width: number,
|
8
|
+
height: number
|
9
|
+
}
|
10
|
+
|
11
|
+
export class View {
|
12
|
+
constructor(private descriptorRegistry: DescriptorRegistry, private viewTag: number) {
|
13
|
+
}
|
14
|
+
|
15
|
+
public getChildren() {
|
16
|
+
return this.getDescriptor().childrenTags.map(childrenTag => {
|
17
|
+
return new View(this.descriptorRegistry, childrenTag)
|
18
|
+
})
|
19
|
+
}
|
20
|
+
|
21
|
+
public getTag(): Tag {
|
22
|
+
return this.viewTag
|
23
|
+
}
|
24
|
+
|
25
|
+
public isPositionInBounds({x, y}: {
|
26
|
+
x: number,
|
27
|
+
y: number
|
28
|
+
}): boolean {
|
29
|
+
const rect = this.getBoundingRect()
|
30
|
+
return x >= rect.x && x <= (rect.x + rect.width) && y >= rect.y && y <= (rect.y + rect.height);
|
31
|
+
}
|
32
|
+
|
33
|
+
public getBoundingRect(): BoundingBox {
|
34
|
+
const d = this.getDescriptor()
|
35
|
+
if (!d) {
|
36
|
+
return { x: 0, y: 0, width: 0, height: 0 }
|
37
|
+
}
|
38
|
+
const offsetToAbsolutePosition = this.getOffsetToAbsolutePosition()
|
39
|
+
return {
|
40
|
+
x: d.layoutMetrics.frame.origin.x - offsetToAbsolutePosition.x,
|
41
|
+
y: d.layoutMetrics.frame.origin.y - offsetToAbsolutePosition.y,
|
42
|
+
width: d.layoutMetrics.frame.size.width,
|
43
|
+
height: d.layoutMetrics.frame.size.height
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
private getDescriptor() {
|
48
|
+
return this.descriptorRegistry.getDescriptor(this.viewTag)
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
private getOffsetToAbsolutePosition(): Vector2D {
|
53
|
+
const currentOffset = new Vector2D()
|
54
|
+
let parentTag = this.getDescriptor()?.parentTag
|
55
|
+
while (parentTag !== undefined) {
|
56
|
+
const d = this.descriptorRegistry.getDescriptor(parentTag)
|
57
|
+
currentOffset.add(this.extractScrollOffsetFromDescriptor(d))
|
58
|
+
currentOffset.subtract(new Vector2D(d.layoutMetrics.frame.origin))
|
59
|
+
parentTag = d.parentTag
|
60
|
+
}
|
61
|
+
return currentOffset
|
62
|
+
}
|
63
|
+
|
64
|
+
private extractScrollOffsetFromDescriptor(descriptor: Descriptor<any>) {
|
65
|
+
if (descriptor.type !== "ScrollView") {
|
66
|
+
return new Vector2D();
|
67
|
+
}
|
68
|
+
const scrollViewState: any = descriptor.state;
|
69
|
+
return new Vector2D({ x: scrollViewState.contentOffsetX, y: scrollViewState.contentOffsetY })
|
70
|
+
}
|
71
71
|
}
|
@@ -1,43 +1,43 @@
|
|
1
|
-
import { DescriptorRegistry, ComponentManagerRegistry, Tag } from "rnoh/ts"
|
2
|
-
import { View } from "./View"
|
3
|
-
|
4
|
-
export class ViewRegistry {
|
5
|
-
constructor(private descriptorRegistry: DescriptorRegistry, private componentManagerRegistry: ComponentManagerRegistry) {
|
6
|
-
}
|
7
|
-
|
8
|
-
public getViewByTag(viewTag: Tag) {
|
9
|
-
return this.createView(viewTag)
|
10
|
-
}
|
11
|
-
|
12
|
-
private createView(tag: Tag): View {
|
13
|
-
return new View(this.descriptorRegistry, tag)
|
14
|
-
}
|
15
|
-
|
16
|
-
public getTouchableViewsAt(pos: {
|
17
|
-
x: number,
|
18
|
-
y: number
|
19
|
-
}, rootTag: Tag): View[] {
|
20
|
-
const rootView = this.createView(rootTag)
|
21
|
-
const results: View[] = []
|
22
|
-
for (const view of this.getTouchableViewsAtPosInView(pos, rootView)) {
|
23
|
-
results.push(view)
|
24
|
-
}
|
25
|
-
return results
|
26
|
-
}
|
27
|
-
|
28
|
-
private getTouchableViewsAtPosInView(pos: {
|
29
|
-
x: number,
|
30
|
-
y: number
|
31
|
-
}, view: View) {
|
32
|
-
if (!view.isPositionInBounds(pos))
|
33
|
-
return [];
|
34
|
-
const results: View[] = []
|
35
|
-
results.push(view)
|
36
|
-
for (const child of view.getChildren()) {
|
37
|
-
for (const result of this.getTouchableViewsAtPosInView(pos, child)) {
|
38
|
-
results.push(result)
|
39
|
-
}
|
40
|
-
}
|
41
|
-
return results
|
42
|
-
}
|
1
|
+
import { DescriptorRegistry, ComponentManagerRegistry, Tag } from "@rnoh/react-native-openharmony/ts"
|
2
|
+
import { View } from "./View"
|
3
|
+
|
4
|
+
export class ViewRegistry {
|
5
|
+
constructor(private descriptorRegistry: DescriptorRegistry, private componentManagerRegistry: ComponentManagerRegistry) {
|
6
|
+
}
|
7
|
+
|
8
|
+
public getViewByTag(viewTag: Tag) {
|
9
|
+
return this.createView(viewTag)
|
10
|
+
}
|
11
|
+
|
12
|
+
private createView(tag: Tag): View {
|
13
|
+
return new View(this.descriptorRegistry, tag)
|
14
|
+
}
|
15
|
+
|
16
|
+
public getTouchableViewsAt(pos: {
|
17
|
+
x: number,
|
18
|
+
y: number
|
19
|
+
}, rootTag: Tag): View[] {
|
20
|
+
const rootView = this.createView(rootTag)
|
21
|
+
const results: View[] = []
|
22
|
+
for (const view of this.getTouchableViewsAtPosInView(pos, rootView)) {
|
23
|
+
results.push(view)
|
24
|
+
}
|
25
|
+
return results
|
26
|
+
}
|
27
|
+
|
28
|
+
private getTouchableViewsAtPosInView(pos: {
|
29
|
+
x: number,
|
30
|
+
y: number
|
31
|
+
}, view: View) {
|
32
|
+
if (!view.isPositionInBounds(pos))
|
33
|
+
return [];
|
34
|
+
const results: View[] = []
|
35
|
+
results.push(view)
|
36
|
+
for (const child of view.getChildren()) {
|
37
|
+
for (const result of this.getTouchableViewsAtPosInView(pos, child)) {
|
38
|
+
results.push(result)
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return results
|
42
|
+
}
|
43
43
|
}
|
@@ -0,0 +1,140 @@
|
|
1
|
+
// This file was generated.
|
2
|
+
import {
|
3
|
+
Descriptor as ComponentDescriptor,
|
4
|
+
ViewBaseProps,
|
5
|
+
ViewRawProps,
|
6
|
+
ViewDescriptorWrapperBase,
|
7
|
+
ColorValue,
|
8
|
+
Color,
|
9
|
+
RNInstance,
|
10
|
+
Tag,
|
11
|
+
RNComponentCommandReceiver,
|
12
|
+
ViewPropsSelector,
|
13
|
+
} from '@rnoh/react-native-openharmony/ts';
|
14
|
+
|
15
|
+
|
16
|
+
export namespace RNGestureHandlerButton {
|
17
|
+
export const NAME = "RNGestureHandlerButton" as const
|
18
|
+
|
19
|
+
export interface DirectRawProps {
|
20
|
+
exclusive?: boolean;
|
21
|
+
foreground?: boolean;
|
22
|
+
borderless?: boolean;
|
23
|
+
enabled?: boolean;
|
24
|
+
rippleColor?: ColorValue;
|
25
|
+
rippleRadius?: number;
|
26
|
+
touchSoundDisabled?: boolean;
|
27
|
+
}
|
28
|
+
|
29
|
+
export interface Props extends ViewBaseProps {}
|
30
|
+
|
31
|
+
export interface State {}
|
32
|
+
|
33
|
+
export interface RawProps extends ViewRawProps, DirectRawProps {}
|
34
|
+
|
35
|
+
export class PropsSelector extends ViewPropsSelector<Props, RawProps> {
|
36
|
+
get exclusive() {
|
37
|
+
return this.rawProps.exclusive ?? true;
|
38
|
+
}
|
39
|
+
|
40
|
+
get foreground() {
|
41
|
+
return this.rawProps.foreground ?? false;
|
42
|
+
}
|
43
|
+
|
44
|
+
get borderless() {
|
45
|
+
return this.rawProps.borderless ?? false;
|
46
|
+
}
|
47
|
+
|
48
|
+
get enabled() {
|
49
|
+
return this.rawProps.enabled ?? true;
|
50
|
+
}
|
51
|
+
|
52
|
+
get rippleRadius() {
|
53
|
+
return this.rawProps.rippleRadius ?? 0;
|
54
|
+
}
|
55
|
+
|
56
|
+
get touchSoundDisabled() {
|
57
|
+
return this.rawProps.touchSoundDisabled ?? false;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
get rippleColor() {
|
62
|
+
if (this.rawProps.rippleColor) {
|
63
|
+
return Color.fromColorValue(this.rawProps.rippleColor)
|
64
|
+
} else {
|
65
|
+
return new Color({ r: 0, g: 0, b: 0, a: 255})
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
export type Descriptor = ComponentDescriptor<
|
72
|
+
typeof NAME,
|
73
|
+
Props,
|
74
|
+
State,
|
75
|
+
RawProps
|
76
|
+
>;
|
77
|
+
|
78
|
+
export class DescriptorWrapper extends ViewDescriptorWrapperBase<
|
79
|
+
typeof NAME,
|
80
|
+
Props,
|
81
|
+
State,
|
82
|
+
RawProps,
|
83
|
+
PropsSelector
|
84
|
+
> {
|
85
|
+
protected createPropsSelector() {
|
86
|
+
return new PropsSelector(this.descriptor.props, this.descriptor.rawProps)
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
export interface EventPayloadByName {
|
91
|
+
}
|
92
|
+
|
93
|
+
export class EventEmitter {
|
94
|
+
constructor(private rnInstance: RNInstance, private tag: Tag) {}
|
95
|
+
|
96
|
+
emit<TEventName extends keyof EventPayloadByName>(eventName: TEventName, payload: EventPayloadByName[TEventName]) {
|
97
|
+
this.rnInstance.emitComponentEvent(this.tag, eventName, payload)
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
export interface CommandArgvByName {
|
102
|
+
}
|
103
|
+
|
104
|
+
export class CommandReceiver {
|
105
|
+
private listenersByCommandName = new Map<string, Set<(...args: any[]) => void>>()
|
106
|
+
private cleanUp: (() => void) | undefined = undefined
|
107
|
+
|
108
|
+
constructor(private componentCommandReceiver: RNComponentCommandReceiver, private tag: Tag) {
|
109
|
+
}
|
110
|
+
|
111
|
+
subscribe<TCommandName extends keyof CommandArgvByName>(commandName: TCommandName, listener: (argv: CommandArgvByName[TCommandName]) => void) {
|
112
|
+
if (!this.listenersByCommandName.has(commandName)) {
|
113
|
+
this.listenersByCommandName.set(commandName, new Set())
|
114
|
+
}
|
115
|
+
this.listenersByCommandName.get(commandName)!.add(listener)
|
116
|
+
const hasRegisteredCommandReceiver = !!this.cleanUp
|
117
|
+
if (!hasRegisteredCommandReceiver) {
|
118
|
+
this.cleanUp = this.componentCommandReceiver.registerCommandCallback(this.tag, (commandName: string, argv: any[]) => {
|
119
|
+
if (this.listenersByCommandName.has(commandName)) {
|
120
|
+
const listeners = this.listenersByCommandName.get(commandName)!
|
121
|
+
listeners.forEach(listener => {
|
122
|
+
listener(argv)
|
123
|
+
})
|
124
|
+
}
|
125
|
+
})
|
126
|
+
}
|
127
|
+
|
128
|
+
return () => {
|
129
|
+
this.listenersByCommandName.get(commandName)?.delete(listener)
|
130
|
+
if (this.listenersByCommandName.get(commandName)?.size ?? 0 === 0) {
|
131
|
+
this.listenersByCommandName.delete(commandName)
|
132
|
+
}
|
133
|
+
if (this.listenersByCommandName.size === 0) {
|
134
|
+
this.cleanUp?.()
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
// This file was generated.
|
2
|
+
import { Tag } from "../../ts"
|
3
|
+
|
4
|
+
export namespace RNGestureHandlerModule {
|
5
|
+
export const NAME = 'RNGestureHandlerModule' as const
|
6
|
+
|
7
|
+
export interface Spec {
|
8
|
+
handleSetJSResponder(tag: number, blockNativeResponder: boolean): void;
|
9
|
+
|
10
|
+
handleClearJSResponder(): void;
|
11
|
+
|
12
|
+
createGestureHandler(handlerName: string, handlerTag: number, config: Object): void;
|
13
|
+
|
14
|
+
attachGestureHandler(handlerTag: number, newView: number, actionType: number): void;
|
15
|
+
|
16
|
+
updateGestureHandler(handlerTag: number, newConfig: Object): void;
|
17
|
+
|
18
|
+
dropGestureHandler(handlerTag: number): void;
|
19
|
+
|
20
|
+
install(): boolean;
|
21
|
+
|
22
|
+
flushOperations(): void;
|
23
|
+
|
24
|
+
}
|
25
|
+
}
|