@react-native-oh-tpl/react-native-gesture-handler 2.12.6-1 → 2.12.6-2
Sign up to get free protection for your applications and to get access to all the features.
- package/harmony/gesture_handler/LICENSE +21 -0
- package/harmony/gesture_handler/OAT.xml +44 -0
- package/harmony/gesture_handler/README.OpenSource +11 -0
- package/harmony/gesture_handler/README.md +1 -0
- package/harmony/gesture_handler/build-profile.json5 +7 -7
- package/harmony/gesture_handler/hvigorfile.ts +2 -2
- package/harmony/gesture_handler/index.ets +2 -2
- package/harmony/gesture_handler/oh-package.json5 +13 -11
- package/harmony/gesture_handler/src/main/cpp/CMakeLists.txt +8 -8
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.cpp +33 -33
- package/harmony/gesture_handler/src/main/cpp/GestureHandlerPackage.h +14 -14
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerButtonComponentDescriptor.h +60 -60
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.cpp +17 -17
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerModule.h +11 -11
- package/harmony/gesture_handler/src/main/cpp/RNGestureHandlerRootViewComponentDescriptor.h +60 -60
- 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 +37 -37
- package/harmony/gesture_handler/src/main/ets/GestureHandler.ts +663 -663
- package/harmony/gesture_handler/src/main/ets/GestureHandlerArkUIAdapter.ets +201 -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 +28 -28
- package/harmony/gesture_handler/src/main/ets/RNGHRootTouchHandler.ets +57 -57
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerButton.ets +36 -36
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerModule.ts +125 -125
- package/harmony/gesture_handler/src/main/ets/RNGestureHandlerRootView.ets +56 -55
- package/harmony/gesture_handler/src/main/ets/RNOHScrollLocker.ts +10 -10
- 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/pages/Index.ets +16 -16
- package/harmony/gesture_handler/src/main/ets/webviewability/WebviewAbility.ts +41 -41
- package/harmony/gesture_handler/src/main/module.json5 +6 -6
- 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.har +0 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js +9 -9
- package/lib/commonjs/components/touchables/TouchableOpacity.js +2 -2
- package/lib/commonjs/handlers/createNativeWrapper.js +6 -6
- package/lib/commonjs/handlers/gestures/GestureDetector.js +3 -3
- package/lib/module/components/touchables/GenericTouchable.js +9 -9
- package/lib/module/components/touchables/TouchableOpacity.js +2 -2
- package/lib/module/handlers/createNativeWrapper.js +6 -6
- package/lib/module/handlers/gestures/GestureDetector.js +3 -3
- package/package.json +70 -70
- package/src/RNGestureHandlerModule.ts +6 -6
- package/src/components/GestureButtons.tsx +334 -334
- package/src/components/GestureHandlerButton.tsx +5 -5
- package/src/components/GestureHandlerRootView.tsx +34 -34
- package/src/components/RNGestureHandlerButton.tsx +23 -23
- package/src/components/touchables/GenericTouchable.tsx +301 -301
- package/src/components/touchables/TouchableOpacity.tsx +76 -76
- package/src/components/touchables/TouchableWithoutFeedback.tsx +14 -14
- package/src/components/touchables/index.ts +7 -7
- package/src/handlers/NativeViewGestureHandler.ts +55 -55
- package/src/handlers/PanGestureHandler.ts +327 -327
- package/src/handlers/TapGestureHandler.ts +95 -95
- package/src/handlers/createHandler.tsx +535 -535
- package/src/handlers/createNativeWrapper.tsx +81 -81
- package/src/handlers/gestureHandlerCommon.ts +15 -15
- package/src/handlers/gestures/GestureDetector.tsx +823 -823
- package/src/index.ts +172 -172
- package/src/init.ts +18 -18
@@ -1,115 +1,115 @@
|
|
1
|
-
import { GestureHandler, GestureHandlerDependencies, DEFAULT_TOUCH_SLOP } from "./GestureHandler"
|
2
|
-
import { Vector2D } from './Vector2D';
|
3
|
-
import { State } from "./State"
|
4
|
-
import { AdaptedEvent } from './Event';
|
5
|
-
|
6
|
-
export class NativeViewGestureHandler extends GestureHandler {
|
7
|
-
private minDistSq = DEFAULT_TOUCH_SLOP * DEFAULT_TOUCH_SLOP;
|
8
|
-
|
9
|
-
protected startPos = new Vector2D()
|
10
|
-
|
11
|
-
public canBeInterrupted() {
|
12
|
-
return !(this.config.disallowInterruption ?? false)
|
13
|
-
}
|
14
|
-
|
15
|
-
constructor(deps: GestureHandlerDependencies) {
|
16
|
-
super({ ...deps, logger: deps.logger.cloneWithPrefix("NativeViewGestureHandler") })
|
17
|
-
}
|
18
|
-
|
19
|
-
public getDefaultConfig() {
|
20
|
-
return {}
|
21
|
-
}
|
22
|
-
|
23
|
-
public onPointerDown(e: AdaptedEvent) {
|
24
|
-
this.tracker.addToTracker(e);
|
25
|
-
super.onPointerDown(e);
|
26
|
-
this.onNewPointer();
|
27
|
-
}
|
28
|
-
|
29
|
-
protected onNewPointer() {
|
30
|
-
this.startPos = this.tracker.getLastAvgPos();
|
31
|
-
if (this.currentState !== State.UNDETERMINED)
|
32
|
-
return;
|
33
|
-
this.begin();
|
34
|
-
this.activate();
|
35
|
-
}
|
36
|
-
|
37
|
-
public onAdditionalPointerAdd(e: AdaptedEvent) {
|
38
|
-
this.tracker.addToTracker(e);
|
39
|
-
super.onPointerDown(e);
|
40
|
-
this.onNewPointer();
|
41
|
-
}
|
42
|
-
|
43
|
-
public onPointerMove(e: AdaptedEvent): void {
|
44
|
-
this.tracker.track(e);
|
45
|
-
const {x: dx, y: dy} = this.startPos.clone().subtract(this.tracker.getLastAvgPos()).value
|
46
|
-
const distSq = dx * dx + dy * dy;
|
47
|
-
|
48
|
-
if (distSq >= this.minDistSq) {
|
49
|
-
if (this.currentState === State.ACTIVE) {
|
50
|
-
this.cancel();
|
51
|
-
} else if (this.currentState === State.BEGAN) {
|
52
|
-
this.activate();
|
53
|
-
}
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
public onPointerLeave(): void {
|
58
|
-
// TODO: add this method to GestureHandler
|
59
|
-
if (this.currentState === State.BEGAN || this.currentState === State.ACTIVE) {
|
60
|
-
this.cancel();
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
public onPointerUp(event: AdaptedEvent): void {
|
65
|
-
super.onPointerUp(event);
|
66
|
-
this.onAnyPointerUp(event);
|
67
|
-
}
|
68
|
-
|
69
|
-
private onAnyPointerUp(e: AdaptedEvent) {
|
70
|
-
this.tracker.removeFromTracker(e.pointerId);
|
71
|
-
if (this.tracker.getTrackedPointersCount() === 0) {
|
72
|
-
if (this.currentState === State.ACTIVE) {
|
73
|
-
this.end();
|
74
|
-
} else {
|
75
|
-
this.fail();
|
76
|
-
}
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
public onAdditionalPointerRemove(e: AdaptedEvent) {
|
81
|
-
super.onAdditionalPointerRemove(e)
|
82
|
-
this.onAnyPointerUp(e)
|
83
|
-
}
|
84
|
-
|
85
|
-
public shouldRecognizeSimultaneously(handler: GestureHandler): boolean {
|
86
|
-
if (super.shouldRecognizeSimultaneously(handler)) {
|
87
|
-
return true;
|
88
|
-
}
|
89
|
-
if (
|
90
|
-
handler instanceof NativeViewGestureHandler &&
|
91
|
-
handler.getState() === State.ACTIVE &&
|
92
|
-
!handler.canBeInterrupted()
|
93
|
-
) {
|
94
|
-
return false;
|
95
|
-
}
|
96
|
-
|
97
|
-
if (
|
98
|
-
this.currentState === State.ACTIVE &&
|
99
|
-
handler.getState() === State.ACTIVE &&
|
100
|
-
this.canBeInterrupted()
|
101
|
-
) {
|
102
|
-
return false;
|
103
|
-
}
|
104
|
-
|
105
|
-
return (
|
106
|
-
this.currentState === State.ACTIVE &&
|
107
|
-
this.canBeInterrupted() &&
|
108
|
-
handler.getTag() > 0
|
109
|
-
);
|
110
|
-
}
|
111
|
-
|
112
|
-
public shouldBeCancelledByOther(_handler: GestureHandler): boolean {
|
113
|
-
return this.canBeInterrupted();
|
114
|
-
}
|
1
|
+
import { GestureHandler, GestureHandlerDependencies, DEFAULT_TOUCH_SLOP } from "./GestureHandler"
|
2
|
+
import { Vector2D } from './Vector2D';
|
3
|
+
import { State } from "./State"
|
4
|
+
import { AdaptedEvent } from './Event';
|
5
|
+
|
6
|
+
export class NativeViewGestureHandler extends GestureHandler {
|
7
|
+
private minDistSq = DEFAULT_TOUCH_SLOP * DEFAULT_TOUCH_SLOP;
|
8
|
+
|
9
|
+
protected startPos = new Vector2D()
|
10
|
+
|
11
|
+
public canBeInterrupted() {
|
12
|
+
return !(this.config.disallowInterruption ?? false)
|
13
|
+
}
|
14
|
+
|
15
|
+
constructor(deps: GestureHandlerDependencies) {
|
16
|
+
super({ ...deps, logger: deps.logger.cloneWithPrefix("NativeViewGestureHandler") })
|
17
|
+
}
|
18
|
+
|
19
|
+
public getDefaultConfig() {
|
20
|
+
return {}
|
21
|
+
}
|
22
|
+
|
23
|
+
public onPointerDown(e: AdaptedEvent) {
|
24
|
+
this.tracker.addToTracker(e);
|
25
|
+
super.onPointerDown(e);
|
26
|
+
this.onNewPointer();
|
27
|
+
}
|
28
|
+
|
29
|
+
protected onNewPointer() {
|
30
|
+
this.startPos = this.tracker.getLastAvgPos();
|
31
|
+
if (this.currentState !== State.UNDETERMINED)
|
32
|
+
return;
|
33
|
+
this.begin();
|
34
|
+
this.activate();
|
35
|
+
}
|
36
|
+
|
37
|
+
public onAdditionalPointerAdd(e: AdaptedEvent) {
|
38
|
+
this.tracker.addToTracker(e);
|
39
|
+
super.onPointerDown(e);
|
40
|
+
this.onNewPointer();
|
41
|
+
}
|
42
|
+
|
43
|
+
public onPointerMove(e: AdaptedEvent): void {
|
44
|
+
this.tracker.track(e);
|
45
|
+
const {x: dx, y: dy} = this.startPos.clone().subtract(this.tracker.getLastAvgPos()).value
|
46
|
+
const distSq = dx * dx + dy * dy;
|
47
|
+
|
48
|
+
if (distSq >= this.minDistSq) {
|
49
|
+
if (this.currentState === State.ACTIVE) {
|
50
|
+
this.cancel();
|
51
|
+
} else if (this.currentState === State.BEGAN) {
|
52
|
+
this.activate();
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
public onPointerLeave(): void {
|
58
|
+
// TODO: add this method to GestureHandler
|
59
|
+
if (this.currentState === State.BEGAN || this.currentState === State.ACTIVE) {
|
60
|
+
this.cancel();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
public onPointerUp(event: AdaptedEvent): void {
|
65
|
+
super.onPointerUp(event);
|
66
|
+
this.onAnyPointerUp(event);
|
67
|
+
}
|
68
|
+
|
69
|
+
private onAnyPointerUp(e: AdaptedEvent) {
|
70
|
+
this.tracker.removeFromTracker(e.pointerId);
|
71
|
+
if (this.tracker.getTrackedPointersCount() === 0) {
|
72
|
+
if (this.currentState === State.ACTIVE) {
|
73
|
+
this.end();
|
74
|
+
} else {
|
75
|
+
this.fail();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
public onAdditionalPointerRemove(e: AdaptedEvent) {
|
81
|
+
super.onAdditionalPointerRemove(e)
|
82
|
+
this.onAnyPointerUp(e)
|
83
|
+
}
|
84
|
+
|
85
|
+
public shouldRecognizeSimultaneously(handler: GestureHandler): boolean {
|
86
|
+
if (super.shouldRecognizeSimultaneously(handler)) {
|
87
|
+
return true;
|
88
|
+
}
|
89
|
+
if (
|
90
|
+
handler instanceof NativeViewGestureHandler &&
|
91
|
+
handler.getState() === State.ACTIVE &&
|
92
|
+
!handler.canBeInterrupted()
|
93
|
+
) {
|
94
|
+
return false;
|
95
|
+
}
|
96
|
+
|
97
|
+
if (
|
98
|
+
this.currentState === State.ACTIVE &&
|
99
|
+
handler.getState() === State.ACTIVE &&
|
100
|
+
this.canBeInterrupted()
|
101
|
+
) {
|
102
|
+
return false;
|
103
|
+
}
|
104
|
+
|
105
|
+
return (
|
106
|
+
this.currentState === State.ACTIVE &&
|
107
|
+
this.canBeInterrupted() &&
|
108
|
+
handler.getTag() > 0
|
109
|
+
);
|
110
|
+
}
|
111
|
+
|
112
|
+
public shouldBeCancelledByOther(_handler: GestureHandler): boolean {
|
113
|
+
return this.canBeInterrupted();
|
114
|
+
}
|
115
115
|
}
|
@@ -1,34 +1,34 @@
|
|
1
|
-
import { State } from "./State"
|
2
|
-
import { TouchEventType } from "./Event"
|
3
|
-
|
4
|
-
export interface GestureEventPayload {
|
5
|
-
handlerTag: number;
|
6
|
-
numberOfPointers: number;
|
7
|
-
state: State;
|
8
|
-
}
|
9
|
-
|
10
|
-
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
11
|
-
oldState: State;
|
12
|
-
}
|
13
|
-
|
14
|
-
export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> = GestureEventPayload
|
15
|
-
& GestureEventPayloadT
|
16
|
-
|
17
|
-
export type GestureStateChangeEvent<GestureStateChangeEventPayloadT = Record<string, unknown>> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT
|
18
|
-
|
19
|
-
export type TouchData = {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
};
|
26
|
-
|
27
|
-
export type GestureTouchEvent = {
|
28
|
-
|
29
|
-
numberOfTouches: number;
|
30
|
-
|
31
|
-
eventType: TouchEventType;
|
32
|
-
allTouches: TouchData[];
|
33
|
-
changedTouches: TouchData[];
|
1
|
+
import { State } from "./State"
|
2
|
+
import { TouchEventType } from "./Event"
|
3
|
+
|
4
|
+
export interface GestureEventPayload {
|
5
|
+
handlerTag: number;
|
6
|
+
numberOfPointers: number;
|
7
|
+
state: State;
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
11
|
+
oldState: State;
|
12
|
+
}
|
13
|
+
|
14
|
+
export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> = GestureEventPayload
|
15
|
+
& GestureEventPayloadT
|
16
|
+
|
17
|
+
export type GestureStateChangeEvent<GestureStateChangeEventPayloadT = Record<string, unknown>> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT
|
18
|
+
|
19
|
+
export type TouchData = {
|
20
|
+
absoluteX: number;
|
21
|
+
absoluteY: number;
|
22
|
+
x: number;
|
23
|
+
y: number;
|
24
|
+
id: number;
|
25
|
+
};
|
26
|
+
|
27
|
+
export type GestureTouchEvent = {
|
28
|
+
state: State;
|
29
|
+
numberOfTouches: number;
|
30
|
+
handlerTag: number;
|
31
|
+
eventType: TouchEventType;
|
32
|
+
allTouches: TouchData[];
|
33
|
+
changedTouches: TouchData[];
|
34
34
|
};
|