react-native-gesture-handler 2.3.2 → 2.4.2
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/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/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/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/DrawerLayout.js +38 -11
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- 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/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/ForceTouchGestureHandler.js +2 -1
- package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +25 -20
- 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 +120 -80
- 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 +24 -4
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/init.js +10 -1
- package/lib/commonjs/init.js.map +1 -1
- 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/commonjs/web/utils.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/DrawerLayout.js +38 -11
- package/lib/module/components/DrawerLayout.js.map +1 -1
- 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/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/ForceTouchGestureHandler.js +1 -1
- package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
- package/lib/module/handlers/createHandler.js +25 -22
- 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 +120 -81
- 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 +23 -4
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/init.js +6 -1
- package/lib/module/init.js.map +1 -1
- 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/module/web/utils.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/DrawerLayout.d.ts +3 -0
- package/lib/typescript/components/GestureButtons.d.ts +18 -6
- package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
- package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +6 -3
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -4
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
- package/lib/typescript/init.d.ts +1 -0
- 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 +4 -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/DrawerLayout.tsx +34 -10
- package/src/components/GestureButtons.tsx +21 -7
- package/src/components/GestureHandlerButton.tsx +2 -2
- package/src/components/touchables/GenericTouchable.tsx +2 -0
- package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
- package/src/getShadowNodeFromRef.ts +12 -9
- package/src/handlers/ForceTouchGestureHandler.ts +3 -2
- package/src/handlers/createHandler.ts +30 -26
- package/src/handlers/gestureHandlerCommon.ts +21 -2
- package/src/handlers/gestures/GestureDetector.tsx +164 -105
- package/src/handlers/gestures/eventReceiver.ts +6 -6
- package/src/handlers/gestures/gesture.ts +29 -2
- package/src/init.ts +8 -1
- package/src/mocks.ts +2 -0
- package/src/utils.ts +20 -0
- package/src/web/GestureHandler.ts +7 -1
- package/src/web/utils.ts +1 -1
- package/ios/RNTouchEventType.h +0 -9
- package/lib/commonjs/EventType.js.map +0 -1
- package/lib/module/EventType.js.map +0 -1
- package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { State } from '../State';
|
|
3
|
-
import {
|
|
3
|
+
import { TouchEventType } from '../TouchEventType';
|
|
4
4
|
import { ValueOf } from '../typeUtils';
|
|
5
|
-
export declare const baseGestureHandlerProps: readonly ["id", "enabled", "shouldCancelWhenOutside", "hitSlop", "waitFor", "simultaneousHandlers", "onBegan", "onFailed", "onCancelled", "onActivated", "onEnded", "onGestureEvent", "onHandlerStateChange"];
|
|
5
|
+
export declare const baseGestureHandlerProps: readonly ["id", "enabled", "shouldCancelWhenOutside", "hitSlop", "cancelsTouchesInView", "waitFor", "simultaneousHandlers", "onBegan", "onFailed", "onCancelled", "onActivated", "onEnded", "onGestureEvent", "onHandlerStateChange"];
|
|
6
6
|
export declare const baseGestureHandlerWithMonitorProps: string[];
|
|
7
7
|
export interface GestureEventPayload {
|
|
8
8
|
handlerTag: number;
|
|
@@ -30,7 +30,7 @@ export declare type GestureTouchEvent = {
|
|
|
30
30
|
handlerTag: number;
|
|
31
31
|
numberOfTouches: number;
|
|
32
32
|
state: ValueOf<typeof State>;
|
|
33
|
-
eventType:
|
|
33
|
+
eventType: TouchEventType;
|
|
34
34
|
allTouches: TouchData[];
|
|
35
35
|
changedTouches: TouchData[];
|
|
36
36
|
};
|
|
@@ -46,6 +46,7 @@ export declare type BaseGestureHandlerProps<ExtraEventPayloadT extends Record<st
|
|
|
46
46
|
waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
|
|
47
47
|
simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
|
|
48
48
|
testID?: string;
|
|
49
|
+
cancelsTouchesInView?: boolean;
|
|
49
50
|
onBegan?: (event: HandlerStateChangeEvent) => void;
|
|
50
51
|
onFailed?: (event: HandlerStateChangeEvent) => void;
|
|
51
52
|
onCancelled?: (event: HandlerStateChangeEvent) => void;
|
|
@@ -53,8 +54,10 @@ export declare type BaseGestureHandlerProps<ExtraEventPayloadT extends Record<st
|
|
|
53
54
|
onEnded?: (event: HandlerStateChangeEvent) => void;
|
|
54
55
|
onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;
|
|
55
56
|
onHandlerStateChange?: (event: HandlerStateChangeEvent<ExtraEventPayloadT>) => void;
|
|
57
|
+
children?: React.ReactNode;
|
|
56
58
|
};
|
|
57
59
|
export declare function filterConfig(props: Record<string, unknown>, validProps: string[], defaults?: Record<string, unknown>): {
|
|
58
60
|
[x: string]: unknown;
|
|
59
61
|
};
|
|
60
62
|
export declare function findNodeHandle(node: null | number | React.Component<any, any> | React.ComponentClass<any>): null | number | React.Component<any, any> | React.ComponentClass<any>;
|
|
63
|
+
export declare function scheduleFlushOperations(): void;
|
|
@@ -2,9 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { GestureType, HandlerCallbacks } from './gesture';
|
|
3
3
|
import { SharedValue } from './reanimatedWrapper';
|
|
4
4
|
import { ComposedGesture } from './gestureComposition';
|
|
5
|
-
declare global {
|
|
6
|
-
function isFormsStackingContext(node: unknown): boolean | null;
|
|
7
|
-
}
|
|
8
5
|
export declare type GestureConfigReference = {
|
|
9
6
|
config: GestureType[];
|
|
10
7
|
animatedEventHandler: unknown;
|
|
@@ -14,6 +11,7 @@ export declare type GestureConfigReference = {
|
|
|
14
11
|
};
|
|
15
12
|
interface GestureDetectorProps {
|
|
16
13
|
gesture?: ComposedGesture | GestureType;
|
|
14
|
+
children?: React.ReactNode;
|
|
17
15
|
}
|
|
18
|
-
export declare const GestureDetector:
|
|
16
|
+
export declare const GestureDetector: (props: GestureDetectorProps) => JSX.Element;
|
|
19
17
|
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import { GestureTouchEvent, GestureUpdateEvent, GestureStateChangeEvent } from '../gestureHandlerCommon';
|
|
2
|
+
export declare function onGestureHandlerEvent(event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent): void;
|
|
1
3
|
export declare function startListening(): void;
|
|
2
4
|
export declare function stopListening(): void;
|
|
@@ -18,9 +18,11 @@ export interface BaseGestureConfig extends CommonGestureConfig, Record<string, u
|
|
|
18
18
|
manualActivation?: boolean;
|
|
19
19
|
runOnJS?: boolean;
|
|
20
20
|
testId?: string;
|
|
21
|
+
cancelsTouchesInView?: boolean;
|
|
21
22
|
}
|
|
22
23
|
declare type TouchEventHandlerType = (event: GestureTouchEvent, stateManager: GestureStateManagerType) => void;
|
|
23
24
|
export declare type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {
|
|
25
|
+
gestureId: number;
|
|
24
26
|
handlerTag: number;
|
|
25
27
|
onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;
|
|
26
28
|
onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;
|
|
@@ -67,10 +69,12 @@ export declare abstract class Gesture {
|
|
|
67
69
|
abstract prepare(): void;
|
|
68
70
|
}
|
|
69
71
|
export declare abstract class BaseGesture<EventPayloadT extends Record<string, unknown>> extends Gesture {
|
|
72
|
+
private gestureId;
|
|
70
73
|
handlerTag: number;
|
|
71
74
|
handlerName: string;
|
|
72
75
|
config: BaseGestureConfig;
|
|
73
76
|
handlers: HandlerCallbacks<EventPayloadT>;
|
|
77
|
+
constructor();
|
|
74
78
|
private addDependency;
|
|
75
79
|
withRef(ref: React.MutableRefObject<GestureType | undefined>): this;
|
|
76
80
|
protected isWorklet(callback: Function): boolean;
|
|
@@ -89,6 +93,7 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
|
|
|
89
93
|
simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]): this;
|
|
90
94
|
requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]): this;
|
|
91
95
|
withTestId(id: string): this;
|
|
96
|
+
cancelsTouchesInView(value: boolean): this;
|
|
92
97
|
initialize(): void;
|
|
93
98
|
toGestureArray(): GestureType[];
|
|
94
99
|
prepare(): void;
|
package/lib/typescript/init.d.ts
CHANGED
|
@@ -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.2",
|
|
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,6 +31,8 @@
|
|
|
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/",
|
|
36
38
|
"jest-utils/",
|
|
@@ -109,7 +111,7 @@
|
|
|
109
111
|
"react-native": "*"
|
|
110
112
|
},
|
|
111
113
|
"lint-staged": {
|
|
112
|
-
"
|
|
114
|
+
"./src/*.{ts,tsx}": [
|
|
113
115
|
"prettier --write"
|
|
114
116
|
]
|
|
115
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];
|
|
@@ -148,6 +148,11 @@ export interface DrawerLayoutProps {
|
|
|
148
148
|
onDrawerSlide?: (position: number) => void;
|
|
149
149
|
|
|
150
150
|
onGestureRef?: (ref: PanGestureHandler) => void;
|
|
151
|
+
|
|
152
|
+
// implicit `children` prop has been removed in @types/react^18.0.0
|
|
153
|
+
children?:
|
|
154
|
+
| React.ReactNode
|
|
155
|
+
| ((openValue?: Animated.AnimatedInterpolation) => React.ReactNode);
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
export type DrawerLayoutState = {
|
|
@@ -155,6 +160,8 @@ export type DrawerLayoutState = {
|
|
|
155
160
|
touchX: Animated.Value;
|
|
156
161
|
drawerTranslation: Animated.Value;
|
|
157
162
|
containerWidth: number;
|
|
163
|
+
drawerState: DrawerState;
|
|
164
|
+
drawerOpened: boolean;
|
|
158
165
|
};
|
|
159
166
|
|
|
160
167
|
export type DrawerMovementOption = {
|
|
@@ -189,6 +196,8 @@ export default class DrawerLayout extends Component<
|
|
|
189
196
|
touchX,
|
|
190
197
|
drawerTranslation,
|
|
191
198
|
containerWidth: 0,
|
|
199
|
+
drawerState: IDLE,
|
|
200
|
+
drawerOpened: false,
|
|
192
201
|
};
|
|
193
202
|
|
|
194
203
|
this.updateAnimatedEvent(props, this.state);
|
|
@@ -349,6 +358,7 @@ export default class DrawerLayout extends Component<
|
|
|
349
358
|
this.handleRelease({ nativeEvent });
|
|
350
359
|
} else if (nativeEvent.state === State.ACTIVE) {
|
|
351
360
|
this.emitStateChanged(DRAGGING, false);
|
|
361
|
+
this.setState({ drawerState: DRAGGING });
|
|
352
362
|
if (this.props.keyboardDismissMode === 'on-drag') {
|
|
353
363
|
Keyboard.dismiss();
|
|
354
364
|
}
|
|
@@ -464,6 +474,7 @@ export default class DrawerLayout extends Component<
|
|
|
464
474
|
const willShow = toValue !== 0;
|
|
465
475
|
this.updateShowing(willShow);
|
|
466
476
|
this.emitStateChanged(SETTLING, willShow);
|
|
477
|
+
this.setState({ drawerState: SETTLING });
|
|
467
478
|
if (this.props.hideStatusBar) {
|
|
468
479
|
StatusBar.setHidden(willShow, this.props.statusBarAnimation || 'slide');
|
|
469
480
|
}
|
|
@@ -476,6 +487,12 @@ export default class DrawerLayout extends Component<
|
|
|
476
487
|
}).start(({ finished }) => {
|
|
477
488
|
if (finished) {
|
|
478
489
|
this.emitStateChanged(IDLE, willShow);
|
|
490
|
+
this.setState({ drawerOpened: willShow });
|
|
491
|
+
if (this.state.drawerState !== DRAGGING) {
|
|
492
|
+
// it's possilbe that user started drag while the drawer
|
|
493
|
+
// was settling, don't override state in this case
|
|
494
|
+
this.setState({ drawerState: IDLE });
|
|
495
|
+
}
|
|
479
496
|
if (willShow) {
|
|
480
497
|
this.props.onDrawerOpen?.();
|
|
481
498
|
} else {
|
|
@@ -516,11 +533,14 @@ export default class DrawerLayout extends Component<
|
|
|
516
533
|
private renderOverlay = () => {
|
|
517
534
|
/* Overlay styles */
|
|
518
535
|
invariant(this.openValue, 'should be set');
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
}
|
|
536
|
+
let overlayOpacity;
|
|
537
|
+
|
|
538
|
+
if (this.state.drawerState !== IDLE) {
|
|
539
|
+
overlayOpacity = this.openValue;
|
|
540
|
+
} else {
|
|
541
|
+
overlayOpacity = this.state.drawerOpened ? 1 : 0;
|
|
542
|
+
}
|
|
543
|
+
|
|
524
544
|
const dynamicOverlayStyles = {
|
|
525
545
|
opacity: overlayOpacity,
|
|
526
546
|
backgroundColor: this.props.overlayColor,
|
|
@@ -579,11 +599,15 @@ export default class DrawerLayout extends Component<
|
|
|
579
599
|
let drawerTranslateX: number | Animated.AnimatedInterpolation = 0;
|
|
580
600
|
if (drawerSlide) {
|
|
581
601
|
const closedDrawerOffset = fromLeft ? -drawerWidth! : drawerWidth!;
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
602
|
+
if (this.state.drawerState !== IDLE) {
|
|
603
|
+
drawerTranslateX = openValue.interpolate({
|
|
604
|
+
inputRange: [0, 1],
|
|
605
|
+
outputRange: [closedDrawerOffset, 0],
|
|
606
|
+
extrapolate: 'clamp',
|
|
607
|
+
});
|
|
608
|
+
} else {
|
|
609
|
+
drawerTranslateX = this.state.drawerOpened ? 0 : closedDrawerOffset;
|
|
610
|
+
}
|
|
587
611
|
}
|
|
588
612
|
const drawerStyles: {
|
|
589
613
|
transform: { translateX: number | Animated.AnimatedInterpolation }[];
|
|
@@ -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,
|
|
@@ -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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
2
|
import { tagMessage } from '../utils';
|
|
3
3
|
import PlatformConstants from '../PlatformConstants';
|
|
4
4
|
import createHandler from './createHandler';
|
|
@@ -13,7 +13,8 @@ export const forceTouchGestureHandlerProps = [
|
|
|
13
13
|
'feedbackOnActivation',
|
|
14
14
|
] as const;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// implicit `children` prop has been removed in @types/react^18.0.0
|
|
17
|
+
class ForceTouchFallback extends React.Component<PropsWithChildren<unknown>> {
|
|
17
18
|
static forceTouchAvailable = false;
|
|
18
19
|
componentDidMount() {
|
|
19
20
|
console.warn(
|
|
@@ -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,17 +148,7 @@ type InternalEventHandlers = {
|
|
|
147
148
|
onGestureHandlerStateChange?: (event: any) => void;
|
|
148
149
|
};
|
|
149
150
|
|
|
150
|
-
|
|
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
|
-
}
|
|
151
|
+
const UNRESOLVED_REFS_RETRY_LIMIT = 1;
|
|
161
152
|
|
|
162
153
|
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
|
163
154
|
export default function createHandler<
|
|
@@ -199,9 +190,6 @@ export default function createHandler<
|
|
|
199
190
|
}
|
|
200
191
|
handlerIDToTag[props.id] = this.handlerTag;
|
|
201
192
|
}
|
|
202
|
-
if (__DEV__ && !isJestEnv()) {
|
|
203
|
-
showRngh2NoticeIfNeeded();
|
|
204
|
-
}
|
|
205
193
|
}
|
|
206
194
|
|
|
207
195
|
componentDidMount() {
|
|
@@ -212,7 +200,7 @@ export default function createHandler<
|
|
|
212
200
|
'toggleElementInspector',
|
|
213
201
|
() => {
|
|
214
202
|
this.setState((_) => ({ allowTouches }));
|
|
215
|
-
this.update();
|
|
203
|
+
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
|
|
216
204
|
}
|
|
217
205
|
);
|
|
218
206
|
}
|
|
@@ -225,7 +213,7 @@ export default function createHandler<
|
|
|
225
213
|
// be resolved by then.
|
|
226
214
|
this.updateEnqueued = setImmediate(() => {
|
|
227
215
|
this.updateEnqueued = null;
|
|
228
|
-
this.update();
|
|
216
|
+
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
|
|
229
217
|
});
|
|
230
218
|
}
|
|
231
219
|
|
|
@@ -245,12 +233,13 @@ export default function createHandler<
|
|
|
245
233
|
if (this.viewTag !== viewTag) {
|
|
246
234
|
this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle
|
|
247
235
|
}
|
|
248
|
-
this.update();
|
|
236
|
+
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
|
|
249
237
|
}
|
|
250
238
|
|
|
251
239
|
componentWillUnmount() {
|
|
252
240
|
this.inspectorToggleListener?.remove();
|
|
253
241
|
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
|
|
242
|
+
scheduleFlushOperations();
|
|
254
243
|
if (this.updateEnqueued) {
|
|
255
244
|
clearImmediate(this.updateEnqueued);
|
|
256
245
|
}
|
|
@@ -361,6 +350,8 @@ export default function createHandler<
|
|
|
361
350
|
actionType
|
|
362
351
|
);
|
|
363
352
|
}
|
|
353
|
+
|
|
354
|
+
scheduleFlushOperations();
|
|
364
355
|
};
|
|
365
356
|
|
|
366
357
|
private updateGestureHandler = (
|
|
@@ -369,16 +360,29 @@ export default function createHandler<
|
|
|
369
360
|
this.config = newConfig;
|
|
370
361
|
|
|
371
362
|
RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
|
|
363
|
+
scheduleFlushOperations();
|
|
372
364
|
};
|
|
373
365
|
|
|
374
|
-
private update() {
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (
|
|
381
|
-
this.
|
|
366
|
+
private update(remainingTries: number) {
|
|
367
|
+
const props: HandlerProps<U> = this.props;
|
|
368
|
+
|
|
369
|
+
// When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
|
|
370
|
+
// `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
|
|
371
|
+
// again is easy enough fix.
|
|
372
|
+
if (hasUnresolvedRefs(props) && remainingTries > 0) {
|
|
373
|
+
this.updateEnqueued = setImmediate(() => {
|
|
374
|
+
this.updateEnqueued = null;
|
|
375
|
+
this.update(remainingTries - 1);
|
|
376
|
+
});
|
|
377
|
+
} else {
|
|
378
|
+
const newConfig = filterConfig(
|
|
379
|
+
transformProps ? transformProps(this.props) : this.props,
|
|
380
|
+
[...allowedProps, ...customNativeProps],
|
|
381
|
+
config
|
|
382
|
+
);
|
|
383
|
+
if (!deepEqual(this.config, newConfig)) {
|
|
384
|
+
this.updateGestureHandler(newConfig);
|
|
385
|
+
}
|
|
382
386
|
}
|
|
383
387
|
}
|
|
384
388
|
|