@react-native-oh-tpl/react-native-gesture-handler 2.14.1-2.14.14 → 2.14.1-2.14.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.14';
4
+ export const HAR_VERSION = '2.14.1-2.14.15';
5
5
  export const BUILD_MODE_NAME = 'release';
6
6
  export const DEBUG = false;
7
7
  export const TARGET_NAME = 'default';
@@ -1,12 +1,5 @@
1
1
  {
2
2
  "apiType": 'stageMode',
3
- // "buildOption": {
4
- // "externalNativeOptions": {
5
- // "path": "./src/main/cpp/CMakeLists.txt",
6
- // "arguments": "",
7
- // "cppFlags": "",
8
- // },
9
- // },
10
3
  "targets": [
11
4
  {
12
5
  "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.14',
8
+ version: '2.14.1-2.14.15',
9
9
  dependencies: {
10
- "@rnoh/react-native-openharmony": "file:./react_native_openharmony"
10
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony"
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
- createUITurboModuleFactory(ctx: TurboModuleContext): TurboModulesFactory {
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 (const view of views) {
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,19 @@ 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; j > 1; j--) {
98
+ const currentView = views[j];
99
+ const parentView = views[j-1];
100
+ if (parentView.intersectsWith(currentView)) {
101
+ parentView.attachChildrenBoundingRects(currentView);
102
+ }
103
+ }
90
104
  }
91
105
 
92
106
  // send touch to gesture handlers, prioritize handling touch events for child components
@@ -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,45 @@ 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 rect = this.getBoundingRect();
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
+ attachChildrenBoundingRects(view: RNGHView) {
61
+ this.childrenBoundingBoxes.add(view.getBoundingRect())
62
+ for (const childBoundingBox of view.getChildrenBoundingRects()) {
63
+ this.childrenBoundingBoxes.add(childBoundingBox)
64
+ }
65
+ }
66
+
67
+ intersectsWith(view: RNGHView): boolean {
68
+ const rect1 = this.getBoundingRect()
69
+ const rect2 = view.getBoundingRect()
70
+ return (
71
+ rect1.x < rect2.x + rect2.width &&
72
+ rect1.x + rect1.width > rect2.x &&
73
+ rect1.y < rect2.y + rect2.height &&
74
+ rect1.y + rect1.height > rect2.y
75
+ )
76
+ }
77
+
55
78
  setButtonRole(buttonRole: boolean) {
56
79
  this.buttonRole = buttonRole
57
80
  }
@@ -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
- const result =
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 {
Binary file
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/react-native-oh-library/react-native-harmony-gesture-handler.git"
14
14
  },
15
- "version": "2.14.1-2.14.14",
15
+ "version": "2.14.1-2.14.15",
16
16
  "description": "",
17
17
  "react-native": "src/index.ts",
18
18
  "main": "lib/commonjs/index.js",