react-native-gesture-handler 2.28.0 → 2.30.0-20251030-c99169d35
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/README.md +1 -0
- package/android/build.gradle +2 -2
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +1 -0
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +8 -1
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +73 -41
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +5 -13
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +14 -6
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +6 -0
- package/apple/Handlers/RNFlingHandler.m +7 -1
- package/apple/Handlers/RNLongPressHandler.m +6 -4
- package/apple/Handlers/RNPanHandler.m +4 -1
- package/apple/Handlers/RNTapHandler.m +2 -1
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +15 -5
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/stateDefinitions.js +1 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js +12 -10
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +32 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +2 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +7 -7
- package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +9 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
- package/lib/commonjs/useIsomorphicLayoutEffect.js +20 -0
- package/lib/commonjs/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib/commonjs/web/handlers/{NativeViewGestureHandler.ts → NativeViewGestureHandler.js} +53 -87
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.js +57 -0
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +15 -5
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/stateDefinitions.js +1 -0
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +6 -4
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +27 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +3 -2
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/utils.js +7 -7
- package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +29 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js +5 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
- package/lib/module/useIsomorphicLayoutEffect.js +15 -0
- package/lib/module/useIsomorphicLayoutEffect.js.map +1 -0
- package/lib/module/web/handlers/{NativeViewGestureHandler.ts → NativeViewGestureHandler.js} +36 -76
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web_hammer/NativeViewGestureHandler.js +51 -0
- package/lib/module/web_hammer/NativeViewGestureHandler.js.map +1 -0
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +2 -2
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts.map +1 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +2 -2
- package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts +2 -1
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +4 -4
- package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts.map +1 -1
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +3 -2
- package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/useIsomorphicLayoutEffect.d.ts +3 -0
- package/lib/typescript/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/components/GestureHandlerRootView.android.tsx +3 -2
- package/src/components/GestureHandlerRootView.tsx +3 -2
- package/src/components/Pressable/Pressable.tsx +16 -5
- package/src/components/Pressable/stateDefinitions.ts +1 -0
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +17 -4
- package/src/handlers/gestures/GestureDetector/index.tsx +3 -8
- package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +4 -1
- package/src/handlers/gestures/GestureDetector/utils.ts +14 -8
- package/src/handlers/gestures/flingGesture.ts +1 -1
- package/src/handlers/gestures/gestureStateManager.ts +4 -0
- package/src/handlers/gestures/gestureStateManager.web.ts +2 -0
- package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
- package/src/useIsomorphicLayoutEffect.tsx +19 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.ts +0 -59
- package/lib/commonjs/handlers/gestures/nativeGesture.ts +0 -33
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.ts +0 -26
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.ts +0 -47
- package/lib/module/handlers/NativeViewGestureHandler.ts +0 -59
- package/lib/module/handlers/gestures/nativeGesture.ts +0 -33
- package/lib/module/specs/NativeRNGestureHandlerModule.ts +0 -26
- package/lib/module/web_hammer/NativeViewGestureHandler.ts +0 -47
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReanimatedSwipeable.d.ts","sourceRoot":"","sources":["../../../../src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ReanimatedSwipeable.d.ts","sourceRoot":"","sources":["../../../../src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EAEb,MAAM,OAAO,CAAC;AAaf,OAAO,EACL,cAAc,EACd,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AAqBpC,QAAA,MAAM,SAAS,GAAI,OAAO,cAAc,gCAwiBvC,CAAC;AAEF,eAAe,SAAS,CAAC;AACzB,MAAM,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/index.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAuCxD,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B;;;;;OAKG;IACH,OAAO,EAAE,eAAe,GAAG,WAAW,CAAC;IACvC;;;;OAIG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,oBAAoB,sBAgG1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnimatedGesture.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/useAnimatedGesture.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAgF/C,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"useAnimatedGesture.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/useAnimatedGesture.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAgF/C,wBAAgB,kBAAkB,CAChC,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,OAAO,QAgHtB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GestureType } from '../gesture';
|
|
1
|
+
import { GestureRef, GestureType } from '../gesture';
|
|
2
2
|
import { WebEventHandler } from './types';
|
|
3
3
|
export declare const ALLOWED_PROPS: string[];
|
|
4
4
|
export declare function extractGestureRelations(gesture: GestureType): {
|
|
5
|
-
waitFor:
|
|
6
|
-
simultaneousHandlers:
|
|
7
|
-
blocksHandlers:
|
|
5
|
+
waitFor: GestureRef[];
|
|
6
|
+
simultaneousHandlers: GestureRef[];
|
|
7
|
+
blocksHandlers: GestureRef[];
|
|
8
8
|
};
|
|
9
9
|
export declare function checkGestureCallbacksForWorklets(gesture: GestureType): void;
|
|
10
10
|
export declare function validateDetectorChildren(ref: any): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/utils.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/handlers/gestures/GestureDetector/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,WAAW,EAAE,MAAM,YAAY,CAAC;AAqBlE,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,aAAa,UAUzB,CAAC;AAsBF,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW;;;;EAgB3D;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,WAAW,QAsCpE;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,GAAG,QA+ChD;AAED,wBAAgB,cAAc,eAO7B;AAED,wBAAgB,mBAAmB,+CAWlC"}
|
|
@@ -12,7 +12,7 @@ export declare class FlingGesture extends BaseGesture<FlingGestureHandlerEventPa
|
|
|
12
12
|
/**
|
|
13
13
|
* Expressed allowed direction of movement.
|
|
14
14
|
* Expected values are exported as constants in the Directions object.
|
|
15
|
-
* Arguments can be combined using `|` operator. Default value is set to `
|
|
15
|
+
* Arguments can be combined using `|` operator. Default value is set to `Directions.RIGHT`.
|
|
16
16
|
* @param direction
|
|
17
17
|
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
|
|
18
18
|
*/
|
|
@@ -3,6 +3,8 @@ export interface GestureStateManagerType {
|
|
|
3
3
|
activate: () => void;
|
|
4
4
|
fail: () => void;
|
|
5
5
|
end: () => void;
|
|
6
|
+
/** @internal */
|
|
7
|
+
handlerTag: number;
|
|
6
8
|
}
|
|
7
9
|
declare function create(handlerTag: number): GestureStateManagerType;
|
|
8
10
|
export declare const GestureStateManager: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestureStateManager.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureStateManager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,GAAG,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"gestureStateManager.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureStateManager.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,GAAG,EAAE,MAAM,IAAI,CAAC;IAChB,gBAAgB;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAWD,iBAAS,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,CAiD3D;AAED,eAAO,MAAM,mBAAmB;;CAE/B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gestureStateManager.web.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureStateManager.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,eAAO,MAAM,mBAAmB;uBACX,MAAM,GAAG,uBAAuB;
|
|
1
|
+
{"version":3,"file":"gestureStateManager.web.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureStateManager.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,eAAO,MAAM,mBAAmB;uBACX,MAAM,GAAG,uBAAuB;CAqBpD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
|
-
interface
|
|
2
|
+
export interface RootViewNativeProps extends ViewProps {
|
|
3
|
+
unstable_forceActive?: boolean;
|
|
3
4
|
}
|
|
4
|
-
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<
|
|
5
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<RootViewNativeProps>;
|
|
5
6
|
export default _default;
|
|
6
7
|
//# sourceMappingURL=RNGestureHandlerRootViewNativeComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNGestureHandlerRootViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/specs/RNGestureHandlerRootViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,
|
|
1
|
+
{"version":3,"file":"RNGestureHandlerRootViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/specs/RNGestureHandlerRootViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,mBAAoB,SAAQ,SAAS;IACpD,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;;AAED,wBAEE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.d.ts","sourceRoot":"","sources":["../../src/useIsomorphicLayoutEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAiB1B,eAAO,MAAM,yBAAyB,wBAC4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gesture-handler",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0-20251030-c99169d35",
|
|
4
4
|
"description": "Declarative API exposing native platform touch and gesture system to React Native",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest",
|
|
@@ -79,12 +79,12 @@
|
|
|
79
79
|
"@babel/core": "^7.25.2",
|
|
80
80
|
"@babel/preset-env": "^7.25.3",
|
|
81
81
|
"@babel/preset-typescript": "^7.12.7",
|
|
82
|
-
"@react-native/babel-preset": "0.
|
|
82
|
+
"@react-native/babel-preset": "0.82.0",
|
|
83
83
|
"@testing-library/react-native": "^12.5.1",
|
|
84
84
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
85
85
|
"@types/invariant": "^2.2.37",
|
|
86
86
|
"@types/jest": "^27.0.3",
|
|
87
|
-
"@types/react": "^19.1.
|
|
87
|
+
"@types/react": "^19.1.1",
|
|
88
88
|
"@types/react-test-renderer": "^19.1.0",
|
|
89
89
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
90
90
|
"@typescript-eslint/parser": "^6.9.0",
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"lint-staged": "^12.3.2",
|
|
102
102
|
"madge": "^6.1.0",
|
|
103
103
|
"prettier": "3.3.3",
|
|
104
|
-
"react": "19.1.
|
|
105
|
-
"react-native": "0.
|
|
106
|
-
"react-native-builder-bob": "^0.
|
|
104
|
+
"react": "19.1.1",
|
|
105
|
+
"react-native": "0.82.0",
|
|
106
|
+
"react-native-builder-bob": "^0.40.13",
|
|
107
107
|
"react-native-reanimated": "^3.18.0",
|
|
108
|
-
"react-test-renderer": "19.1.
|
|
108
|
+
"react-test-renderer": "19.1.1",
|
|
109
109
|
"typescript": "~5.8.3"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
4
|
import { maybeInitializeFabric } from '../init';
|
|
5
5
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
|
6
|
+
import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent';
|
|
6
7
|
import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';
|
|
7
8
|
|
|
8
9
|
export interface GestureHandlerRootViewProps
|
|
9
|
-
extends PropsWithChildren<
|
|
10
|
+
extends PropsWithChildren<RootViewNativeProps> {}
|
|
10
11
|
|
|
11
12
|
export default function GestureHandlerRootView({
|
|
12
13
|
style,
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PropsWithChildren } from 'react';
|
|
3
|
-
import { View,
|
|
3
|
+
import { View, StyleSheet } from 'react-native';
|
|
4
4
|
import { maybeInitializeFabric } from '../init';
|
|
5
5
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
|
6
|
+
import type { RootViewNativeProps } from '../specs/RNGestureHandlerRootViewNativeComponent';
|
|
6
7
|
|
|
7
8
|
export interface GestureHandlerRootViewProps
|
|
8
|
-
extends PropsWithChildren<
|
|
9
|
+
extends PropsWithChildren<RootViewNativeProps> {}
|
|
9
10
|
|
|
10
11
|
export default function GestureHandlerRootView({
|
|
11
12
|
style,
|
|
@@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
|
|
|
270
270
|
stateMachine.reset();
|
|
271
271
|
handlePressOut(pressableEvent, false);
|
|
272
272
|
})
|
|
273
|
-
.onFinalize(() => {
|
|
273
|
+
.onFinalize((_event, success) => {
|
|
274
274
|
if (Platform.OS === 'web') {
|
|
275
|
-
|
|
275
|
+
if (success) {
|
|
276
|
+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
|
|
277
|
+
} else {
|
|
278
|
+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
|
|
279
|
+
}
|
|
276
280
|
handleFinalize();
|
|
277
281
|
}
|
|
278
282
|
}),
|
|
@@ -301,12 +305,19 @@ const Pressable = (props: PressableProps) => {
|
|
|
301
305
|
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
|
|
302
306
|
}
|
|
303
307
|
})
|
|
304
|
-
.onFinalize(() => {
|
|
308
|
+
.onFinalize((_event, success) => {
|
|
305
309
|
if (Platform.OS !== 'web') {
|
|
306
310
|
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
|
|
307
311
|
// as Native cancels on mouse move, and LongPress does not.
|
|
308
|
-
|
|
309
|
-
|
|
312
|
+
if (success) {
|
|
313
|
+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
|
|
314
|
+
} else {
|
|
315
|
+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (Platform.OS !== 'ios') {
|
|
319
|
+
handleFinalize();
|
|
320
|
+
}
|
|
310
321
|
}
|
|
311
322
|
}),
|
|
312
323
|
[stateMachine, handlePressOut, handleFinalize]
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useMemo,
|
|
3
|
+
useCallback,
|
|
4
|
+
useImperativeHandle,
|
|
5
|
+
ForwardedRef,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { LayoutChangeEvent, View, I18nManager, StyleSheet } from 'react-native';
|
|
3
9
|
import Animated, {
|
|
4
10
|
useSharedValue,
|
|
@@ -11,7 +17,11 @@ import Animated, {
|
|
|
11
17
|
runOnUI,
|
|
12
18
|
useAnimatedStyle,
|
|
13
19
|
} from 'react-native-reanimated';
|
|
14
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
SwipeableProps,
|
|
22
|
+
SwipeableMethods,
|
|
23
|
+
SwipeDirection,
|
|
24
|
+
} from './ReanimatedSwipeableProps';
|
|
15
25
|
import { Gesture } from '../..';
|
|
16
26
|
import {
|
|
17
27
|
GestureStateChangeEvent,
|
|
@@ -78,6 +88,7 @@ const Swipeable = (props: SwipeableProps) => {
|
|
|
78
88
|
]
|
|
79
89
|
);
|
|
80
90
|
|
|
91
|
+
const [shouldEnableTap, setShouldEnableTap] = useState(false);
|
|
81
92
|
const rowState = useSharedValue<number>(0);
|
|
82
93
|
|
|
83
94
|
const userDrag = useSharedValue<number>(0);
|
|
@@ -251,6 +262,8 @@ const Swipeable = (props: SwipeableProps) => {
|
|
|
251
262
|
dispatchImmediateEvents(frozenRowState, toValue);
|
|
252
263
|
|
|
253
264
|
rowState.value = Math.sign(toValue);
|
|
265
|
+
|
|
266
|
+
runOnJS(setShouldEnableTap)(rowState.value !== 0);
|
|
254
267
|
},
|
|
255
268
|
[
|
|
256
269
|
rowState,
|
|
@@ -468,6 +481,7 @@ const Swipeable = (props: SwipeableProps) => {
|
|
|
468
481
|
const tapGesture = useMemo(() => {
|
|
469
482
|
const tap = Gesture.Tap()
|
|
470
483
|
.shouldCancelWhenOutside(true)
|
|
484
|
+
.enabled(shouldEnableTap)
|
|
471
485
|
.onStart(() => {
|
|
472
486
|
if (rowState.value !== 0) {
|
|
473
487
|
close();
|
|
@@ -481,9 +495,8 @@ const Swipeable = (props: SwipeableProps) => {
|
|
|
481
495
|
relation as RelationPropType
|
|
482
496
|
);
|
|
483
497
|
});
|
|
484
|
-
|
|
485
498
|
return tap;
|
|
486
|
-
}, [close, relationProps, rowState]);
|
|
499
|
+
}, [close, relationProps, rowState, shouldEnableTap]);
|
|
487
500
|
|
|
488
501
|
const panGesture = useMemo(() => {
|
|
489
502
|
const pan = Gesture.Pan()
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/no-unused-prop-types */
|
|
2
|
-
import React, {
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useLayoutEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
} from 'react';
|
|
2
|
+
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
9
3
|
import { Platform } from 'react-native';
|
|
10
4
|
import findNodeHandle from '../../../findNodeHandle';
|
|
11
5
|
import { GestureType } from '../gesture';
|
|
@@ -24,6 +18,7 @@ import { Wrap, AnimatedWrap } from './Wrap';
|
|
|
24
18
|
import { useDetectorUpdater } from './useDetectorUpdater';
|
|
25
19
|
import { useViewRefHandler } from './useViewRefHandler';
|
|
26
20
|
import { useMountReactions } from './useMountReactions';
|
|
21
|
+
import { useIsomorphicLayoutEffect } from '../../../useIsomorphicLayoutEffect';
|
|
27
22
|
|
|
28
23
|
function propagateDetectorConfig(
|
|
29
24
|
props: GestureDetectorProps,
|
|
@@ -149,7 +144,7 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
|
149
144
|
|
|
150
145
|
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
|
|
151
146
|
|
|
152
|
-
|
|
147
|
+
useIsomorphicLayoutEffect(() => {
|
|
153
148
|
const viewTag = findNodeHandle(state.viewRef) as number;
|
|
154
149
|
preparedGesture.isMounted = true;
|
|
155
150
|
|
|
@@ -163,7 +163,10 @@ export function useAnimatedGesture(
|
|
|
163
163
|
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
|
|
164
164
|
}
|
|
165
165
|
} else if (isTouchEvent(event)) {
|
|
166
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
!stateControllers[i] ||
|
|
168
|
+
stateControllers[i].handlerTag !== event.handlerTag
|
|
169
|
+
) {
|
|
167
170
|
stateControllers[i] = GestureStateManager.create(event.handlerTag);
|
|
168
171
|
}
|
|
169
172
|
|
|
@@ -49,22 +49,28 @@ function convertToHandlerTag(ref: GestureRef): number {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {
|
|
52
|
-
return (
|
|
53
|
-
|
|
52
|
+
return Array.from(
|
|
53
|
+
new Set(
|
|
54
|
+
interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []
|
|
55
|
+
)
|
|
54
56
|
);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export function extractGestureRelations(gesture: GestureType) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
gesture.config.requireToFail = extractValidHandlerTags(
|
|
61
|
+
gesture.config.requireToFail
|
|
62
|
+
);
|
|
63
|
+
gesture.config.simultaneousWith = extractValidHandlerTags(
|
|
60
64
|
gesture.config.simultaneousWith
|
|
61
65
|
);
|
|
62
|
-
|
|
66
|
+
gesture.config.blocksHandlers = extractValidHandlerTags(
|
|
67
|
+
gesture.config.blocksHandlers
|
|
68
|
+
);
|
|
63
69
|
|
|
64
70
|
return {
|
|
65
|
-
waitFor: requireToFail,
|
|
66
|
-
simultaneousHandlers: simultaneousWith,
|
|
67
|
-
blocksHandlers: blocksHandlers,
|
|
71
|
+
waitFor: gesture.config.requireToFail,
|
|
72
|
+
simultaneousHandlers: gesture.config.simultaneousWith,
|
|
73
|
+
blocksHandlers: gesture.config.blocksHandlers,
|
|
68
74
|
};
|
|
69
75
|
}
|
|
70
76
|
|
|
@@ -23,7 +23,7 @@ export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
|
|
|
23
23
|
/**
|
|
24
24
|
* Expressed allowed direction of movement.
|
|
25
25
|
* Expected values are exported as constants in the Directions object.
|
|
26
|
-
* Arguments can be combined using `|` operator. Default value is set to `
|
|
26
|
+
* Arguments can be combined using `|` operator. Default value is set to `Directions.RIGHT`.
|
|
27
27
|
* @param direction
|
|
28
28
|
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
|
|
29
29
|
*/
|
|
@@ -7,6 +7,8 @@ export interface GestureStateManagerType {
|
|
|
7
7
|
activate: () => void;
|
|
8
8
|
fail: () => void;
|
|
9
9
|
end: () => void;
|
|
10
|
+
/** @internal */
|
|
11
|
+
handlerTag: number;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const warningMessage = tagMessage(
|
|
@@ -21,6 +23,8 @@ const setGestureState = Reanimated?.setGestureState;
|
|
|
21
23
|
function create(handlerTag: number): GestureStateManagerType {
|
|
22
24
|
'worklet';
|
|
23
25
|
return {
|
|
26
|
+
handlerTag,
|
|
27
|
+
|
|
24
28
|
begin: () => {
|
|
25
29
|
'worklet';
|
|
26
30
|
if (REANIMATED_AVAILABLE) {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
2
2
|
import type { ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
export interface RootViewNativeProps extends ViewProps {
|
|
5
|
+
unstable_forceActive?: boolean;
|
|
6
|
+
}
|
|
5
7
|
|
|
6
|
-
export default codegenNativeComponent<
|
|
8
|
+
export default codegenNativeComponent<RootViewNativeProps>(
|
|
9
|
+
'RNGestureHandlerRootView'
|
|
10
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
// code below is modified version of the code found in:
|
|
3
|
+
// https://github.com/reduxjs/react-redux/blob/7e2fdd4ee2021e4282e12ba9fc722f09124e30cd/src/utils/useIsomorphicLayoutEffect.ts#L36
|
|
4
|
+
// React currently throws a warning when using useLayoutEffect on the server.
|
|
5
|
+
// To get around it, we can conditionally useEffect on the server (no-op) and
|
|
6
|
+
|
|
7
|
+
// useLayoutEffect in the browser.
|
|
8
|
+
const isDOM = !!(
|
|
9
|
+
typeof window !== 'undefined' &&
|
|
10
|
+
typeof window.document !== 'undefined' &&
|
|
11
|
+
typeof window.document.createElement !== 'undefined'
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// Under React Native, we know that we always want to use useLayoutEffect
|
|
15
|
+
const isReactNative =
|
|
16
|
+
typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
|
|
17
|
+
|
|
18
|
+
export const useIsomorphicLayoutEffect =
|
|
19
|
+
isDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload';
|
|
2
|
-
import createHandler from './createHandler';
|
|
3
|
-
import {
|
|
4
|
-
BaseGestureHandlerProps,
|
|
5
|
-
baseGestureHandlerProps,
|
|
6
|
-
} from './gestureHandlerCommon';
|
|
7
|
-
|
|
8
|
-
export const nativeViewGestureHandlerProps = [
|
|
9
|
-
'shouldActivateOnStart',
|
|
10
|
-
'disallowInterruption',
|
|
11
|
-
] as const;
|
|
12
|
-
|
|
13
|
-
export interface NativeViewGestureConfig {
|
|
14
|
-
/**
|
|
15
|
-
* Android only.
|
|
16
|
-
*
|
|
17
|
-
* Determines whether the handler should check for an existing touch event on
|
|
18
|
-
* instantiation.
|
|
19
|
-
*/
|
|
20
|
-
shouldActivateOnStart?: boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* When `true`, cancels all other gesture handlers when this
|
|
24
|
-
* `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
*/
|
|
26
|
-
disallowInterruption?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
31
|
-
*/
|
|
32
|
-
export interface NativeViewGestureHandlerProps
|
|
33
|
-
extends BaseGestureHandlerProps<NativeViewGestureHandlerPayload>,
|
|
34
|
-
NativeViewGestureConfig {}
|
|
35
|
-
|
|
36
|
-
export const nativeViewProps = [
|
|
37
|
-
...baseGestureHandlerProps,
|
|
38
|
-
...nativeViewGestureHandlerProps,
|
|
39
|
-
] as const;
|
|
40
|
-
|
|
41
|
-
export const nativeViewHandlerName = 'NativeViewGestureHandler';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
45
|
-
*/
|
|
46
|
-
export type NativeViewGestureHandler = typeof NativeViewGestureHandler;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
|
52
|
-
export const NativeViewGestureHandler = createHandler<
|
|
53
|
-
NativeViewGestureHandlerProps,
|
|
54
|
-
NativeViewGestureHandlerPayload
|
|
55
|
-
>({
|
|
56
|
-
name: nativeViewHandlerName,
|
|
57
|
-
allowedProps: nativeViewProps,
|
|
58
|
-
config: {},
|
|
59
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseGestureConfig, BaseGesture } from './gesture';
|
|
2
|
-
import { NativeViewGestureConfig } from '../NativeViewGestureHandler';
|
|
3
|
-
import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload';
|
|
4
|
-
|
|
5
|
-
export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {
|
|
6
|
-
public config: BaseGestureConfig & NativeViewGestureConfig = {};
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
this.handlerName = 'NativeViewGestureHandler';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
|
|
16
|
-
* @param value
|
|
17
|
-
*/
|
|
18
|
-
shouldActivateOnStart(value: boolean) {
|
|
19
|
-
this.config.shouldActivateOnStart = value;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
* @param value
|
|
26
|
-
*/
|
|
27
|
-
disallowInterruption(value: boolean) {
|
|
28
|
-
this.config.disallowInterruption = value;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type NativeGestureType = InstanceType<typeof NativeGesture>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TurboModuleRegistry, TurboModule } from 'react-native';
|
|
2
|
-
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
handleSetJSResponder: (tag: Double, blockNativeResponder: boolean) => void;
|
|
6
|
-
handleClearJSResponder: () => void;
|
|
7
|
-
createGestureHandler: (
|
|
8
|
-
handlerName: string,
|
|
9
|
-
handlerTag: Double,
|
|
10
|
-
// Record<> is not supported by codegen
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
12
|
-
config: Object
|
|
13
|
-
) => void;
|
|
14
|
-
attachGestureHandler: (
|
|
15
|
-
handlerTag: Double,
|
|
16
|
-
newView: Double,
|
|
17
|
-
actionType: Double
|
|
18
|
-
) => void;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
-
updateGestureHandler: (handlerTag: Double, newConfig: Object) => void;
|
|
21
|
-
dropGestureHandler: (handlerTag: Double) => void;
|
|
22
|
-
install: () => boolean;
|
|
23
|
-
flushOperations: () => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default TurboModuleRegistry.getEnforcing<Spec>('RNGestureHandlerModule');
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import DiscreteGestureHandler from './DiscreteGestureHandler';
|
|
2
|
-
import { HammerInputExt } from './GestureHandler';
|
|
3
|
-
import * as NodeManager from './NodeManager';
|
|
4
|
-
import PressGestureHandler from './PressGestureHandler';
|
|
5
|
-
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
|
6
|
-
|
|
7
|
-
class NativeViewGestureHandler extends PressGestureHandler {
|
|
8
|
-
get isNative() {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onRawEvent(ev: HammerInputExt) {
|
|
13
|
-
super.onRawEvent(ev);
|
|
14
|
-
if (!ev.isFinal) {
|
|
15
|
-
// if (this.ref instanceof ScrollView) {
|
|
16
|
-
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
|
|
17
|
-
// @ts-ignore FIXME(TS) config type
|
|
18
|
-
if (this.config.disallowInterruption) {
|
|
19
|
-
const gestures = Object.values(NodeManager.getNodes()).filter(
|
|
20
|
-
(gesture) => {
|
|
21
|
-
const { handlerTag, view, isGestureRunning } = gesture;
|
|
22
|
-
return (
|
|
23
|
-
// Check if this gesture isn't self
|
|
24
|
-
handlerTag !== this.handlerTag &&
|
|
25
|
-
// Ensure the gesture needs to be cancelled
|
|
26
|
-
isGestureRunning &&
|
|
27
|
-
// ScrollView can cancel discrete gestures like taps and presses
|
|
28
|
-
gesture instanceof DiscreteGestureHandler &&
|
|
29
|
-
// Ensure a view exists and is a child of the current view
|
|
30
|
-
view &&
|
|
31
|
-
// @ts-ignore FIXME(TS) view type
|
|
32
|
-
this.view.contains(view)
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
// Cancel all of the gestures that passed the filter
|
|
37
|
-
for (const gesture of gestures) {
|
|
38
|
-
// TODO: Bacon: Send some cached event.
|
|
39
|
-
gesture.forceInvalidate(ev);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default NativeViewGestureHandler;
|