react-native-gesture-handler 2.3.1 → 2.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +2 -1
- package/android/build.gradle +38 -6
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
- package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
- package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
- package/ios/RNGHTouchEventType.h +9 -0
- package/ios/RNGestureHandler.h +2 -2
- package/ios/RNGestureHandler.m +21 -8
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +2 -2
- package/ios/RNGestureHandlerButton.h +1 -0
- package/ios/RNGestureHandlerButton.m +9 -1
- package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
- package/ios/RNGestureHandlerButtonManager.m +4 -1
- package/ios/RNGestureHandlerEvents.h +2 -2
- package/ios/RNGestureHandlerEvents.m +2 -2
- package/ios/RNGestureHandlerManager.h +2 -0
- package/ios/RNGestureHandlerManager.mm +30 -20
- package/ios/RNGestureHandlerModule.mm +18 -0
- package/ios/RNGestureHandlerPointerTracker.h +2 -2
- package/ios/RNGestureHandlerPointerTracker.m +9 -6
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/jest-utils/package.json +6 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +6 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
- package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +5 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
- package/lib/commonjs/TouchEventType.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +3 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +12 -9
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +7 -13
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +41 -21
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +11 -2
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/index.js +0 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +10 -1
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils/index.js +20 -0
- package/lib/commonjs/jestUtils/index.js.map +1 -0
- package/lib/commonjs/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -0
- package/lib/commonjs/mocks.js +2 -0
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/utils.js +23 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -1
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/module/GestureHandlerRootView.android.js +7 -2
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/GestureHandlerRootView.web.js +6 -0
- package/lib/module/GestureHandlerRootView.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +5 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +4 -1
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/{EventType.js → TouchEventType.js} +2 -2
- package/lib/module/TouchEventType.js.map +1 -0
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +2 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +4 -2
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +11 -8
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/handlers/createHandler.js +7 -16
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +11 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +41 -22
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +6 -7
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +10 -2
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +6 -1
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils/index.js +2 -0
- package/lib/module/jestUtils/index.js.map +1 -0
- package/lib/module/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
- package/lib/module/jestUtils/jestUtils.js.map +1 -0
- package/lib/module/mocks.js +2 -0
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/utils.js +17 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -1
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
- package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
- package/lib/typescript/components/GestureButtons.d.ts +18 -6
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -1
- package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
- package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +5 -3
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -3
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/jestUtils/index.d.ts +1 -0
- package/lib/typescript/{jestUtils.d.ts → jestUtils/jestUtils.d.ts} +18 -18
- package/lib/typescript/mocks.d.ts +1 -0
- package/lib/typescript/utils.d.ts +2 -0
- package/lib/typescript/web/GestureHandler.d.ts +1 -1
- package/package.json +5 -2
- package/src/GestureHandlerRootView.android.tsx +8 -2
- package/src/GestureHandlerRootView.tsx +6 -0
- package/src/GestureHandlerRootView.web.tsx +12 -0
- package/src/RNGestureHandlerModule.ts +7 -0
- package/src/RNGestureHandlerModule.web.ts +2 -0
- package/src/{EventType.ts → TouchEventType.ts} +2 -2
- package/src/components/GestureButtons.tsx +21 -7
- package/src/components/GestureHandlerButton.tsx +2 -2
- package/src/components/touchables/GenericTouchable.tsx +2 -0
- package/src/components/touchables/TouchableOpacity.tsx +6 -2
- package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
- package/src/getShadowNodeFromRef.ts +12 -9
- package/src/handlers/createHandler.ts +6 -16
- package/src/handlers/gestureHandlerCommon.ts +19 -2
- package/src/handlers/gestures/GestureDetector.tsx +64 -31
- package/src/handlers/gestures/eventReceiver.ts +6 -6
- package/src/handlers/gestures/gesture.ts +13 -2
- package/src/index.ts +0 -1
- package/src/init.ts +8 -1
- package/src/jestUtils/index.ts +1 -0
- package/src/{jestUtils.ts → jestUtils/jestUtils.ts} +21 -21
- package/src/mocks.ts +2 -0
- package/src/utils.ts +20 -0
- package/src/web/GestureHandler.ts +7 -1
- package/ios/RNTouchEventType.h +0 -9
- package/lib/commonjs/EventType.js.map +0 -1
- package/lib/commonjs/jestUtils.js.map +0 -1
- package/lib/module/EventType.js.map +0 -1
- package/lib/module/jestUtils.js.map +0 -1
- package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -1,22 +1,22 @@
|
|
1
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
2
|
-
import { FlingGestureHandler } from '
|
3
|
-
import { ForceTouchGestureHandler, ForceTouchGestureHandlerEventPayload } from '
|
4
|
-
import { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent } from '
|
5
|
-
import { FlingGesture } from '
|
6
|
-
import { ForceTouchGesture } from '
|
7
|
-
import { BaseGesture, GestureType } from '
|
8
|
-
import { LongPressGesture } from '
|
9
|
-
import { NativeGesture } from '
|
10
|
-
import { PanGesture } from '
|
11
|
-
import { PinchGesture } from '
|
12
|
-
import { RotationGesture } from '
|
13
|
-
import { TapGesture } from '
|
14
|
-
import { LongPressGestureHandler, LongPressGestureHandlerEventPayload } from '
|
15
|
-
import { NativeViewGestureHandler, NativeViewGestureHandlerPayload } from '
|
16
|
-
import { PanGestureHandler, PanGestureHandlerEventPayload } from '
|
17
|
-
import { PinchGestureHandler, PinchGestureHandlerEventPayload } from '
|
18
|
-
import { RotationGestureHandler, RotationGestureHandlerEventPayload } from '
|
19
|
-
import { TapGestureHandler, TapGestureHandlerEventPayload } from '
|
2
|
+
import { FlingGestureHandler } from '../handlers/FlingGestureHandler';
|
3
|
+
import { ForceTouchGestureHandler, ForceTouchGestureHandlerEventPayload } from '../handlers/ForceTouchGestureHandler';
|
4
|
+
import { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent } from '../handlers/gestureHandlerCommon';
|
5
|
+
import { FlingGesture } from '../handlers/gestures/flingGesture';
|
6
|
+
import { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture';
|
7
|
+
import { BaseGesture, GestureType } from '../handlers/gestures/gesture';
|
8
|
+
import { LongPressGesture } from '../handlers/gestures/longPressGesture';
|
9
|
+
import { NativeGesture } from '../handlers/gestures/nativeGesture';
|
10
|
+
import { PanGesture } from '../handlers/gestures/panGesture';
|
11
|
+
import { PinchGesture } from '../handlers/gestures/pinchGesture';
|
12
|
+
import { RotationGesture } from '../handlers/gestures/rotationGesture';
|
13
|
+
import { TapGesture } from '../handlers/gestures/tapGesture';
|
14
|
+
import { LongPressGestureHandler, LongPressGestureHandlerEventPayload } from '../handlers/LongPressGestureHandler';
|
15
|
+
import { NativeViewGestureHandler, NativeViewGestureHandlerPayload } from '../handlers/NativeViewGestureHandler';
|
16
|
+
import { PanGestureHandler, PanGestureHandlerEventPayload } from '../handlers/PanGestureHandler';
|
17
|
+
import { PinchGestureHandler, PinchGestureHandlerEventPayload } from '../handlers/PinchGestureHandler';
|
18
|
+
import { RotationGestureHandler, RotationGestureHandlerEventPayload } from '../handlers/RotationGestureHandler';
|
19
|
+
import { TapGestureHandler, TapGestureHandlerEventPayload } from '../handlers/TapGestureHandler';
|
20
20
|
declare type GestureHandlerTestEvent<TEventPayload extends Record<string, unknown> = Record<string, unknown>> = (GestureEvent<TEventPayload> | HandlerStateChangeEvent<TEventPayload>)['nativeEvent'];
|
21
21
|
declare type AllGestures = TapGesture | PanGesture | LongPressGesture | RotationGesture | PinchGesture | FlingGesture | ForceTouchGesture | NativeGesture;
|
22
22
|
declare type AllHandlers = TapGestureHandler | PanGestureHandler | LongPressGestureHandler | RotationGestureHandler | PinchGestureHandler | FlingGestureHandler | ForceTouchGestureHandler | NativeViewGestureHandler;
|
@@ -25,6 +25,7 @@ declare const _default: {
|
|
25
25
|
readonly createGestureHandler: () => void;
|
26
26
|
readonly dropGestureHandler: () => void;
|
27
27
|
readonly updateGestureHandler: () => void;
|
28
|
+
readonly flushOperations: () => void;
|
28
29
|
readonly Directions: {
|
29
30
|
readonly RIGHT: 1;
|
30
31
|
readonly LEFT: 2;
|
@@ -5,3 +5,5 @@ export declare function hasProperty(object: object, key: string): boolean;
|
|
5
5
|
export declare function isJestEnv(): boolean;
|
6
6
|
export declare function tagMessage(msg: string): string;
|
7
7
|
export declare function isFabric(): boolean;
|
8
|
+
export declare function shouldUseCodegenNativeComponent(): boolean;
|
9
|
+
export declare function isRemoteDebuggingEnabled(): boolean;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.1",
|
4
4
|
"description": "Experimental implementation of a new declarative API for gesture handling in react-native",
|
5
5
|
"scripts": {
|
6
6
|
"prepare": "bob build",
|
@@ -31,8 +31,11 @@
|
|
31
31
|
"android/lib/build.gradle",
|
32
32
|
"android/lib/src/main/java/",
|
33
33
|
"android/common/src/main/java/",
|
34
|
+
"android/reanimated/src/main/java/",
|
35
|
+
"android/noreanimated/src/main/java/",
|
34
36
|
"ios/",
|
35
37
|
"Swipeable/",
|
38
|
+
"jest-utils/",
|
36
39
|
"DrawerLayout/",
|
37
40
|
"README.md",
|
38
41
|
"jestSetup.js",
|
@@ -108,7 +111,7 @@
|
|
108
111
|
"react-native": "*"
|
109
112
|
},
|
110
113
|
"lint-staged": {
|
111
|
-
"
|
114
|
+
"./src/*.{ts,tsx}": [
|
112
115
|
"prettier --write"
|
113
116
|
]
|
114
117
|
},
|
@@ -2,9 +2,10 @@
|
|
2
2
|
import * as React from 'react';
|
3
3
|
import { PropsWithChildren } from 'react';
|
4
4
|
import { requireNativeComponent, ViewProps } from 'react-native';
|
5
|
-
import {
|
5
|
+
import { maybeInitializeFabric } from './init';
|
6
|
+
import { shouldUseCodegenNativeComponent } from './utils';
|
6
7
|
|
7
|
-
const GestureHandlerRootViewNativeComponent =
|
8
|
+
const GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()
|
8
9
|
? require('./fabric/RNGestureHandlerRootViewNativeComponent').default
|
9
10
|
: requireNativeComponent('RNGestureHandlerRootView');
|
10
11
|
|
@@ -14,5 +15,10 @@ export interface GestureHandlerRootViewProps
|
|
14
15
|
export default function GestureHandlerRootView(
|
15
16
|
props: GestureHandlerRootViewProps
|
16
17
|
) {
|
18
|
+
// try initialize fabric on the first render, at this point we can
|
19
|
+
// reliably check if fabric is enabled (the function contains a flag
|
20
|
+
// to make sure it's called only once)
|
21
|
+
maybeInitializeFabric();
|
22
|
+
|
17
23
|
return <GestureHandlerRootViewNativeComponent {...props} />;
|
18
24
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
3
|
import { View, ViewProps } from 'react-native';
|
4
|
+
import { maybeInitializeFabric } from './init';
|
4
5
|
|
5
6
|
export interface GestureHandlerRootViewProps
|
6
7
|
extends PropsWithChildren<ViewProps> {}
|
@@ -8,5 +9,10 @@ export interface GestureHandlerRootViewProps
|
|
8
9
|
export default function GestureHandlerRootView(
|
9
10
|
props: GestureHandlerRootViewProps
|
10
11
|
) {
|
12
|
+
// try initialize fabric on the first render, at this point we can
|
13
|
+
// reliably check if fabric is enabled (the function contains a flag
|
14
|
+
// to make sure it's called only once)
|
15
|
+
maybeInitializeFabric();
|
16
|
+
|
11
17
|
return <View {...props} />;
|
12
18
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
import { PropsWithChildren } from 'react';
|
3
|
+
import { View, ViewProps } from 'react-native';
|
4
|
+
|
5
|
+
export interface GestureHandlerRootViewProps
|
6
|
+
extends PropsWithChildren<ViewProps> {}
|
7
|
+
|
8
|
+
export default function GestureHandlerRootView(
|
9
|
+
props: GestureHandlerRootViewProps
|
10
|
+
) {
|
11
|
+
return <View {...props} />;
|
12
|
+
}
|
@@ -16,6 +16,12 @@ if (RNGestureHandlerModule == null) {
|
|
16
16
|
);
|
17
17
|
}
|
18
18
|
|
19
|
+
if (RNGestureHandlerModule.flushOperations === undefined) {
|
20
|
+
RNGestureHandlerModule.flushOperations = () => {
|
21
|
+
// NO-OP if not defined
|
22
|
+
};
|
23
|
+
}
|
24
|
+
|
19
25
|
export type RNGestureHandlerModuleProps = {
|
20
26
|
handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;
|
21
27
|
handleClearJSResponder: () => void;
|
@@ -35,6 +41,7 @@ export type RNGestureHandlerModuleProps = {
|
|
35
41
|
) => void;
|
36
42
|
dropGestureHandler: (handlerTag: number) => void;
|
37
43
|
install: () => void;
|
44
|
+
flushOperations: () => void;
|
38
45
|
};
|
39
46
|
|
40
47
|
export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export const
|
1
|
+
export const TouchEventType = {
|
2
2
|
UNDETERMINED: 0,
|
3
3
|
TOUCHES_DOWN: 1,
|
4
4
|
TOUCHES_MOVE: 2,
|
@@ -7,4 +7,4 @@ export const EventType = {
|
|
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
|
10
|
+
export type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];
|
@@ -35,6 +35,27 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
|
|
35
35
|
* Defines color of native ripple animation used since API level 21.
|
36
36
|
*/
|
37
37
|
rippleColor?: any; // it was present in BaseButtonProps before but is used here in code
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Android only.
|
41
|
+
*
|
42
|
+
* Defines radius of native ripple animation used since API level 21.
|
43
|
+
*/
|
44
|
+
rippleRadius?: number | null;
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Android only.
|
48
|
+
*
|
49
|
+
* Set this to true if you want the ripple animation to render outside the view bounds.
|
50
|
+
*/
|
51
|
+
borderless?: boolean;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Android only.
|
55
|
+
*
|
56
|
+
* Defines whether the ripple animation should be drawn on the foreground of the view.
|
57
|
+
*/
|
58
|
+
foreground?: boolean;
|
38
59
|
}
|
39
60
|
|
40
61
|
export interface BaseButtonProps extends RawButtonProps {
|
@@ -69,13 +90,6 @@ export interface RectButtonProps extends BaseButtonProps {
|
|
69
90
|
}
|
70
91
|
|
71
92
|
export interface BorderlessButtonProps extends BaseButtonProps {
|
72
|
-
/**
|
73
|
-
* Android only.
|
74
|
-
*
|
75
|
-
* Set this to false if you want the ripple animation to render only within view bounds.
|
76
|
-
*/
|
77
|
-
borderless?: boolean;
|
78
|
-
|
79
93
|
/**
|
80
94
|
* iOS only.
|
81
95
|
*
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
2
2
|
import { HostComponent, requireNativeComponent } from 'react-native';
|
3
3
|
import { RawButtonProps } from './GestureButtons';
|
4
|
-
import {
|
4
|
+
import { shouldUseCodegenNativeComponent } from '../utils';
|
5
5
|
|
6
|
-
const RNGestureHandlerButtonNativeComponent =
|
6
|
+
const RNGestureHandlerButtonNativeComponent = shouldUseCodegenNativeComponent()
|
7
7
|
? require('../fabric/RNGestureHandlerButtonNativeComponent').default
|
8
8
|
: requireNativeComponent('RNGestureHandlerButton');
|
9
9
|
|
@@ -258,6 +258,8 @@ export default class GenericTouchable extends Component<
|
|
258
258
|
// TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,
|
259
259
|
// would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016
|
260
260
|
accessibilityState: this.props.accessibilityState,
|
261
|
+
accessibilityActions: this.props.accessibilityActions,
|
262
|
+
onAccessibilityAction: this.props.onAccessibilityAction,
|
261
263
|
nativeID: this.props.nativeID,
|
262
264
|
onLayout: this.props.onLayout,
|
263
265
|
hitSlop: this.props.hitSlop,
|
@@ -12,11 +12,15 @@ import GenericTouchable, {
|
|
12
12
|
import * as React from 'react';
|
13
13
|
import { Component } from 'react';
|
14
14
|
|
15
|
+
interface GHTouchableOpacityProps {
|
16
|
+
useNativeAnimations?: boolean;
|
17
|
+
}
|
18
|
+
|
15
19
|
/**
|
16
20
|
* TouchableOpacity bases on timing animation which has been used in RN's core
|
17
21
|
*/
|
18
22
|
export default class TouchableOpacity extends Component<
|
19
|
-
TouchableOpacityProps & GenericTouchableProps
|
23
|
+
TouchableOpacityProps & GenericTouchableProps & GHTouchableOpacityProps
|
20
24
|
> {
|
21
25
|
static defaultProps = {
|
22
26
|
...GenericTouchable.defaultProps,
|
@@ -36,7 +40,7 @@ export default class TouchableOpacity extends Component<
|
|
36
40
|
toValue: value,
|
37
41
|
duration: duration,
|
38
42
|
easing: Easing.inOut(Easing.quad),
|
39
|
-
useNativeDriver:
|
43
|
+
useNativeDriver: this.props.useNativeAnimations ?? true,
|
40
44
|
}).start();
|
41
45
|
};
|
42
46
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
2
|
+
import codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
3
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
4
|
+
import type {
|
5
|
+
Int32,
|
6
|
+
WithDefault,
|
7
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
8
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
9
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
10
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
11
|
+
import type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
|
12
|
+
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
14
|
+
const codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(
|
15
|
+
name: string
|
16
|
+
) => HostComponent<T>;
|
17
|
+
|
18
|
+
interface NativeProps extends ViewProps {
|
19
|
+
exclusive?: WithDefault<boolean, true>;
|
20
|
+
foreground?: boolean;
|
21
|
+
borderless?: boolean;
|
22
|
+
enabled?: WithDefault<boolean, true>;
|
23
|
+
rippleColor?: ColorValue;
|
24
|
+
rippleRadius?: Int32;
|
25
|
+
}
|
26
|
+
|
27
|
+
export default codegenNativeComponent<NativeProps>('RNGestureHandlerButton');
|
@@ -0,0 +1,12 @@
|
|
1
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
2
|
+
import codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
3
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
4
|
+
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
6
|
+
const codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(
|
7
|
+
name: string
|
8
|
+
) => HostComponent<T>;
|
9
|
+
|
10
|
+
interface NativeProps extends ViewProps {}
|
11
|
+
|
12
|
+
export default codegenNativeComponent<NativeProps>('RNGestureHandlerRootView');
|
@@ -2,17 +2,20 @@
|
|
2
2
|
// attached view may get flattened on Fabric. This implementation causes errors
|
3
3
|
// on web due to the static resolution of `require` statements by webpack breaking
|
4
4
|
// the conditional importing. Solved by making .web file.
|
5
|
-
let findHostInstance_DEPRECATED
|
6
|
-
|
7
|
-
try {
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
9
|
-
findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')
|
10
|
-
.findHostInstance_DEPRECATED;
|
11
|
-
} catch (e) {
|
12
|
-
// do nothing
|
13
|
-
}
|
5
|
+
let findHostInstance_DEPRECATED: (ref: any) => void;
|
14
6
|
|
15
7
|
export function getShadowNodeFromRef(ref: any) {
|
8
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
9
|
+
if (findHostInstance_DEPRECATED === undefined) {
|
10
|
+
try {
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
12
|
+
findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')
|
13
|
+
.findHostInstance_DEPRECATED;
|
14
|
+
} catch (e) {
|
15
|
+
findHostInstance_DEPRECATED = (_ref: any) => null;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
16
19
|
// @ts-ignore Fabric
|
17
20
|
return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode
|
18
21
|
.node;
|
@@ -23,9 +23,10 @@ import {
|
|
23
23
|
GestureEvent,
|
24
24
|
HandlerStateChangeEvent,
|
25
25
|
findNodeHandle,
|
26
|
+
scheduleFlushOperations,
|
26
27
|
} from './gestureHandlerCommon';
|
27
28
|
import { ValueOf } from '../typeUtils';
|
28
|
-
import { isFabric, isJestEnv
|
29
|
+
import { isFabric, isJestEnv } from '../utils';
|
29
30
|
import { ActionType } from '../ActionType';
|
30
31
|
|
31
32
|
const UIManagerAny = UIManager as any;
|
@@ -147,18 +148,6 @@ type InternalEventHandlers = {
|
|
147
148
|
onGestureHandlerStateChange?: (event: any) => void;
|
148
149
|
};
|
149
150
|
|
150
|
-
let showedRngh2Notice = false;
|
151
|
-
function showRngh2NoticeIfNeeded() {
|
152
|
-
if (!showedRngh2Notice) {
|
153
|
-
console.warn(
|
154
|
-
tagMessage(
|
155
|
-
"Seems like you're using an old API with gesture components, check out new Gestures system!"
|
156
|
-
)
|
157
|
-
);
|
158
|
-
showedRngh2Notice = true;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
|
162
151
|
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
163
152
|
export default function createHandler<
|
164
153
|
T extends BaseGestureHandlerProps<U>,
|
@@ -199,9 +188,6 @@ export default function createHandler<
|
|
199
188
|
}
|
200
189
|
handlerIDToTag[props.id] = this.handlerTag;
|
201
190
|
}
|
202
|
-
if (__DEV__ && !isJestEnv()) {
|
203
|
-
showRngh2NoticeIfNeeded();
|
204
|
-
}
|
205
191
|
}
|
206
192
|
|
207
193
|
componentDidMount() {
|
@@ -251,6 +237,7 @@ export default function createHandler<
|
|
251
237
|
componentWillUnmount() {
|
252
238
|
this.inspectorToggleListener?.remove();
|
253
239
|
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
|
240
|
+
scheduleFlushOperations();
|
254
241
|
if (this.updateEnqueued) {
|
255
242
|
clearImmediate(this.updateEnqueued);
|
256
243
|
}
|
@@ -361,6 +348,8 @@ export default function createHandler<
|
|
361
348
|
actionType
|
362
349
|
);
|
363
350
|
}
|
351
|
+
|
352
|
+
scheduleFlushOperations();
|
364
353
|
};
|
365
354
|
|
366
355
|
private updateGestureHandler = (
|
@@ -369,6 +358,7 @@ export default function createHandler<
|
|
369
358
|
this.config = newConfig;
|
370
359
|
|
371
360
|
RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
|
361
|
+
scheduleFlushOperations();
|
372
362
|
};
|
373
363
|
|
374
364
|
private update() {
|
@@ -6,16 +6,18 @@ import * as React from 'react';
|
|
6
6
|
import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
|
7
7
|
|
8
8
|
import { State } from '../State';
|
9
|
-
import {
|
9
|
+
import { TouchEventType } from '../TouchEventType';
|
10
10
|
import { ValueOf } from '../typeUtils';
|
11
11
|
import { handlerIDToTag } from './handlersRegistry';
|
12
12
|
import { toArray } from '../utils';
|
13
|
+
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
13
14
|
|
14
15
|
const commonProps = [
|
15
16
|
'id',
|
16
17
|
'enabled',
|
17
18
|
'shouldCancelWhenOutside',
|
18
19
|
'hitSlop',
|
20
|
+
'cancelsTouchesInView',
|
19
21
|
] as const;
|
20
22
|
|
21
23
|
const componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;
|
@@ -83,7 +85,7 @@ export type GestureTouchEvent = {
|
|
83
85
|
handlerTag: number;
|
84
86
|
numberOfTouches: number;
|
85
87
|
state: ValueOf<typeof State>;
|
86
|
-
eventType:
|
88
|
+
eventType: TouchEventType;
|
87
89
|
allTouches: TouchData[];
|
88
90
|
changedTouches: TouchData[];
|
89
91
|
};
|
@@ -111,6 +113,7 @@ export type BaseGestureHandlerProps<
|
|
111
113
|
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
112
114
|
simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
|
113
115
|
testID?: string;
|
116
|
+
cancelsTouchesInView?: boolean;
|
114
117
|
// TODO(TS) - fix event types
|
115
118
|
onBegan?: (event: HandlerStateChangeEvent) => void;
|
116
119
|
onFailed?: (event: HandlerStateChangeEvent) => void;
|
@@ -180,3 +183,17 @@ export function findNodeHandle(
|
|
180
183
|
if (Platform.OS === 'web') return node;
|
181
184
|
return findNodeHandleRN(node);
|
182
185
|
}
|
186
|
+
|
187
|
+
let scheduledFlushOperationsId: ReturnType<
|
188
|
+
typeof requestAnimationFrame
|
189
|
+
> | null = null;
|
190
|
+
|
191
|
+
export function scheduleFlushOperations() {
|
192
|
+
if (scheduledFlushOperationsId === null) {
|
193
|
+
scheduledFlushOperationsId = requestAnimationFrame(() => {
|
194
|
+
RNGestureHandlerModule.flushOperations();
|
195
|
+
|
196
|
+
scheduledFlushOperationsId = null;
|
197
|
+
});
|
198
|
+
}
|
199
|
+
}
|