@react-native-oh-tpl/react-native-gesture-handler 2.14.14 → 2.14.16
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/harmony/gesture_handler/BuildProfile.ets +1 -1
- package/harmony/gesture_handler/build-profile.json5 +0 -7
- package/harmony/gesture_handler/oh-package-lock.json5 +6 -5
- package/harmony/gesture_handler/oh-package.json5 +2 -2
- package/harmony/gesture_handler/src/main/ets/gesture-handlers/PanGestureHandler.ts +14 -0
- package/harmony/gesture_handler/src/main/ets/rnoh/GestureHandlerPackage.ts +1 -1
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHRootViewController.ts +17 -3
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHView.ts +30 -3
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGHViewController.ts +1 -8
- package/harmony/gesture_handler/src/main/ets/rnoh/RNGestureHandlerModule.ts +3 -3
- 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.
|
4
|
+
export const HAR_VERSION = '2.14.16';
|
5
5
|
export const BUILD_MODE_NAME = 'release';
|
6
6
|
export const DEBUG = false;
|
7
7
|
export const TARGET_NAME = 'default';
|
@@ -5,14 +5,15 @@
|
|
5
5
|
"lockfileVersion": 3,
|
6
6
|
"ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
|
7
7
|
"specifiers": {
|
8
|
-
"@rnoh/react-native-openharmony
|
8
|
+
"@rnoh/react-native-openharmony@0.72.38": "@rnoh/react-native-openharmony@0.72.38"
|
9
9
|
},
|
10
10
|
"packages": {
|
11
|
-
"@rnoh/react-native-openharmony
|
11
|
+
"@rnoh/react-native-openharmony@0.72.38": {
|
12
12
|
"name": "@rnoh/react-native-openharmony",
|
13
|
-
"version": "0.72.
|
14
|
-
"
|
15
|
-
"
|
13
|
+
"version": "0.72.38",
|
14
|
+
"integrity": "sha512-br5SIrbB0OarSLirenleE7eTOX1lNccMJ7nb/G7qWTyJ7kW4DalmTXVKYpoT2qaOLls1uEE7McD1OjbZZM9jug==",
|
15
|
+
"resolved": "https://ohpm.openharmony.cn/ohpm/@rnoh/react-native-openharmony/-/react-native-openharmony-0.72.38.har",
|
16
|
+
"registryType": "ohpm"
|
16
17
|
}
|
17
18
|
}
|
18
19
|
}
|
@@ -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.
|
8
|
+
version: '2.14.16',
|
9
9
|
dependencies: {
|
10
|
-
"@rnoh/react-native-openharmony": "
|
10
|
+
"@rnoh/react-native-openharmony": "^0.72.32"
|
11
11
|
},
|
12
12
|
}
|
@@ -284,7 +284,13 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
284
284
|
if (this.currentState === State.ACTIVE) {
|
285
285
|
this.lastPos = this.tracker.getLastAvgPos();
|
286
286
|
}
|
287
|
+
|
287
288
|
this.tracker.removeFromTracker(event.pointerId);
|
289
|
+
|
290
|
+
if (this.tracker.getTrackedPointersCount() === 0) {
|
291
|
+
this.clearActivationTimeout();
|
292
|
+
}
|
293
|
+
|
288
294
|
if (this.currentState === State.ACTIVE) {
|
289
295
|
this.end();
|
290
296
|
} else {
|
@@ -358,4 +364,12 @@ export class PanGestureHandler extends GestureHandler<PanGestureHandlerConfig> {
|
|
358
364
|
this.unlockRNGestureResponder?.()
|
359
365
|
}
|
360
366
|
}
|
367
|
+
|
368
|
+
protected onCancel(): void {
|
369
|
+
this.clearActivationTimeout();
|
370
|
+
}
|
371
|
+
|
372
|
+
protected onReset(): void {
|
373
|
+
this.clearActivationTimeout();
|
374
|
+
}
|
361
375
|
}
|
@@ -19,7 +19,7 @@ class GestureHandlerTurboModuleFactory extends TurboModulesFactory {
|
|
19
19
|
* @deprecated: Use the package class exported from ../RNOHPackage.ets (2024-10-10)
|
20
20
|
*/
|
21
21
|
export class GestureHandlerPackage extends RNPackage {
|
22
|
-
|
22
|
+
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
|
23
23
|
return new GestureHandlerTurboModuleFactory(ctx);
|
24
24
|
}
|
25
25
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { TouchEvent as TouchEventArkTS, TouchType, TouchObject } from './types';
|
2
2
|
import { RNGHLogger, View, Multiset, GestureHandlerRegistry } from '../core';
|
3
|
-
import { RawTouchableView } from "./RNGHView"
|
3
|
+
import { RawTouchableView, RNGHView } from "./RNGHView"
|
4
4
|
import { RNGHViewController } from './RNGHViewController';
|
5
5
|
|
6
6
|
type RawTouchPoint = {
|
@@ -59,8 +59,9 @@ export class RNGHRootViewController {
|
|
59
59
|
if (e.type === TouchType.Down) {
|
60
60
|
this.activeViewTags.clear();
|
61
61
|
}
|
62
|
-
const views = touchableViews
|
63
|
-
for (
|
62
|
+
const views = touchableViews as RNGHView[]
|
63
|
+
for (let i = 0; i < views.length; i++) {
|
64
|
+
const view = views[i];
|
64
65
|
for (const handler of this.gestureHandlerRegistry.getGestureHandlersByViewTag(
|
65
66
|
view.getTag(),
|
66
67
|
)) {
|
@@ -87,6 +88,18 @@ export class RNGHRootViewController {
|
|
87
88
|
this.activeViewTags.add(view.getTag());
|
88
89
|
}
|
89
90
|
}
|
91
|
+
|
92
|
+
// If the pointer is inside the view but it overflows its parent, handlers attached to the parent
|
93
|
+
// might not have been called correctly (wrong bounding box). Extending the parent bounding box
|
94
|
+
// with the child bounding box ensures that the parent handlers are called correctly.
|
95
|
+
// This approach is slightly different from Android RNGH implementation (extracting parent gesture handlers),
|
96
|
+
// however, the outcome is the same.
|
97
|
+
for (let j = i - 1; j > 0; j--) {
|
98
|
+
const parentView = views[j];
|
99
|
+
if (parentView.intersectsWith(view)) {
|
100
|
+
parentView.attachChildrenBoundingRects(view);
|
101
|
+
}
|
102
|
+
}
|
90
103
|
}
|
91
104
|
|
92
105
|
// send touch to gesture handlers, prioritize handling touch events for child components
|
@@ -104,6 +117,7 @@ export class RNGHRootViewController {
|
|
104
117
|
|
105
118
|
if (touchEvent.type === TouchType.Up || touchEvent.type === TouchType.Cancel) {
|
106
119
|
touchableViews.forEach(view => this.touchableViewsMultiset.remove(view));
|
120
|
+
views.forEach(view => view.resetChildrenBoundingRects());
|
107
121
|
}
|
108
122
|
}
|
109
123
|
|
@@ -20,6 +20,7 @@ export class RNGHView implements View {
|
|
20
20
|
private tag: number
|
21
21
|
private buttonRole: boolean
|
22
22
|
private boundingBox: BoundingBox
|
23
|
+
private childrenBoundingBoxes: Set<BoundingBox> = new Set()
|
23
24
|
|
24
25
|
constructor({ tag, buttonRole, ...boundingBox }: RawTouchableView) {
|
25
26
|
this.tag = tag
|
@@ -35,23 +36,49 @@ export class RNGHView implements View {
|
|
35
36
|
return { ...this.boundingBox }
|
36
37
|
}
|
37
38
|
|
39
|
+
getChildrenBoundingRects(): BoundingBox[] {
|
40
|
+
return Array.from(this.childrenBoundingBoxes)
|
41
|
+
}
|
42
|
+
|
38
43
|
isPositionInBounds({ x, y }: {
|
39
44
|
x: number;
|
40
45
|
y: number
|
41
46
|
}): boolean {
|
42
|
-
const
|
43
|
-
return (
|
47
|
+
const rects = [this.boundingBox, ...this.childrenBoundingBoxes]
|
48
|
+
return rects.some(rect => (
|
44
49
|
x >= rect.x &&
|
45
50
|
x <= rect.x + rect.width &&
|
46
51
|
y >= rect.y &&
|
47
52
|
y <= rect.y + rect.height
|
48
|
-
)
|
53
|
+
))
|
49
54
|
}
|
50
55
|
|
51
56
|
updateBoundingBox(boundingBox: BoundingBox) {
|
52
57
|
this.boundingBox = boundingBox
|
53
58
|
}
|
54
59
|
|
60
|
+
resetChildrenBoundingRects() {
|
61
|
+
this.childrenBoundingBoxes.clear()
|
62
|
+
}
|
63
|
+
|
64
|
+
attachChildrenBoundingRects(view: RNGHView) {
|
65
|
+
this.childrenBoundingBoxes.add(view.getBoundingRect())
|
66
|
+
for (const childBoundingBox of view.getChildrenBoundingRects()) {
|
67
|
+
this.childrenBoundingBoxes.add(childBoundingBox)
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
intersectsWith(view: RNGHView): boolean {
|
72
|
+
const rect1 = this.getBoundingRect()
|
73
|
+
const rect2 = view.getBoundingRect()
|
74
|
+
return (
|
75
|
+
rect1.x < rect2.x + rect2.width &&
|
76
|
+
rect1.x + rect1.width > rect2.x &&
|
77
|
+
rect1.y < rect2.y + rect2.height &&
|
78
|
+
rect1.y + rect1.height > rect2.y
|
79
|
+
)
|
80
|
+
}
|
81
|
+
|
55
82
|
setButtonRole(buttonRole: boolean) {
|
56
83
|
this.buttonRole = buttonRole
|
57
84
|
}
|
@@ -165,16 +165,9 @@ export class RNGHViewController {
|
|
165
165
|
}
|
166
166
|
|
167
167
|
private isInBounds(point: Point): boolean {
|
168
|
-
const x = point.x;
|
169
|
-
const y = point.y;
|
170
168
|
const rect = this.view.getBoundingRect();
|
171
169
|
this.logger.cloneAndJoinPrefix("isInBounds").debug({ rect })
|
172
|
-
|
173
|
-
x >= rect.x &&
|
174
|
-
x <= rect.x + rect.width &&
|
175
|
-
y >= rect.y &&
|
176
|
-
y <= rect.y + rect.height;
|
177
|
-
return result;
|
170
|
+
return this.view.isPositionInBounds(point);
|
178
171
|
}
|
179
172
|
|
180
173
|
private updateActivePointers(touchType: TouchType, pointerId: number): void {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { TurboModule, TurboModuleContext, Tag } from "@rnoh/react-native-openharmony/ts";
|
2
2
|
import { TM } from "@rnoh/react-native-openharmony/generated/ts"
|
3
3
|
import {
|
4
4
|
GestureHandlerRegistry,
|
@@ -25,7 +25,7 @@ export enum ActionType {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
|
28
|
-
export class RNGestureHandlerModule extends
|
28
|
+
export class RNGestureHandlerModule extends TurboModule implements TM.RNGestureHandlerModule.Spec {
|
29
29
|
static readonly NAME = "RNGestureHandlerModule"
|
30
30
|
|
31
31
|
private gestureHandlerRegistry: GestureHandlerRegistry
|
@@ -36,7 +36,7 @@ export class RNGestureHandlerModule extends UITurboModule implements TM.RNGestur
|
|
36
36
|
private rootViewControllerByRootTag = new Map<Tag, RNGHRootViewController>()
|
37
37
|
private interactionManager: InteractionManager
|
38
38
|
|
39
|
-
constructor(ctx:
|
39
|
+
constructor(ctx: TurboModuleContext, isDevModeEnabled: boolean = false) {
|
40
40
|
super(ctx)
|
41
41
|
this.cleanLogger =
|
42
42
|
isDevModeEnabled && ctx.isDebugModeEnabled ? new DevelopmentRNGHLogger(ctx.logger, "RNGH") :
|
Binary file
|
package/package.json
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
"type": "git",
|
18
18
|
"url": "https://github.com/react-native-oh-library/react-native-harmony-gesture-handler.git"
|
19
19
|
},
|
20
|
-
"version": "2.14.
|
20
|
+
"version": "2.14.16",
|
21
21
|
"description": "",
|
22
22
|
"react-native": "src/index.ts",
|
23
23
|
"main": "lib/commonjs/index.js",
|