@react-native-oh-tpl/react-native-gesture-handler 2.14.1-2.14.13 → 2.14.1-2.14.15
Sign up to get free protection for your applications and to get access to all the features.
- package/harmony/gesture_handler/BuildProfile.ets +1 -1
- package/harmony/gesture_handler/build-profile.json5 +0 -7
- package/harmony/gesture_handler/index.ets +1 -2
- package/harmony/gesture_handler/oh-package-lock.json5 +1 -1
- package/harmony/gesture_handler/oh-package.json5 +2 -2
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +1 -1
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +9 -18
- package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.cpp +157 -0
- package/harmony/gesture_handler/src/main/cpp/RnohReactNativeHarmonyGestureHandlerPackage.h +21 -0
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerButtonComponentInstance.h +16 -16
- package/harmony/gesture_handler/src/main/cpp/componentInstances/RNGestureHandlerRootViewComponentInstance.h +202 -199
- package/harmony/gesture_handler/src/main/ets/RNOHPackage.ets +17 -0
- package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +84 -35
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerOrchestrator.ts +20 -11
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/core/InteractionManager.ts +4 -4
- package/harmony/gesture_handler/src/main/ets/core/Multiset.ts +26 -0
- package/harmony/gesture_handler/src/main/ets/core/RNGHLogger.ts +7 -3
- package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +1 -2
- package/harmony/gesture_handler/src/main/ets/core/index.ts +2 -2
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/FlingGestureHandler.ts +12 -4
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/GestureHandlerFactory.ts +8 -5
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/LongPressGestureHandler.ts +14 -2
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/ManualGestureHandler.ts +9 -1
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/NativeViewGestureHandler.ts +13 -4
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +45 -12
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PinchGestureHandler.ts +145 -130
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/RotationGestureHandler.ts +9 -1
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/TapGestureHandler.ts +15 -5
- package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +6 -3
- package/harmony/gesture_handler/src/main/ets/rnoh/Logger.ts +74 -16
- package/harmony/gesture_handler/src/main/ets/rnoh/OutgoingEventDispatchers.ts +35 -12
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +196 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +85 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/{GestureHandlerArkUIAdapter.ts → RNGHViewController.ts} +45 -30
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewRegistry.ts +19 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +127 -93
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHGestureResponder.ts +0 -9
- package/harmony/gesture_handler/src/main/ets/rnoh/RNOHScrollLocker.ts +1 -8
- package/harmony/gesture_handler.har +0 -0
- package/package.json +7 -3
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +0 -149
- package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +0 -11
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +0 -98
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerCAPI.ts +0 -110
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerButton.ets +0 -38
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerRootView.ets +0 -53
- package/harmony/gesture_handler/src/main/ets/rnoh/View.ts +0 -134
- package/harmony/gesture_handler/src/main/ets/rnoh/ViewRegistry.ts +0 -97
@@ -18,7 +18,15 @@ export class LongPressGestureHandler extends GestureHandler {
|
|
18
18
|
private activationTimeout: number | undefined;
|
19
19
|
|
20
20
|
constructor(deps: GestureHandlerDependencies) {
|
21
|
-
super({...deps, logger: deps.logger.
|
21
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("LongPressGestureHandler") })
|
22
|
+
}
|
23
|
+
|
24
|
+
override getName(): string {
|
25
|
+
return "LongPressGestureHandler"
|
26
|
+
}
|
27
|
+
|
28
|
+
public override isGestureContinuous(): boolean {
|
29
|
+
return false
|
22
30
|
}
|
23
31
|
|
24
32
|
public getDefaultConfig() {
|
@@ -45,7 +53,6 @@ export class LongPressGestureHandler extends GestureHandler {
|
|
45
53
|
}
|
46
54
|
|
47
55
|
|
48
|
-
|
49
56
|
protected resetConfig(): void {
|
50
57
|
super.resetConfig();
|
51
58
|
this.minDurationMs = DEFAULT_MIN_DURATION_MS;
|
@@ -71,6 +78,11 @@ export class LongPressGestureHandler extends GestureHandler {
|
|
71
78
|
this.checkDistanceFail(event);
|
72
79
|
}
|
73
80
|
|
81
|
+
public onPointerOutOfBounds(e: IncomingEvent): void {
|
82
|
+
this.tracker.track(e);
|
83
|
+
super.onPointerOutOfBounds(e);
|
84
|
+
}
|
85
|
+
|
74
86
|
public onPointerUp(event: IncomingEvent): void {
|
75
87
|
super.onPointerUp(event);
|
76
88
|
this.tracker.removeFromTracker(event.pointerId);
|
@@ -2,7 +2,15 @@ import { GestureHandler, GestureHandlerDependencies, IncomingEvent } from '../co
|
|
2
2
|
|
3
3
|
export class ManualGestureHandler extends GestureHandler {
|
4
4
|
constructor(deps: GestureHandlerDependencies) {
|
5
|
-
super({...deps, logger: deps.logger.
|
5
|
+
super({...deps, logger: deps.logger.cloneAndJoinPrefix("ManualGestureHandler")})
|
6
|
+
}
|
7
|
+
|
8
|
+
public override getName(): string {
|
9
|
+
return "ManualGestureHandler"
|
10
|
+
}
|
11
|
+
|
12
|
+
public override isGestureContinuous(): boolean {
|
13
|
+
return false
|
6
14
|
}
|
7
15
|
|
8
16
|
public getDefaultConfig() {
|
@@ -11,7 +11,15 @@ export class NativeViewGestureHandler extends GestureHandler {
|
|
11
11
|
}
|
12
12
|
|
13
13
|
constructor(deps: GestureHandlerDependencies) {
|
14
|
-
super({ ...deps, logger: deps.logger.
|
14
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("NativeViewGestureHandler") })
|
15
|
+
}
|
16
|
+
|
17
|
+
public override getName(): string {
|
18
|
+
return "NativeViewGestureHandler"
|
19
|
+
}
|
20
|
+
|
21
|
+
public override isGestureContinuous(): boolean {
|
22
|
+
return false
|
15
23
|
}
|
16
24
|
|
17
25
|
public getDefaultConfig() {
|
@@ -26,10 +34,11 @@ export class NativeViewGestureHandler extends GestureHandler {
|
|
26
34
|
|
27
35
|
protected onNewPointer() {
|
28
36
|
this.startPos = this.tracker.getLastAvgPos();
|
29
|
-
if (this.currentState !== State.UNDETERMINED)
|
37
|
+
if (this.currentState !== State.UNDETERMINED) {
|
30
38
|
return;
|
39
|
+
}
|
31
40
|
this.begin();
|
32
|
-
if(this.view.hasButtonRole()) {
|
41
|
+
if (this.view.hasButtonRole()) {
|
33
42
|
this.activate();
|
34
43
|
}
|
35
44
|
}
|
@@ -42,7 +51,7 @@ export class NativeViewGestureHandler extends GestureHandler {
|
|
42
51
|
|
43
52
|
public onPointerMove(e: IncomingEvent): void {
|
44
53
|
this.tracker.track(e);
|
45
|
-
const {x: dx, y: dy} = this.startPos.clone().subtract(this.tracker.getLastAvgPos()).value
|
54
|
+
const { x: dx, y: dy } = this.startPos.clone().subtract(this.tracker.getLastAvgPos()).value
|
46
55
|
const distSq = dx * dx + dy * dy;
|
47
56
|
|
48
57
|
if (distSq >= this.minDistSq) {
|
@@ -21,24 +21,35 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
21
21
|
private velocity = new Vector2D();
|
22
22
|
private activationTimeout = 0;
|
23
23
|
|
24
|
+
public override getName(): string {
|
25
|
+
return "PanGestureHandler"
|
26
|
+
}
|
27
|
+
|
28
|
+
public override isGestureContinuous(): boolean {
|
29
|
+
return true
|
30
|
+
}
|
31
|
+
|
24
32
|
private get failOffsetXStart() {
|
25
33
|
if (this.config.failOffsetXStart === undefined
|
26
|
-
&& this.config.failOffsetXEnd === undefined)
|
34
|
+
&& this.config.failOffsetXEnd === undefined) {
|
27
35
|
return undefined
|
36
|
+
}
|
28
37
|
return this.config.failOffsetXStart ?? Number.MIN_SAFE_INTEGER
|
29
38
|
}
|
30
39
|
|
31
40
|
private get failOffsetXEnd() {
|
32
41
|
if (this.config.failOffsetXStart === undefined
|
33
|
-
&& this.config.failOffsetXEnd === undefined)
|
42
|
+
&& this.config.failOffsetXEnd === undefined) {
|
34
43
|
return undefined
|
44
|
+
}
|
35
45
|
return this.config.failOffsetXEnd ?? Number.MAX_SAFE_INTEGER
|
36
46
|
}
|
37
47
|
|
38
48
|
private get failOffsetYStart() {
|
39
49
|
if (this.config.failOffsetYStart === undefined
|
40
|
-
&& this.config.failOffsetYEnd === undefined)
|
50
|
+
&& this.config.failOffsetYEnd === undefined) {
|
41
51
|
return undefined
|
52
|
+
}
|
42
53
|
return this.config.failOffsetYStart ?? Number.MIN_SAFE_INTEGER
|
43
54
|
}
|
44
55
|
|
@@ -48,29 +59,33 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
48
59
|
|
49
60
|
private get activeOffsetXStart() {
|
50
61
|
if (this.config.activeOffsetXStart === undefined
|
51
|
-
&& this.config.activeOffsetXEnd === undefined)
|
62
|
+
&& this.config.activeOffsetXEnd === undefined) {
|
52
63
|
return undefined
|
64
|
+
}
|
53
65
|
return this.config.activeOffsetXStart ?? Number.MIN_SAFE_INTEGER
|
54
66
|
}
|
55
67
|
|
56
68
|
private get activeOffsetXEnd() {
|
57
69
|
if (this.config.activeOffsetXStart === undefined
|
58
|
-
&& this.config.activeOffsetXEnd === undefined)
|
70
|
+
&& this.config.activeOffsetXEnd === undefined) {
|
59
71
|
return undefined
|
72
|
+
}
|
60
73
|
return this.config.activeOffsetXEnd ?? Number.MAX_SAFE_INTEGER
|
61
74
|
}
|
62
75
|
|
63
76
|
private get activeOffsetYStart() {
|
64
77
|
if (this.config.activeOffsetYStart === undefined
|
65
|
-
&& this.config.activeOffsetYEnd === undefined)
|
78
|
+
&& this.config.activeOffsetYEnd === undefined) {
|
66
79
|
return undefined
|
80
|
+
}
|
67
81
|
return this.config.activeOffsetYStart ?? Number.MIN_SAFE_INTEGER
|
68
82
|
}
|
69
83
|
|
70
84
|
private get activeOffsetYEnd() {
|
71
85
|
if (this.config.activeOffsetYStart === undefined
|
72
|
-
&& this.config.activeOffsetYEnd === undefined)
|
86
|
+
&& this.config.activeOffsetYEnd === undefined) {
|
73
87
|
return undefined
|
88
|
+
}
|
74
89
|
return this.config.activeOffsetYEnd ?? Number.MAX_SAFE_INTEGER
|
75
90
|
}
|
76
91
|
|
@@ -92,7 +107,7 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
92
107
|
private unlockRNGestureResponder: (() => void) | undefined
|
93
108
|
|
94
109
|
public constructor(deps: GestureHandlerDependencies) {
|
95
|
-
super({ ...deps, logger: deps.logger.
|
110
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("PanGestureHandler") })
|
96
111
|
}
|
97
112
|
|
98
113
|
public onPointerDown(e) {
|
@@ -115,7 +130,7 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
115
130
|
}
|
116
131
|
|
117
132
|
private shouldFail(): boolean {
|
118
|
-
const {x: dx, y: dy} = this.getTranslation().value;
|
133
|
+
const { x: dx, y: dy } = this.getTranslation().value;
|
119
134
|
const distanceSq = dx * dx + dy * dy;
|
120
135
|
if (this.activateAfterLongPress > 0 && distanceSq > DEFAULT_MIN_DIST_SQ) {
|
121
136
|
this.clearActivationTimeout();
|
@@ -138,7 +153,7 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
138
153
|
}
|
139
154
|
|
140
155
|
private shouldActivate(): boolean {
|
141
|
-
const {x: dx, y: dy} = this.getTranslation().value;
|
156
|
+
const { x: dx, y: dy } = this.getTranslation().value;
|
142
157
|
if (this.activeOffsetXStart !== Number.MAX_SAFE_INTEGER && dx < this.activeOffsetXStart
|
143
158
|
) {
|
144
159
|
return true;
|
@@ -156,7 +171,7 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
156
171
|
if (this.minDistSq !== Number.MAX_SAFE_INTEGER && distanceSq >= this.minDistSq) {
|
157
172
|
return true;
|
158
173
|
}
|
159
|
-
const {x: vx, y: vy} = this.velocity
|
174
|
+
const { x: vx, y: vy } = this.velocity
|
160
175
|
if (
|
161
176
|
this.minVelocityX !== Number.MAX_SAFE_INTEGER &&
|
162
177
|
((this.minVelocityX < 0 && vx <= this.minVelocityX) ||
|
@@ -183,7 +198,11 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
183
198
|
}
|
184
199
|
|
185
200
|
private tryBegin(e: IncomingEvent): void {
|
186
|
-
this.logger.
|
201
|
+
this.logger.cloneAndJoinPrefix("tryBegin").debug({
|
202
|
+
currentState: getStateName(this.currentState),
|
203
|
+
trackedPointersCount: this.tracker.getTrackedPointersCount(),
|
204
|
+
minPointers: this.minPointers
|
205
|
+
})
|
187
206
|
if (
|
188
207
|
(this.currentState === State.UNDETERMINED) &&
|
189
208
|
this.tracker.getTrackedPointersCount() >= this.minPointers
|
@@ -265,7 +284,13 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
265
284
|
if (this.currentState === State.ACTIVE) {
|
266
285
|
this.lastPos = this.tracker.getLastAvgPos();
|
267
286
|
}
|
287
|
+
|
268
288
|
this.tracker.removeFromTracker(event.pointerId);
|
289
|
+
|
290
|
+
if (this.tracker.getTrackedPointersCount() === 0) {
|
291
|
+
this.clearActivationTimeout();
|
292
|
+
}
|
293
|
+
|
269
294
|
if (this.currentState === State.ACTIVE) {
|
270
295
|
this.end();
|
271
296
|
} else {
|
@@ -339,4 +364,12 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
339
364
|
this.unlockRNGestureResponder?.()
|
340
365
|
}
|
341
366
|
}
|
367
|
+
|
368
|
+
protected onCancel(): void {
|
369
|
+
this.clearActivationTimeout();
|
370
|
+
}
|
371
|
+
|
372
|
+
protected onReset(): void {
|
373
|
+
this.clearActivationTimeout();
|
374
|
+
}
|
342
375
|
}
|
@@ -1,159 +1,174 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
GestureHandler,
|
3
|
+
DEFAULT_TOUCH_SLOP,
|
4
|
+
IncomingEvent,
|
5
|
+
GestureConfig,
|
6
|
+
State,
|
7
|
+
GestureHandlerDependencies
|
8
|
+
} from "../core"
|
2
9
|
import ScaleGestureDetector, { ScaleGestureListener } from "../detectors/ScaleGestureDetector";
|
3
10
|
|
4
11
|
|
5
|
-
|
6
12
|
export class PinchGestureHandler extends GestureHandler {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
private scale = 1;
|
14
|
+
private velocity = 0;
|
15
|
+
|
16
|
+
private startingSpan = 0;
|
17
|
+
private spanSlop = DEFAULT_TOUCH_SLOP;
|
18
|
+
|
19
|
+
private scaleDetectorListener: ScaleGestureListener = {
|
20
|
+
onScaleBegin: (detector: ScaleGestureDetector): boolean => {
|
21
|
+
this.startingSpan = detector.getCurrentSpan();
|
22
|
+
return true;
|
23
|
+
},
|
24
|
+
onScale: (detector: ScaleGestureDetector): boolean => {
|
25
|
+
const prevScaleFactor: number = this.scale;
|
26
|
+
this.scale *= detector.getScaleFactor(
|
27
|
+
this.tracker.getTrackedPointersCount()
|
28
|
+
);
|
29
|
+
|
30
|
+
const delta = detector.getTimeDelta();
|
31
|
+
if (delta > 0) {
|
32
|
+
this.velocity = (this.scale - prevScaleFactor) / delta;
|
33
|
+
}
|
34
|
+
|
35
|
+
if (
|
36
|
+
Math.abs(this.startingSpan - detector.getCurrentSpan()) >=
|
37
|
+
this.spanSlop &&
|
32
38
|
this.currentState === State.BEGAN
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
) {
|
40
|
+
this.activate();
|
41
|
+
}
|
42
|
+
return true;
|
43
|
+
},
|
44
|
+
onScaleEnd: (
|
45
|
+
_detector: ScaleGestureDetector
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
47
|
+
): void => {
|
48
|
+
},
|
49
|
+
};
|
50
|
+
|
51
|
+
private scaleGestureDetector: ScaleGestureDetector = new ScaleGestureDetector(
|
52
|
+
this.scaleDetectorListener
|
53
|
+
);
|
54
|
+
|
55
|
+
|
56
|
+
public constructor(deps: GestureHandlerDependencies) {
|
57
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("PinchGestureHandler") })
|
58
|
+
this.setShouldCancelWhenOutside(false);
|
59
|
+
}
|
60
|
+
|
61
|
+
public getName(): string {
|
62
|
+
return "PinchGestureHandler"
|
63
|
+
}
|
64
|
+
|
65
|
+
public override isGestureContinuous(): boolean {
|
66
|
+
return true
|
67
|
+
}
|
68
|
+
|
69
|
+
public getDefaultConfig() {
|
70
|
+
return {}
|
71
|
+
}
|
72
|
+
|
73
|
+
public updateGestureConfig({ enabled = true, ...props }: GestureConfig): void {
|
74
|
+
super.updateGestureConfig({ enabled: enabled, ...props });
|
75
|
+
}
|
76
|
+
|
77
|
+
protected transformNativeEvent() {
|
78
|
+
return {
|
79
|
+
focalX: this.scaleGestureDetector.getFocusX(),
|
80
|
+
focalY: this.scaleGestureDetector.getFocusY(),
|
81
|
+
velocity: this.velocity,
|
82
|
+
scale: this.scale,
|
42
83
|
};
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
);
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
protected transformNativeEvent() {
|
63
|
-
return {
|
64
|
-
focalX: this.scaleGestureDetector.getFocusX(),
|
65
|
-
focalY: this.scaleGestureDetector.getFocusY(),
|
66
|
-
velocity: this.velocity,
|
67
|
-
scale: this.scale,
|
68
|
-
};
|
69
|
-
}
|
70
|
-
|
71
|
-
public onPointerDown(event: IncomingEvent): void {
|
72
|
-
this.tracker.addToTracker(event);
|
73
|
-
super.onPointerDown(event);
|
84
|
+
}
|
85
|
+
|
86
|
+
public onPointerDown(event: IncomingEvent): void {
|
87
|
+
this.tracker.addToTracker(event);
|
88
|
+
super.onPointerDown(event);
|
89
|
+
}
|
90
|
+
|
91
|
+
public onAdditionalPointerAdd(event: IncomingEvent): void {
|
92
|
+
this.tracker.addToTracker(event);
|
93
|
+
super.onAdditionalPointerAdd(event);
|
94
|
+
this.tryBegin();
|
95
|
+
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
96
|
+
}
|
97
|
+
|
98
|
+
public onPointerUp(event: IncomingEvent): void {
|
99
|
+
super.onPointerUp(event);
|
100
|
+
this.tracker.removeFromTracker(event.pointerId);
|
101
|
+
if (this.currentState !== State.ACTIVE) {
|
102
|
+
return;
|
74
103
|
}
|
104
|
+
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
75
105
|
|
76
|
-
|
77
|
-
this.
|
78
|
-
|
79
|
-
this.
|
80
|
-
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
106
|
+
if (this.currentState === State.ACTIVE) {
|
107
|
+
this.end();
|
108
|
+
} else {
|
109
|
+
this.fail();
|
81
110
|
}
|
111
|
+
}
|
82
112
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
return;
|
88
|
-
}
|
89
|
-
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
113
|
+
public onAdditionalPointerRemove(event: IncomingEvent): void {
|
114
|
+
super.onAdditionalPointerRemove(event);
|
115
|
+
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
116
|
+
this.tracker.removeFromTracker(event.pointerId);
|
90
117
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
118
|
+
if (
|
119
|
+
this.currentState === State.ACTIVE &&
|
120
|
+
this.tracker.getTrackedPointersCount() < 2
|
121
|
+
) {
|
122
|
+
this.end();
|
96
123
|
}
|
124
|
+
}
|
97
125
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
this.tracker.removeFromTracker(event.pointerId);
|
102
|
-
|
103
|
-
if (
|
104
|
-
this.currentState === State.ACTIVE &&
|
105
|
-
this.tracker.getTrackedPointersCount() < 2
|
106
|
-
) {
|
107
|
-
this.end();
|
108
|
-
}
|
126
|
+
public onPointerMove(event: IncomingEvent): void {
|
127
|
+
if (this.tracker.getTrackedPointersCount() < 2) {
|
128
|
+
return;
|
109
129
|
}
|
130
|
+
this.tracker.track(event);
|
110
131
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
}
|
115
|
-
this.tracker.track(event);
|
132
|
+
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
133
|
+
super.onPointerMove(event);
|
134
|
+
}
|
116
135
|
|
117
|
-
|
118
|
-
|
136
|
+
public onPointerOutOfBounds(event: IncomingEvent): void {
|
137
|
+
if (this.tracker.getTrackedPointersCount() < 2) {
|
138
|
+
return;
|
119
139
|
}
|
140
|
+
this.tracker.track(event);
|
120
141
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
}
|
125
|
-
this.tracker.track(event);
|
142
|
+
this.scaleGestureDetector.onTouchEvent(event, this.tracker);
|
143
|
+
super.onPointerOutOfBounds(event);
|
144
|
+
}
|
126
145
|
|
127
|
-
|
128
|
-
|
146
|
+
private tryBegin(): void {
|
147
|
+
if (this.currentState !== State.UNDETERMINED) {
|
148
|
+
return;
|
129
149
|
}
|
130
150
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
}
|
151
|
+
this.resetProgress();
|
152
|
+
this.begin();
|
153
|
+
}
|
135
154
|
|
155
|
+
public activate(force?: boolean): void {
|
156
|
+
if (this.currentState !== State.ACTIVE) {
|
136
157
|
this.resetProgress();
|
137
|
-
this.begin();
|
138
158
|
}
|
139
159
|
|
140
|
-
|
141
|
-
|
142
|
-
this.resetProgress();
|
143
|
-
}
|
144
|
-
|
145
|
-
super.activate();
|
146
|
-
}
|
160
|
+
super.activate();
|
161
|
+
}
|
147
162
|
|
148
|
-
|
149
|
-
|
150
|
-
|
163
|
+
protected onReset(): void {
|
164
|
+
this.resetProgress();
|
165
|
+
}
|
151
166
|
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
}
|
156
|
-
this.velocity = 0;
|
157
|
-
this.scale = 1;
|
167
|
+
protected resetProgress(): void {
|
168
|
+
if (this.currentState === State.ACTIVE) {
|
169
|
+
return;
|
158
170
|
}
|
171
|
+
this.velocity = 0;
|
172
|
+
this.scale = 1;
|
173
|
+
}
|
159
174
|
}
|
@@ -12,7 +12,15 @@ export class RotationGestureHandler extends GestureHandler {
|
|
12
12
|
private unlockScrolls: (() => void) | undefined
|
13
13
|
|
14
14
|
constructor(deps: GestureHandlerDependencies) {
|
15
|
-
super({ ...deps, logger: deps.logger.
|
15
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix("RotationGestureHandler") })
|
16
|
+
}
|
17
|
+
|
18
|
+
public override getName(): string {
|
19
|
+
return "RotationGestureHandler"
|
20
|
+
}
|
21
|
+
|
22
|
+
public override isGestureContinuous(): boolean {
|
23
|
+
return true
|
16
24
|
}
|
17
25
|
|
18
26
|
private rotationGestureListener: RotationGestureListener = {
|
@@ -17,7 +17,15 @@ export class TapGestureHandler extends GestureHandler {
|
|
17
17
|
private delayTimeout: number | undefined;
|
18
18
|
|
19
19
|
constructor(deps: GestureHandlerDependencies) {
|
20
|
-
super({...deps, logger: deps.logger.
|
20
|
+
super({ ...deps, logger: deps.logger.cloneAndJoinPrefix(`TapGestureHandler${deps.handlerTag}`) })
|
21
|
+
}
|
22
|
+
|
23
|
+
public override getName(): string {
|
24
|
+
return "TapGestureHandler"
|
25
|
+
}
|
26
|
+
|
27
|
+
public override isGestureContinuous(): boolean {
|
28
|
+
return false
|
21
29
|
}
|
22
30
|
|
23
31
|
onPointerDown(event) {
|
@@ -101,7 +109,9 @@ export class TapGestureHandler extends GestureHandler {
|
|
101
109
|
}
|
102
110
|
|
103
111
|
private trySettingPosition(event: IncomingEvent): void {
|
104
|
-
if (this.currentState !== State.UNDETERMINED)
|
112
|
+
if (this.currentState !== State.UNDETERMINED) {
|
113
|
+
return;
|
114
|
+
}
|
105
115
|
this.offsetX = 0;
|
106
116
|
this.offsetY = 0;
|
107
117
|
this.startX = event.x;
|
@@ -109,7 +119,7 @@ export class TapGestureHandler extends GestureHandler {
|
|
109
119
|
}
|
110
120
|
|
111
121
|
private updateState(event: IncomingEvent): void {
|
112
|
-
const logger = this.logger.
|
122
|
+
const logger = this.logger.cloneAndJoinPrefix("updateState")
|
113
123
|
if (this.maxNumberOfPointersSoFar < this.tracker.getTrackedPointersCount()) {
|
114
124
|
this.maxNumberOfPointersSoFar = this.tracker.getTrackedPointersCount()
|
115
125
|
}
|
@@ -175,13 +185,13 @@ export class TapGestureHandler extends GestureHandler {
|
|
175
185
|
}
|
176
186
|
|
177
187
|
private endTap() {
|
178
|
-
const logger = this.logger.
|
188
|
+
const logger = this.logger.cloneAndJoinPrefix("endTap")
|
179
189
|
this.clearTimeouts();
|
180
190
|
if (
|
181
191
|
++this.numberOfTapsSoFar === (this.config.numberOfTaps ?? DEFAULT_NUMBER_OF_TAPS) &&
|
182
192
|
this.maxNumberOfPointersSoFar >= (this.config.minNumberOfPointers ?? 0)
|
183
193
|
) {
|
184
|
-
logger.info(JSON.stringify({numberOfTapsSoFar: this.numberOfTapsSoFar}))
|
194
|
+
logger.info(JSON.stringify({ numberOfTapsSoFar: this.numberOfTapsSoFar }))
|
185
195
|
this.activate();
|
186
196
|
} else {
|
187
197
|
this.delayTimeout = setTimeout(() => this.fail(), this.config.maxDelayMs ?? DEFAULT_MAX_DELAY_MS);
|
@@ -2,7 +2,7 @@ import {RNPackage, TurboModulesFactory} from "@rnoh/react-native-openharmony/ts"
|
|
2
2
|
import type {TurboModule, TurboModuleContext} from "@rnoh/react-native-openharmony/ts";
|
3
3
|
import {RNGestureHandlerModule} from './RNGestureHandlerModule';
|
4
4
|
|
5
|
-
class
|
5
|
+
class GestureHandlerTurboModuleFactory extends TurboModulesFactory {
|
6
6
|
createTurboModule(name: string): TurboModule | null {
|
7
7
|
if (name === RNGestureHandlerModule.NAME) {
|
8
8
|
return new RNGestureHandlerModule(this.ctx);
|
@@ -15,8 +15,11 @@ class GestureHandlerTurboModulesFactory extends TurboModulesFactory {
|
|
15
15
|
}
|
16
16
|
}
|
17
17
|
|
18
|
+
/**
|
19
|
+
* @deprecated: Use the package class exported from ../RNOHPackage.ets (2024-10-10)
|
20
|
+
*/
|
18
21
|
export class GestureHandlerPackage extends RNPackage {
|
19
22
|
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
20
|
-
return new
|
23
|
+
return new GestureHandlerTurboModuleFactory(ctx);
|
21
24
|
}
|
22
|
-
}
|
25
|
+
}
|