react-native-gesture-handler 2.21.2 → 2.22.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -3
- package/android/build.gradle +10 -0
- package/android/package77/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +85 -0
- package/android/{src → packageDeprecated/src}/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +2 -3
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +3 -2
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +3 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +16 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +45 -8
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +18 -0
- package/apple/Handlers/RNFlingHandler.m +0 -1
- package/apple/Handlers/RNForceTouchHandler.m +0 -1
- package/apple/Handlers/RNLongPressHandler.m +0 -1
- package/apple/Handlers/RNManualHandler.m +0 -1
- package/apple/Handlers/RNPanHandler.m +0 -3
- package/apple/Handlers/RNPinchHandler.m +0 -1
- package/apple/Handlers/RNRotationHandler.m +0 -1
- package/apple/Handlers/RNTapHandler.m +0 -1
- package/apple/RNGestureHandlerButton.h +1 -0
- package/apple/RNGestureHandlerButton.mm +51 -0
- package/apple/RNGestureHandlerManager.mm +6 -1
- package/apple/RNManualActivationRecognizer.m +1 -0
- package/lib/commonjs/ActionType.js.map +1 -1
- package/lib/commonjs/Directions.js.map +1 -1
- package/lib/commonjs/EnableNewWebImplementation.js +14 -1
- package/lib/commonjs/EnableNewWebImplementation.js.map +1 -1
- package/lib/commonjs/State.js.map +1 -1
- package/lib/commonjs/TouchEventType.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/components/Swipeable.js.map +1 -1
- package/lib/commonjs/components/Text.js +61 -0
- package/lib/commonjs/components/Text.js.map +1 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +10 -2
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/ghQueueMicrotask.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +12 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js +4 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js +4 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js +48 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/utils.js +1 -0
- package/lib/commonjs/handlers/utils.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
- package/lib/commonjs/mountRegistry.js +49 -0
- package/lib/commonjs/mountRegistry.js.map +1 -0
- package/lib/commonjs/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +3 -5
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -10
- package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -14
- package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -4
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
- package/lib/commonjs/web_hammer/PressGestureHandler.js.map +1 -1
- package/lib/module/ActionType.js.map +1 -1
- package/lib/module/Directions.js.map +1 -1
- package/lib/module/EnableNewWebImplementation.js +14 -1
- package/lib/module/EnableNewWebImplementation.js.map +1 -1
- package/lib/module/State.js.map +1 -1
- package/lib/module/TouchEventType.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +1 -1
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/components/Swipeable.js.map +1 -1
- package/lib/module/components/Text.js +44 -0
- package/lib/module/components/Text.js.map +1 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +10 -2
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/ghQueueMicrotask.js.map +1 -1
- package/lib/module/handlers/createHandler.js +11 -0
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js +3 -0
- package/lib/module/handlers/gestures/GestureDetector/attachHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/dropHandlers.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +2 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js +39 -0
- package/lib/module/handlers/gestures/GestureDetector/useMountReactions.js.map +1 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/utils.js +1 -3
- package/lib/module/handlers/utils.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jestUtils/jestUtils.js.map +1 -1
- package/lib/module/mountRegistry.js +40 -0
- package/lib/module/mountRegistry.js.map +1 -0
- package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +0 -4
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +0 -14
- package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +6 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/ManualGestureHandler.js +0 -14
- package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +3 -5
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +0 -4
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PinchGestureHandler.js +0 -10
- package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/RotationGestureHandler.js +0 -14
- package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +0 -4
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web_hammer/GestureHandler.js.map +1 -1
- package/lib/module/web_hammer/PressGestureHandler.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +1 -1
- package/lib/typescript/Directions.d.ts +2 -2
- package/lib/typescript/EnableNewWebImplementation.d.ts +6 -0
- package/lib/typescript/State.d.ts +1 -1
- package/lib/typescript/TouchEventType.d.ts +1 -1
- package/lib/typescript/components/GestureButtonsProps.d.ts +2 -2
- package/lib/typescript/components/Text.d.ts +4 -0
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -1
- package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +2 -2
- package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +1 -1
- package/lib/typescript/handlers/utils.d.ts +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/mocks.d.ts +3 -3
- package/lib/typescript/mountRegistry.d.ts +17 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -2
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -4
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
- package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -4
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -2
- package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -2
- package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -3
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -2
- package/package.json +18 -17
- package/src/ActionType.ts +1 -1
- package/src/Directions.ts +2 -2
- package/src/EnableNewWebImplementation.ts +18 -0
- package/src/State.ts +1 -1
- package/src/TouchEventType.ts +2 -1
- package/src/components/GestureButtonsProps.ts +4 -2
- package/src/components/Pressable/Pressable.tsx +3 -3
- package/src/components/ReanimatedSwipeable.tsx +8 -8
- package/src/components/Swipeable.tsx +4 -4
- package/src/components/Text.tsx +60 -0
- package/src/components/touchables/GenericTouchable.tsx +1 -1
- package/src/getShadowNodeFromRef.ts +8 -2
- package/src/ghQueueMicrotask.ts +2 -2
- package/src/handlers/GestureHandlerEventPayload.ts +2 -2
- package/src/handlers/createHandler.tsx +14 -1
- package/src/handlers/gestureHandlerCommon.ts +3 -3
- package/src/handlers/gestures/GestureDetector/attachHandlers.ts +3 -0
- package/src/handlers/gestures/GestureDetector/dropHandlers.ts +3 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +3 -0
- package/src/handlers/gestures/GestureDetector/useMountReactions.ts +51 -0
- package/src/handlers/gestures/gesture.ts +3 -3
- package/src/handlers/utils.ts +2 -1
- package/src/index.ts +1 -0
- package/src/jestUtils/jestUtils.ts +10 -12
- package/src/mountRegistry.ts +51 -0
- package/src/web/detectors/ScaleGestureDetector.ts +1 -1
- package/src/web/handlers/FlingGestureHandler.ts +0 -4
- package/src/web/handlers/GestureHandler.ts +1 -3
- package/src/web/handlers/HoverGestureHandler.ts +1 -9
- package/src/web/handlers/LongPressGestureHandler.ts +6 -0
- package/src/web/handlers/ManualGestureHandler.ts +1 -9
- package/src/web/handlers/NativeViewGestureHandler.ts +5 -5
- package/src/web/handlers/PanGestureHandler.ts +0 -4
- package/src/web/handlers/PinchGestureHandler.ts +1 -5
- package/src/web/handlers/RotationGestureHandler.ts +1 -9
- package/src/web/handlers/TapGestureHandler.ts +0 -4
- package/src/web/tools/GestureHandlerWebDelegate.ts +4 -4
- package/src/web_hammer/GestureHandler.ts +1 -1
- package/src/web_hammer/PressGestureHandler.ts +7 -4
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { AdaptedEvent
|
2
|
+
import { AdaptedEvent } from '../interfaces';
|
3
3
|
import GestureHandler from './GestureHandler';
|
4
4
|
export default class RotationGestureHandler extends GestureHandler {
|
5
5
|
private rotation;
|
@@ -9,7 +9,6 @@ export default class RotationGestureHandler extends GestureHandler {
|
|
9
9
|
private rotationGestureListener;
|
10
10
|
private rotationGestureDetector;
|
11
11
|
init(ref: number, propsRef: React.RefObject<unknown>): void;
|
12
|
-
updateGestureConfig({ enabled, ...props }: Config): void;
|
13
12
|
protected transformNativeEvent(): {
|
14
13
|
rotation: number;
|
15
14
|
anchorX: number;
|
@@ -25,6 +24,5 @@ export default class RotationGestureHandler extends GestureHandler {
|
|
25
24
|
protected onPointerUp(event: AdaptedEvent): void;
|
26
25
|
protected onPointerRemove(event: AdaptedEvent): void;
|
27
26
|
protected tryBegin(): void;
|
28
|
-
activate(_force?: boolean): void;
|
29
27
|
protected onReset(): void;
|
30
28
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
/// <reference types="react" />
|
2
1
|
import { AdaptedEvent, Config } from '../interfaces';
|
3
2
|
import GestureHandler from './GestureHandler';
|
4
3
|
export default class TapGestureHandler extends GestureHandler {
|
@@ -19,7 +18,6 @@ export default class TapGestureHandler extends GestureHandler {
|
|
19
18
|
private waitTimeout;
|
20
19
|
private delayTimeout;
|
21
20
|
private tapsSoFar;
|
22
|
-
init(ref: number, propsRef: React.RefObject<unknown>): void;
|
23
21
|
updateGestureConfig({ enabled, ...props }: Config): void;
|
24
22
|
protected resetConfig(): void;
|
25
23
|
private clearTimeouts;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.22.0",
|
4
4
|
"description": "Declarative API exposing native platform touch and gesture system to React Native",
|
5
5
|
"scripts": {
|
6
6
|
"prepare": "bob build && husky install",
|
@@ -39,6 +39,8 @@
|
|
39
39
|
"android/common/src/main/java/",
|
40
40
|
"android/reanimated/src/main/java/",
|
41
41
|
"android/noreanimated/src/main/java/",
|
42
|
+
"android/package77/",
|
43
|
+
"android/packageDeprecated/",
|
42
44
|
"apple/",
|
43
45
|
"Swipeable/",
|
44
46
|
"ReanimatedSwipeable/",
|
@@ -66,44 +68,38 @@
|
|
66
68
|
"dependencies": {
|
67
69
|
"@egjs/hammerjs": "^2.0.17",
|
68
70
|
"hoist-non-react-statics": "^3.3.0",
|
69
|
-
"invariant": "^2.2.4"
|
70
|
-
"prop-types": "^15.7.2"
|
71
|
+
"invariant": "^2.2.4"
|
71
72
|
},
|
72
73
|
"devDependencies": {
|
73
|
-
"@babel/core": "^7.
|
74
|
-
"@babel/
|
75
|
-
"@babel/preset-env": "^7.12.11",
|
74
|
+
"@babel/core": "^7.25.2",
|
75
|
+
"@babel/preset-env": "^7.25.3",
|
76
76
|
"@babel/preset-typescript": "^7.12.7",
|
77
|
-
"@babel
|
78
|
-
"@react-native/babel-preset": "^0.74.85",
|
79
|
-
"@testing-library/jest-native": "^5.4.3",
|
77
|
+
"@react-native/babel-preset": "0.77.0-rc.3",
|
80
78
|
"@testing-library/react-native": "^12.5.1",
|
81
|
-
"@types/hammerjs": "^2.0.38",
|
82
79
|
"@types/hoist-non-react-statics": "^3.3.1",
|
80
|
+
"@types/invariant": "^2.2.37",
|
83
81
|
"@types/jest": "^27.0.3",
|
84
82
|
"@types/react": "^18.2.6",
|
85
83
|
"@types/react-test-renderer": "^17.0.0",
|
86
84
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
87
85
|
"@typescript-eslint/parser": "^4.33.0",
|
88
|
-
"babel-
|
86
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
89
87
|
"clang-format": "^1.8.0",
|
90
88
|
"eslint": "^7.32.0",
|
91
89
|
"eslint-config-satya164": "^3.1.8",
|
92
90
|
"eslint-import-resolver-babel-module": "^5.2.0",
|
93
|
-
"eslint-plugin-import": "^2.22.1",
|
94
91
|
"eslint-plugin-jest": "^26.0.0",
|
92
|
+
"eslint-plugin-prettier": "^5.2.1",
|
95
93
|
"expo": "^35.0.1",
|
96
94
|
"husky": "^8.0.1",
|
97
95
|
"jest": "^28.1.0",
|
98
96
|
"lint-staged": "^12.3.2",
|
99
97
|
"madge": "^6.1.0",
|
100
|
-
"prettier": "
|
101
|
-
"react": "18.
|
102
|
-
"react-
|
103
|
-
"react-native": "0.74.3",
|
98
|
+
"prettier": "3.3.3",
|
99
|
+
"react": "18.3.1",
|
100
|
+
"react-native": "0.77.0-rc.3",
|
104
101
|
"react-native-builder-bob": "^0.17.1",
|
105
102
|
"react-native-reanimated": "^3.12.0",
|
106
|
-
"react-native-web": "^0.11.7",
|
107
103
|
"react-test-renderer": "18.2.0",
|
108
104
|
"release-it": "^13.6.5",
|
109
105
|
"typescript": "5.0.4"
|
@@ -150,6 +146,11 @@
|
|
150
146
|
"jsSrcsDir": "./src/specs",
|
151
147
|
"android": {
|
152
148
|
"javaPackageName": "com.swmansion.gesturehandler"
|
149
|
+
},
|
150
|
+
"ios": {
|
151
|
+
"componentProvider": {
|
152
|
+
"RNGestureHandlerButton": "RNGestureHandlerButtonComponentView"
|
153
|
+
}
|
153
154
|
}
|
154
155
|
},
|
155
156
|
"packageManager": "yarn@1.22.22"
|
package/src/ActionType.ts
CHANGED
@@ -6,4 +6,4 @@ export const ActionType = {
|
|
6
6
|
} as const;
|
7
7
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
9
|
-
export type ActionType = typeof ActionType[keyof typeof ActionType];
|
9
|
+
export type ActionType = (typeof ActionType)[keyof typeof ActionType];
|
package/src/Directions.ts
CHANGED
@@ -20,7 +20,7 @@ export const DiagonalDirections = {
|
|
20
20
|
} as const;
|
21
21
|
|
22
22
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
23
|
-
export type Directions = typeof Directions[keyof typeof Directions];
|
23
|
+
export type Directions = (typeof Directions)[keyof typeof Directions];
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
25
25
|
export type DiagonalDirections =
|
26
|
-
typeof DiagonalDirections[keyof typeof DiagonalDirections];
|
26
|
+
(typeof DiagonalDirections)[keyof typeof DiagonalDirections];
|
@@ -1,17 +1,35 @@
|
|
1
1
|
import { Platform } from 'react-native';
|
2
|
+
import { tagMessage } from './utils';
|
2
3
|
|
3
4
|
let useNewWebImplementation = true;
|
4
5
|
let getWasCalled = false;
|
5
6
|
|
7
|
+
/**
|
8
|
+
* @deprecated new web implementation is enabled by default. This function will be removed in Gesture Handler 3
|
9
|
+
*/
|
6
10
|
export function enableExperimentalWebImplementation(
|
7
11
|
_shouldEnable = true
|
8
12
|
): void {
|
9
13
|
// NO-OP since the new implementation is now the default
|
14
|
+
console.warn(
|
15
|
+
tagMessage(
|
16
|
+
'New web implementation is enabled by default. This function will be removed in Gesture Handler 3.'
|
17
|
+
)
|
18
|
+
);
|
10
19
|
}
|
11
20
|
|
21
|
+
/**
|
22
|
+
* @deprecated legacy implementation is no longer supported. This function will be removed in Gesture Handler 3
|
23
|
+
*/
|
12
24
|
export function enableLegacyWebImplementation(
|
13
25
|
shouldUseLegacyImplementation = true
|
14
26
|
): void {
|
27
|
+
console.warn(
|
28
|
+
tagMessage(
|
29
|
+
'Legacy web implementation is deprecated. This function will be removed in Gesture Handler 3.'
|
30
|
+
)
|
31
|
+
);
|
32
|
+
|
15
33
|
if (
|
16
34
|
Platform.OS !== 'web' ||
|
17
35
|
useNewWebImplementation === !shouldUseLegacyImplementation
|
package/src/State.ts
CHANGED
@@ -10,4 +10,4 @@ export const State = {
|
|
10
10
|
} as const;
|
11
11
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
13
|
-
export type State = typeof State[keyof typeof State];
|
13
|
+
export type State = (typeof State)[keyof typeof State];
|
package/src/TouchEventType.ts
CHANGED
@@ -7,4 +7,5 @@ export const TouchEventType = {
|
|
7
7
|
} as const;
|
8
8
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
|
10
|
-
export type TouchEventType =
|
10
|
+
export type TouchEventType =
|
11
|
+
(typeof TouchEventType)[keyof typeof TouchEventType];
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
2
|
+
import { AccessibilityProps, StyleProp, ViewStyle } from 'react-native';
|
3
3
|
import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler';
|
4
4
|
|
5
|
-
export interface RawButtonProps
|
5
|
+
export interface RawButtonProps
|
6
|
+
extends NativeViewGestureHandlerProps,
|
7
|
+
AccessibilityProps {
|
6
8
|
/**
|
7
9
|
* Defines if more than one button could be pressed simultaneously. By default
|
8
10
|
* set true.
|
@@ -58,7 +58,7 @@ export default function Pressable(props: PressableProps) {
|
|
58
58
|
|
59
59
|
const normalizedHitSlop: Insets = useMemo(
|
60
60
|
() =>
|
61
|
-
typeof hitSlop === 'number' ? numberAsInset(hitSlop) : hitSlop ?? {},
|
61
|
+
typeof hitSlop === 'number' ? numberAsInset(hitSlop) : (hitSlop ?? {}),
|
62
62
|
[hitSlop]
|
63
63
|
);
|
64
64
|
|
@@ -66,7 +66,7 @@ export default function Pressable(props: PressableProps) {
|
|
66
66
|
() =>
|
67
67
|
typeof pressRetentionOffset === 'number'
|
68
68
|
? numberAsInset(pressRetentionOffset)
|
69
|
-
: pressRetentionOffset ?? {},
|
69
|
+
: (pressRetentionOffset ?? {}),
|
70
70
|
[pressRetentionOffset]
|
71
71
|
);
|
72
72
|
|
@@ -352,7 +352,7 @@ export default function Pressable(props: PressableProps) {
|
|
352
352
|
|
353
353
|
const isPressableEnabled = disabled !== true;
|
354
354
|
|
355
|
-
const gestures = [pressAndTouchGesture, hoverGesture
|
355
|
+
const gestures = [buttonGesture, pressAndTouchGesture, hoverGesture];
|
356
356
|
|
357
357
|
for (const gesture of gestures) {
|
358
358
|
gesture.enabled(isPressableEnabled);
|
@@ -280,8 +280,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
|
|
280
280
|
rowState.value === 1
|
281
281
|
? leftWidth.value
|
282
282
|
: rowState.value === -1
|
283
|
-
|
284
|
-
|
283
|
+
? -rightWidth.value
|
284
|
+
: 0;
|
285
285
|
|
286
286
|
const offsetDrag = userDrag.value / friction + startOffset;
|
287
287
|
|
@@ -387,8 +387,8 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
|
|
387
387
|
? rightWidth.value
|
388
388
|
: leftWidth.value
|
389
389
|
: moveToRight
|
390
|
-
|
391
|
-
|
390
|
+
? leftWidth.value
|
391
|
+
: rightWidth.value;
|
392
392
|
|
393
393
|
const progressSpringConfig = {
|
394
394
|
...translationSpringConfig,
|
@@ -614,10 +614,10 @@ const Swipeable = forwardRef<SwipeableMethods, SwipeableProps>(
|
|
614
614
|
rowState.value === -1
|
615
615
|
? SwipeDirection.RIGHT
|
616
616
|
: rowState.value === 1
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
617
|
+
? SwipeDirection.LEFT
|
618
|
+
: event.translationX > 0
|
619
|
+
? SwipeDirection.RIGHT
|
620
|
+
: SwipeDirection.LEFT;
|
621
621
|
|
622
622
|
if (!dragStarted.value) {
|
623
623
|
dragStarted.value = true;
|
@@ -362,10 +362,10 @@ export default class Swipeable extends Component<
|
|
362
362
|
rowState === -1
|
363
363
|
? 'right'
|
364
364
|
: rowState === 1
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
365
|
+
? 'left'
|
366
|
+
: translationX > 0
|
367
|
+
? 'left'
|
368
|
+
: 'right';
|
369
369
|
|
370
370
|
if (rowState === 0) {
|
371
371
|
this.props.onSwipeableOpenStartDrag?.(direction);
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import React, {
|
2
|
+
ForwardedRef,
|
3
|
+
forwardRef,
|
4
|
+
RefObject,
|
5
|
+
useEffect,
|
6
|
+
useRef,
|
7
|
+
} from 'react';
|
8
|
+
import {
|
9
|
+
Platform,
|
10
|
+
Text as RNText,
|
11
|
+
TextProps as RNTextProps,
|
12
|
+
} from 'react-native';
|
13
|
+
|
14
|
+
import { Gesture, GestureDetector } from '../';
|
15
|
+
|
16
|
+
export const Text = forwardRef(
|
17
|
+
(props: RNTextProps, ref: ForwardedRef<RNText>) => {
|
18
|
+
const { onPress, ...rest } = props;
|
19
|
+
const textRef = useRef<RNText | null>(null);
|
20
|
+
const native = Gesture.Native().runOnJS(true);
|
21
|
+
|
22
|
+
const refHandler = (node: any) => {
|
23
|
+
textRef.current = node;
|
24
|
+
|
25
|
+
if (ref === null) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
|
29
|
+
if (typeof ref === 'function') {
|
30
|
+
ref(node);
|
31
|
+
} else {
|
32
|
+
ref.current = node;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
useEffect(() => {
|
37
|
+
if (Platform.OS !== 'web') {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
|
41
|
+
const textElement = ref
|
42
|
+
? (ref as RefObject<RNText>).current
|
43
|
+
: textRef.current;
|
44
|
+
|
45
|
+
// At this point we are sure that textElement is div in HTML tree
|
46
|
+
(textElement as unknown as HTMLDivElement)?.setAttribute(
|
47
|
+
'rnghtext',
|
48
|
+
'true'
|
49
|
+
);
|
50
|
+
}, []);
|
51
|
+
|
52
|
+
return (
|
53
|
+
<GestureDetector gesture={native}>
|
54
|
+
<RNText onPress={onPress} ref={refHandler} {...rest} />
|
55
|
+
</GestureDetector>
|
56
|
+
);
|
57
|
+
}
|
58
|
+
);
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
60
|
+
export type Text = typeof Text & RNText;
|
@@ -26,7 +26,7 @@ export const TOUCHABLE_STATE = {
|
|
26
26
|
MOVED_OUTSIDE: 2,
|
27
27
|
} as const;
|
28
28
|
|
29
|
-
type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];
|
29
|
+
type TouchableState = (typeof TOUCHABLE_STATE)[keyof typeof TOUCHABLE_STATE];
|
30
30
|
|
31
31
|
interface InternalProps {
|
32
32
|
extraButtonProps: TouchableNativeFeedbackExtraProps;
|
@@ -11,10 +11,16 @@ export function getShadowNodeFromRef(ref: unknown) {
|
|
11
11
|
// Load findHostInstance_DEPRECATED lazily because it may not be available before render
|
12
12
|
if (findHostInstance_DEPRECATED === undefined) {
|
13
13
|
try {
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-assignment
|
15
|
+
const ReactFabric = require('react-native/Libraries/Renderer/shims/ReactFabric');
|
16
|
+
// Since RN 0.77 ReactFabric exports findHostInstance_DEPRECATED in default object so we're trying to
|
17
|
+
// access it first, then fallback on named export
|
14
18
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
15
19
|
findHostInstance_DEPRECATED =
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-
|
17
|
-
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
21
|
+
ReactFabric?.default?.findHostInstance_DEPRECATED ||
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
23
|
+
ReactFabric?.findHostInstance_DEPRECATED;
|
18
24
|
} catch (e) {
|
19
25
|
findHostInstance_DEPRECATED = (_ref: unknown) => null;
|
20
26
|
}
|
package/src/ghQueueMicrotask.ts
CHANGED
@@ -4,5 +4,5 @@ export const ghQueueMicrotask =
|
|
4
4
|
typeof setImmediate === 'function'
|
5
5
|
? setImmediate.bind(null)
|
6
6
|
: typeof requestAnimationFrame === 'function'
|
7
|
-
|
8
|
-
|
7
|
+
? requestAnimationFrame.bind(null)
|
8
|
+
: queueMicrotask.bind(null);
|
@@ -126,7 +126,7 @@ export type PanGestureHandlerEventPayload = {
|
|
126
126
|
/**
|
127
127
|
* Object containing additional stylus data.
|
128
128
|
*/
|
129
|
-
stylusData
|
129
|
+
stylusData?: StylusData;
|
130
130
|
};
|
131
131
|
|
132
132
|
export type PinchGestureHandlerEventPayload = {
|
@@ -222,5 +222,5 @@ export type HoverGestureHandlerEventPayload = {
|
|
222
222
|
/**
|
223
223
|
* Object containing additional stylus data.
|
224
224
|
*/
|
225
|
-
stylusData
|
225
|
+
stylusData?: StylusData;
|
226
226
|
};
|
@@ -24,6 +24,7 @@ import { ActionType } from '../ActionType';
|
|
24
24
|
import { PressabilityDebugView } from './PressabilityDebugView';
|
25
25
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
26
26
|
import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
27
|
+
import { MountRegistry } from '../mountRegistry';
|
27
28
|
|
28
29
|
const UIManagerAny = UIManager as any;
|
29
30
|
|
@@ -160,7 +161,7 @@ const UNRESOLVED_REFS_RETRY_LIMIT = 1;
|
|
160
161
|
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
161
162
|
export default function createHandler<
|
162
163
|
T extends BaseGestureHandlerProps<U>,
|
163
|
-
U extends Record<string, unknown
|
164
|
+
U extends Record<string, unknown>,
|
164
165
|
>({
|
165
166
|
name,
|
166
167
|
allowedProps = [],
|
@@ -234,6 +235,12 @@ export default function createHandler<
|
|
234
235
|
)
|
235
236
|
);
|
236
237
|
|
238
|
+
if (!this.viewNode) {
|
239
|
+
throw new Error(
|
240
|
+
`[Gesture Handler] Failed to obtain view for ${Handler.displayName}. Note that old API doesn't support functional components.`
|
241
|
+
);
|
242
|
+
}
|
243
|
+
|
237
244
|
this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null
|
238
245
|
}
|
239
246
|
|
@@ -256,6 +263,8 @@ export default function createHandler<
|
|
256
263
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
257
264
|
delete handlerIDToTag[handlerID];
|
258
265
|
}
|
266
|
+
|
267
|
+
MountRegistry.gestureHandlerWillUnmount(this);
|
259
268
|
}
|
260
269
|
|
261
270
|
private onGestureHandlerEvent = (event: GestureEvent<U>) => {
|
@@ -367,6 +376,10 @@ export default function createHandler<
|
|
367
376
|
}
|
368
377
|
|
369
378
|
scheduleFlushOperations();
|
379
|
+
|
380
|
+
ghQueueMicrotask(() => {
|
381
|
+
MountRegistry.gestureHandlerWillMount(this);
|
382
|
+
});
|
370
383
|
};
|
371
384
|
|
372
385
|
private updateGestureHandler = (
|
@@ -142,7 +142,7 @@ export interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {
|
|
142
142
|
nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;
|
143
143
|
}
|
144
144
|
export interface HandlerStateChangeEvent<
|
145
|
-
ExtraEventPayloadT = Record<string, unknown
|
145
|
+
ExtraEventPayloadT = Record<string, unknown>,
|
146
146
|
> {
|
147
147
|
nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;
|
148
148
|
}
|
@@ -169,7 +169,7 @@ export type GestureUpdateEvent<GestureEventPayloadT = Record<string, unknown>> =
|
|
169
169
|
GestureEventPayload & GestureEventPayloadT;
|
170
170
|
|
171
171
|
export type GestureStateChangeEvent<
|
172
|
-
GestureStateChangeEventPayloadT = Record<string, unknown
|
172
|
+
GestureStateChangeEventPayloadT = Record<string, unknown>,
|
173
173
|
> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;
|
174
174
|
|
175
175
|
export type CommonGestureConfig = {
|
@@ -186,7 +186,7 @@ export type CommonGestureConfig = {
|
|
186
186
|
// Events payloads are types instead of interfaces due to TS limitation.
|
187
187
|
// See https://github.com/microsoft/TypeScript/issues/15300 for more info.
|
188
188
|
export type BaseGestureHandlerProps<
|
189
|
-
ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown
|
189
|
+
ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>,
|
190
190
|
> = CommonGestureConfig & {
|
191
191
|
id?: string;
|
192
192
|
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
@@ -14,6 +14,7 @@ import {
|
|
14
14
|
checkGestureCallbacksForWorklets,
|
15
15
|
ALLOWED_PROPS,
|
16
16
|
} from './utils';
|
17
|
+
import { MountRegistry } from '../../../mountRegistry';
|
17
18
|
|
18
19
|
interface AttachHandlersConfig {
|
19
20
|
preparedGesture: AttachedGestureState;
|
@@ -93,6 +94,8 @@ export function attachHandlers({
|
|
93
94
|
actionType
|
94
95
|
);
|
95
96
|
}
|
97
|
+
|
98
|
+
MountRegistry.gestureWillMount(gesture);
|
96
99
|
}
|
97
100
|
|
98
101
|
preparedGesture.attachedGestures = gesturesToAttach;
|
@@ -2,12 +2,15 @@ import { unregisterHandler } from '../../handlersRegistry';
|
|
2
2
|
import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
|
3
3
|
import { scheduleFlushOperations } from '../../utils';
|
4
4
|
import { AttachedGestureState } from './types';
|
5
|
+
import { MountRegistry } from '../../../mountRegistry';
|
5
6
|
|
6
7
|
export function dropHandlers(preparedGesture: AttachedGestureState) {
|
7
8
|
for (const handler of preparedGesture.attachedGestures) {
|
8
9
|
RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
|
9
10
|
|
10
11
|
unregisterHandler(handler.handlerTag, handler.config.testId);
|
12
|
+
|
13
|
+
MountRegistry.gestureWillUnmount(handler);
|
11
14
|
}
|
12
15
|
|
13
16
|
scheduleFlushOperations();
|
@@ -23,6 +23,7 @@ import { useWebEventHandlers } from './utils';
|
|
23
23
|
import { Wrap, AnimatedWrap } from './Wrap';
|
24
24
|
import { useDetectorUpdater } from './useDetectorUpdater';
|
25
25
|
import { useViewRefHandler } from './useViewRefHandler';
|
26
|
+
import { useMountReactions } from './useMountReactions';
|
26
27
|
|
27
28
|
function propagateDetectorConfig(
|
28
29
|
props: GestureDetectorProps,
|
@@ -174,6 +175,8 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
174
175
|
}
|
175
176
|
}, [props]);
|
176
177
|
|
178
|
+
useMountReactions(updateAttachedGestures, preparedGesture);
|
179
|
+
|
177
180
|
if (shouldUseReanimated) {
|
178
181
|
return (
|
179
182
|
<AnimatedWrap
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { transformIntoHandlerTags } from '../../utils';
|
2
|
+
import { MountRegistry } from '../../../mountRegistry';
|
3
|
+
import { AttachedGestureState } from './types';
|
4
|
+
import { useEffect } from 'react';
|
5
|
+
import { GestureRef } from '../gesture';
|
6
|
+
|
7
|
+
function shouldUpdateDetector(
|
8
|
+
relation: GestureRef[] | undefined,
|
9
|
+
gesture: { handlerTag: number }
|
10
|
+
) {
|
11
|
+
if (relation === undefined) {
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
|
15
|
+
for (const tag of transformIntoHandlerTags(relation)) {
|
16
|
+
if (tag === gesture.handlerTag) {
|
17
|
+
return true;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
return false;
|
22
|
+
}
|
23
|
+
|
24
|
+
export function useMountReactions(
|
25
|
+
updateDetector: () => void,
|
26
|
+
state: AttachedGestureState
|
27
|
+
) {
|
28
|
+
useEffect(() => {
|
29
|
+
return MountRegistry.addMountListener((gesture) => {
|
30
|
+
// At this point the ref in the gesture config should be updated, so we can check if one of the gestures
|
31
|
+
// set in a relation with the gesture got mounted. If so, we need to update the detector to propagate
|
32
|
+
// the changes to the native side.
|
33
|
+
for (const attachedGesture of state.attachedGestures) {
|
34
|
+
const blocksHandlers = attachedGesture.config.blocksHandlers;
|
35
|
+
const requireToFail = attachedGesture.config.requireToFail;
|
36
|
+
const simultaneousWith = attachedGesture.config.simultaneousWith;
|
37
|
+
|
38
|
+
if (
|
39
|
+
shouldUpdateDetector(blocksHandlers, gesture) ||
|
40
|
+
shouldUpdateDetector(requireToFail, gesture) ||
|
41
|
+
shouldUpdateDetector(simultaneousWith, gesture)
|
42
|
+
) {
|
43
|
+
updateDetector();
|
44
|
+
|
45
|
+
// We can safely return here, if any other gestures should be updated, they will be by the above call
|
46
|
+
return;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
});
|
50
|
+
}, [updateDetector, state]);
|
51
|
+
}
|
@@ -101,7 +101,7 @@ export const CALLBACK_TYPE = {
|
|
101
101
|
|
102
102
|
// Allow using CALLBACK_TYPE as object and type
|
103
103
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
104
|
-
export type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];
|
104
|
+
export type CALLBACK_TYPE = (typeof CALLBACK_TYPE)[keyof typeof CALLBACK_TYPE];
|
105
105
|
|
106
106
|
export abstract class Gesture {
|
107
107
|
/**
|
@@ -125,7 +125,7 @@ export abstract class Gesture {
|
|
125
125
|
|
126
126
|
let nextGestureId = 0;
|
127
127
|
export abstract class BaseGesture<
|
128
|
-
EventPayloadT extends Record<string, unknown
|
128
|
+
EventPayloadT extends Record<string, unknown>,
|
129
129
|
> extends Gesture {
|
130
130
|
private gestureId = -1;
|
131
131
|
public handlerTag = -1;
|
@@ -433,7 +433,7 @@ export abstract class BaseGesture<
|
|
433
433
|
|
434
434
|
export abstract class ContinousBaseGesture<
|
435
435
|
EventPayloadT extends Record<string, unknown>,
|
436
|
-
EventChangePayloadT extends Record<string, unknown
|
436
|
+
EventChangePayloadT extends Record<string, unknown>,
|
437
437
|
> extends BaseGesture<EventPayloadT> {
|
438
438
|
/**
|
439
439
|
* Set the callback that is being called every time the gesture receives an update while it's active.
|
package/src/handlers/utils.ts
CHANGED
@@ -36,7 +36,8 @@ export function filterConfig(
|
|
36
36
|
}
|
37
37
|
return filteredConfig;
|
38
38
|
}
|
39
|
-
|
39
|
+
|
40
|
+
export function transformIntoHandlerTags(handlerIDs: any) {
|
40
41
|
handlerIDs = toArray(handlerIDs);
|
41
42
|
|
42
43
|
if (Platform.OS === 'web') {
|
package/src/index.ts
CHANGED