@react-native-oh-tpl/react-native-gesture-handler 2.14.1-2.14.12 → 2.14.1-2.14.13
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/oh-package.json5 +3 -3
- package/harmony/gesture_handler/src/main/ets/core/GestureHandler.ts +8 -2
- package/harmony/gesture_handler/src/main/ets/core/GestureHandlerRegistry.ts +29 -1
- package/harmony/gesture_handler/src/main/ets/core/ViewFinder.ts +11 -0
- package/harmony/gesture_handler/src/main/ets/core/ViewRegistry.ts +8 -0
- package/harmony/gesture_handler/src/main/ets/core/index.ts +3 -1
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootTouchHandlerArkTS.ts +1 -11
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +6 -5
- package/harmony/gesture_handler/src/main/ets/rnoh/ViewRegistry.ts +9 -7
- package/harmony/gesture_handler.har +0 -0
- package/package.json +1 -1
@@ -1,7 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
3
3
|
*/
|
4
|
-
export const HAR_VERSION = '2.14.1-2.14.
|
4
|
+
export const HAR_VERSION = '2.14.1-2.14.13';
|
5
5
|
export const BUILD_MODE_NAME = 'release';
|
6
6
|
export const DEBUG = false;
|
7
7
|
export const TARGET_NAME = 'default';
|
@@ -5,8 +5,8 @@
|
|
5
5
|
name: '@react-native-oh-tpl/react-native-gesture-handler',
|
6
6
|
description: '',
|
7
7
|
type: 'module',
|
8
|
-
version: '2.14.1-2.14.
|
8
|
+
version: '2.14.1-2.14.13',
|
9
9
|
dependencies: {
|
10
|
-
"@rnoh/react-native-openharmony": "file
|
11
|
-
}
|
10
|
+
"@rnoh/react-native-openharmony": "file:./react_native_openharmony"
|
11
|
+
},
|
12
12
|
}
|
@@ -579,8 +579,14 @@ export abstract class GestureHandler<TGestureConfig extends GestureConfig = Gest
|
|
579
579
|
};
|
580
580
|
}
|
581
581
|
|
582
|
-
protected transformNativeEvent() {
|
583
|
-
|
582
|
+
protected transformNativeEvent(): Record<string, unknown> {
|
583
|
+
const rect = this.view.getBoundingRect();
|
584
|
+
return {
|
585
|
+
x: this.tracker.getLastAvgX() - rect.x,
|
586
|
+
y: this.tracker.getLastAvgY() - rect.y,
|
587
|
+
absoluteX: this.tracker.getLastAvgX(),
|
588
|
+
absoluteY: this.tracker.getLastAvgY(),
|
589
|
+
};
|
584
590
|
}
|
585
591
|
|
586
592
|
setAwaiting(isAwaiting: boolean): void {
|
@@ -1,14 +1,17 @@
|
|
1
1
|
import { GestureHandler } from "./GestureHandler"
|
2
2
|
import { View } from "./View"
|
3
3
|
import { RNGHLogger } from "./RNGHLogger"
|
4
|
+
import { ViewRegistry } from "./ViewRegistry"
|
4
5
|
|
5
6
|
export class GestureHandlerRegistry {
|
6
7
|
private gestureHandlerByHandlerTag: Map<number, GestureHandler> = new Map()
|
7
8
|
private gestureHandlersByViewTag: Map<number, Set<GestureHandler>> = new Map()
|
9
|
+
private viewRegistry: ViewRegistry | undefined
|
8
10
|
private logger: RNGHLogger
|
9
11
|
|
10
|
-
constructor(logger: RNGHLogger) {
|
12
|
+
constructor(viewRegistry: ViewRegistry | undefined, logger: RNGHLogger) {
|
11
13
|
this.logger = logger.cloneWithPrefix("GestureHandlerRegistry")
|
14
|
+
this.viewRegistry = viewRegistry
|
12
15
|
}
|
13
16
|
|
14
17
|
public addGestureHandler(gestureHandler: GestureHandler) {
|
@@ -29,6 +32,31 @@ export class GestureHandlerRegistry {
|
|
29
32
|
return Array.from(this.gestureHandlersByViewTag.get(viewTag) ?? [])
|
30
33
|
}
|
31
34
|
|
35
|
+
public removeGestureHandlerByHandlerTag(handlerTag: number) {
|
36
|
+
const gestureHandler = this.gestureHandlerByHandlerTag.get(handlerTag)
|
37
|
+
if (!gestureHandler) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
const viewTag = gestureHandler.getView()?.getTag();
|
41
|
+
if (viewTag) {
|
42
|
+
const gestureHandlers = this.gestureHandlersByViewTag.get(viewTag)
|
43
|
+
if (gestureHandlers) {
|
44
|
+
gestureHandlers.delete(gestureHandler)
|
45
|
+
if (gestureHandlers.size === 0) {
|
46
|
+
this.gestureHandlersByViewTag.delete(viewTag)
|
47
|
+
this.viewRegistry?.deleteByTag(viewTag)
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
if (gestureHandler.getView()) {
|
52
|
+
// Handler is in "prepared" state which means it is registered in the orchestrator and can
|
53
|
+
// receive touch events. This means that before we remove it from the registry we need to
|
54
|
+
// "cancel" it so that orchestrator does no longer keep a reference to it.
|
55
|
+
gestureHandler.cancel()
|
56
|
+
}
|
57
|
+
this.gestureHandlerByHandlerTag.delete(handlerTag)
|
58
|
+
}
|
59
|
+
|
32
60
|
public getGestureHandlerByHandlerTag(handlerTag: number): GestureHandler {
|
33
61
|
return this.gestureHandlerByHandlerTag.get(handlerTag)
|
34
62
|
}
|
@@ -10,4 +10,6 @@ export * from "./InteractionManager"
|
|
10
10
|
export * from "./PointerTracker"
|
11
11
|
export * from "./RNGHError"
|
12
12
|
export * from "./State"
|
13
|
-
export * from "./GestureHandlerRegistry"
|
13
|
+
export * from "./GestureHandlerRegistry"
|
14
|
+
export * from "./ViewFinder"
|
15
|
+
export * from "./ViewRegistry"
|
@@ -1,18 +1,8 @@
|
|
1
1
|
import { Tag } from '@rnoh/react-native-openharmony/ts';
|
2
2
|
import { GestureHandlerArkUIAdapter } from './GestureHandlerArkUIAdapter';
|
3
|
-
import { RNGHLogger, GestureHandlerRegistry, View } from '../core';
|
3
|
+
import { RNGHLogger, GestureHandlerRegistry, View, ViewFinder } from '../core';
|
4
4
|
import { TouchEvent, TouchType } from './types';
|
5
5
|
|
6
|
-
export interface ViewFinder {
|
7
|
-
getTouchableViewsAt(
|
8
|
-
pointRelativeToRoot: {
|
9
|
-
x: number,
|
10
|
-
y: number
|
11
|
-
},
|
12
|
-
rootTag: Tag
|
13
|
-
): View[]
|
14
|
-
}
|
15
|
-
|
16
6
|
export class RNGHRootTouchHandlerArkTS {
|
17
7
|
private adapterByViewTag: Map<number, GestureHandlerArkUIAdapter> = new Map(); // TODO: remove adapter when view is removed
|
18
8
|
/**
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { TurboModule, TurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
|
2
2
|
import { TM } from "../namespace/ts"
|
3
|
-
import { GestureHandlerRegistry, State, OutgoingEventDispatcher, RNGHLogger, InteractionManager } from '../core';
|
3
|
+
import { GestureHandlerRegistry, State, OutgoingEventDispatcher, RNGHLogger, InteractionManager, ViewRegistry } from '../core';
|
4
4
|
import { GestureHandlerFactory } from "../gesture-handlers"
|
5
|
-
import {
|
5
|
+
import { ViewRegistryArkTS, ViewRegistryCAPI } from './ViewRegistry';
|
6
6
|
import { StandardRNGHLogger, FakeRNGHLogger } from './Logger';
|
7
7
|
import { JSEventDispatcher, AnimatedEventDispatcher, ReanimatedEventDispatcher } from './OutgoingEventDispatchers'
|
8
8
|
import { RNOHScrollLockerArkTS, RNOHScrollLockerCAPI } from "./RNOHScrollLocker"
|
@@ -34,7 +34,7 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
|
|
34
34
|
const debug = false
|
35
35
|
this.logger = debug ? new StandardRNGHLogger(ctx.logger, "RNGH") : new FakeRNGHLogger()
|
36
36
|
this.interactionManager = new InteractionManager(this.logger)
|
37
|
-
this.gestureHandlerRegistry = new GestureHandlerRegistry(this.logger)
|
37
|
+
this.gestureHandlerRegistry = new GestureHandlerRegistry(this.viewRegistry, this.logger)
|
38
38
|
|
39
39
|
if (this.ctx.rnInstance.getArchitecture() === "C_API") {
|
40
40
|
this.ctx.rnInstance.cppEventEmitter.subscribe("RNGH::TOUCH_EVENT", (e: any) => {
|
@@ -173,7 +173,8 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
|
|
173
173
|
}
|
174
174
|
|
175
175
|
public dropGestureHandler(handlerTag: number) {
|
176
|
-
this.
|
176
|
+
this.interactionManager.dropRelationsForHandlerWithTag(handlerTag)
|
177
|
+
this.gestureHandlerRegistry.removeGestureHandlerByHandlerTag(handlerTag)
|
177
178
|
}
|
178
179
|
|
179
180
|
public handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
|
@@ -185,7 +186,7 @@ export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureH
|
|
185
186
|
}
|
186
187
|
|
187
188
|
public flushOperations() {
|
188
|
-
|
189
|
+
// no-op
|
189
190
|
}
|
190
191
|
|
191
192
|
// -------------------------------------------------------------------------------------------------------------------
|
@@ -1,12 +1,6 @@
|
|
1
1
|
import { DescriptorRegistry, Tag, } from '@rnoh/react-native-openharmony/ts';
|
2
2
|
import { ViewArkTS } from './View';
|
3
|
-
import { View } from '../core';
|
4
|
-
import type { ViewFinder } from "./RNGHRootTouchHandlerArkTS"
|
5
|
-
|
6
|
-
export interface ViewRegistry extends ViewFinder {
|
7
|
-
getViewByTag(viewTag: Tag)
|
8
|
-
save(view: View)
|
9
|
-
}
|
3
|
+
import { View, ViewRegistry } from '../core';
|
10
4
|
|
11
5
|
export class ViewRegistryArkTS implements ViewRegistry {
|
12
6
|
constructor(
|
@@ -27,6 +21,10 @@ export class ViewRegistryArkTS implements ViewRegistry {
|
|
27
21
|
*/
|
28
22
|
}
|
29
23
|
|
24
|
+
deleteByTag(viewTag: Tag) {
|
25
|
+
// No-op, ArkTS is going to be deprecated at some point in the future.
|
26
|
+
}
|
27
|
+
|
30
28
|
private createView(tag: Tag): ViewArkTS {
|
31
29
|
return new ViewArkTS(this.descriptorRegistry, tag);
|
32
30
|
}
|
@@ -77,6 +75,10 @@ export class ViewRegistryCAPI implements ViewRegistry {
|
|
77
75
|
this.viewByTag.set(view.getTag(), view)
|
78
76
|
}
|
79
77
|
|
78
|
+
deleteByTag(viewTag: Tag) {
|
79
|
+
this.viewByTag.delete(viewTag)
|
80
|
+
}
|
81
|
+
|
80
82
|
getViewByTag(viewTag: Tag) {
|
81
83
|
return this.viewByTag.get(viewTag);
|
82
84
|
}
|
Binary file
|
package/package.json
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
"type": "git",
|
9
9
|
"url": "https://github.com/react-native-oh-library/react-native-harmony-gesture-handler.git"
|
10
10
|
},
|
11
|
-
"version": "2.14.1-2.14.
|
11
|
+
"version": "2.14.1-2.14.13",
|
12
12
|
"description": "",
|
13
13
|
"react-native": "src/index.ts",
|
14
14
|
"main": "lib/commonjs/index.js",
|