react-native-gesture-handler 2.16.0 → 2.16.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +97 -4
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.native.js +16 -0
- package/lib/commonjs/RNGestureHandlerModule.native.js.map +1 -0
- package/lib/commonjs/RNRenderer.js +5 -10
- package/lib/commonjs/RNRenderer.js.map +1 -1
- package/lib/commonjs/RNRenderer.native.js +16 -0
- package/lib/commonjs/RNRenderer.native.js.map +1 -0
- package/lib/commonjs/components/GestureComponents.js +19 -82
- package/lib/commonjs/components/GestureComponents.js.map +1 -1
- package/lib/commonjs/components/GestureComponents.native.js +115 -0
- package/lib/commonjs/components/GestureComponents.native.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerButton.js +13 -3
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.native.js +14 -0
- package/lib/commonjs/components/GestureHandlerButton.native.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerRootView.js +0 -6
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +7 -1
- package/lib/commonjs/components/GestureHandlerRootView.native.js.map +1 -0
- package/lib/commonjs/getReactNativeVersion.js +1 -12
- package/lib/commonjs/getReactNativeVersion.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.native.js +22 -0
- package/lib/commonjs/getReactNativeVersion.native.js.map +1 -0
- package/lib/commonjs/getShadowNodeFromRef.js +5 -34
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.native.js +44 -0
- package/lib/commonjs/getShadowNodeFromRef.native.js.map +1 -0
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.js +5 -7
- package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.native.js +14 -0
- package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +9 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/customDirectEventTypes.js +5 -8
- package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -1
- package/lib/commonjs/handlers/customDirectEventTypes.native.js +14 -0
- package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js +15 -0
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js +13 -0
- package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +135 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureObjects.js +66 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/longPressGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js +10 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js +76 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/tapGesture.js +42 -0
- package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/commonjs/utils.js +5 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +7 -7
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +3 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +84 -4
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.native.js +5 -0
- package/lib/module/RNGestureHandlerModule.native.js.map +1 -0
- package/lib/module/RNRenderer.js +3 -3
- package/lib/module/RNRenderer.js.map +1 -1
- package/lib/module/RNRenderer.native.js +4 -0
- package/lib/module/RNRenderer.native.js.map +1 -0
- package/lib/module/components/GestureComponents.js +18 -80
- package/lib/module/components/GestureComponents.js.map +1 -1
- package/lib/module/components/GestureComponents.native.js +90 -0
- package/lib/module/components/GestureComponents.native.js.map +1 -0
- package/lib/module/components/GestureHandlerButton.js +8 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.native.js +3 -0
- package/lib/module/components/GestureHandlerButton.native.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.js +0 -5
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +6 -1
- package/lib/module/components/GestureHandlerRootView.native.js.map +1 -0
- package/lib/module/getReactNativeVersion.js +1 -7
- package/lib/module/getReactNativeVersion.js.map +1 -1
- package/lib/module/getReactNativeVersion.native.js +10 -0
- package/lib/module/getReactNativeVersion.native.js.map +1 -0
- package/lib/module/getShadowNodeFromRef.js +4 -33
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.native.js +37 -0
- package/lib/module/getShadowNodeFromRef.native.js.map +1 -0
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.js +4 -2
- package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.native.js +3 -0
- package/lib/module/handlers/PressabilityDebugView.native.js.map +1 -0
- package/lib/module/handlers/createHandler.js +9 -3
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/customDirectEventTypes.js +4 -2
- package/lib/module/handlers/customDirectEventTypes.js.map +1 -1
- package/lib/module/handlers/customDirectEventTypes.native.js +3 -0
- package/lib/module/handlers/customDirectEventTypes.native.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector.js +15 -0
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +13 -0
- package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +17 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +135 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureObjects.js +67 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
- package/lib/module/handlers/gestures/longPressGesture.js +12 -0
- package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +10 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +76 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/tapGesture.js +42 -0
- package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
- package/lib/module/utils.js +5 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +7 -7
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +3 -1
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +15 -2
- package/lib/typescript/RNGestureHandlerModule.native.d.ts +2 -0
- package/lib/typescript/RNRenderer.d.ts +3 -1
- package/lib/typescript/RNRenderer.native.d.ts +1 -0
- package/lib/typescript/components/GestureComponents.d.ts +7 -21
- package/lib/typescript/components/GestureComponents.native.d.ts +22 -0
- package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
- package/lib/typescript/components/GestureHandlerButton.native.d.ts +4 -0
- package/lib/typescript/getReactNativeVersion.d.ts +1 -4
- package/lib/typescript/getReactNativeVersion.native.d.ts +4 -0
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
- package/lib/typescript/getShadowNodeFromRef.native.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +4 -4
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
- package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +1 -0
- package/lib/typescript/handlers/customDirectEventTypes.d.ts +2 -1
- package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +1 -0
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +36 -0
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +11 -0
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +14 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +113 -0
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +57 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +10 -0
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +8 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +67 -4
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +35 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -2
- package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -1
- package/lib/typescript/web/interfaces.d.ts +1 -0
- package/package.json +3 -2
- package/src/RNGestureHandlerModule.native.ts +5 -0
- package/src/RNGestureHandlerModule.ts +104 -4
- package/src/RNRenderer.native.ts +3 -0
- package/src/RNRenderer.ts +3 -3
- package/src/components/GestureComponents.native.tsx +148 -0
- package/src/components/GestureComponents.tsx +24 -131
- package/src/components/GestureHandlerButton.native.tsx +5 -0
- package/src/components/GestureHandlerButton.tsx +5 -4
- package/src/components/{GestureHandlerRootView.web.tsx → GestureHandlerRootView.native.tsx} +6 -0
- package/src/components/GestureHandlerRootView.tsx +0 -6
- package/src/getReactNativeVersion.native.ts +11 -0
- package/src/getReactNativeVersion.ts +1 -9
- package/src/getShadowNodeFromRef.native.ts +44 -0
- package/src/getShadowNodeFromRef.ts +4 -41
- package/src/handlers/PanGestureHandler.ts +8 -4
- package/src/handlers/PressabilityDebugView.native.tsx +2 -0
- package/src/handlers/PressabilityDebugView.tsx +4 -2
- package/src/handlers/createHandler.tsx +14 -10
- package/src/handlers/customDirectEventTypes.native.ts +2 -0
- package/src/handlers/customDirectEventTypes.ts +5 -2
- package/src/handlers/gestures/GestureDetector.tsx +47 -4
- package/src/handlers/gestures/flingGesture.ts +11 -0
- package/src/handlers/gestures/forceTouchGesture.ts +14 -0
- package/src/handlers/gestures/gesture.ts +113 -0
- package/src/handlers/gestures/gestureObjects.ts +57 -0
- package/src/handlers/gestures/gestureStateManager.web.ts +1 -1
- package/src/handlers/gestures/hoverGesture.ts +1 -1
- package/src/handlers/gestures/longPressGesture.ts +10 -0
- package/src/handlers/gestures/nativeGesture.ts +8 -0
- package/src/handlers/gestures/panGesture.ts +75 -4
- package/src/handlers/gestures/tapGesture.ts +35 -0
- package/src/utils.ts +9 -2
- package/src/web/handlers/GestureHandler.ts +9 -9
- package/src/web/handlers/IGestureHandler.ts +1 -1
- package/src/web/handlers/PanGestureHandler.ts +4 -0
- package/src/web/interfaces.ts +1 -0
- package/lib/commonjs/RNGestureHandlerModule.web.js +0 -109
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +0 -1
- package/lib/commonjs/RNRenderer.web.js +0 -11
- package/lib/commonjs/RNRenderer.web.js.map +0 -1
- package/lib/commonjs/components/GestureComponents.web.js +0 -52
- package/lib/commonjs/components/GestureComponents.web.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerButton.web.js +0 -24
- package/lib/commonjs/components/GestureHandlerButton.web.js.map +0 -1
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +0 -1
- package/lib/commonjs/getReactNativeVersion.web.js +0 -11
- package/lib/commonjs/getReactNativeVersion.web.js.map +0 -1
- package/lib/commonjs/getShadowNodeFromRef.web.js +0 -15
- package/lib/commonjs/getShadowNodeFromRef.web.js.map +0 -1
- package/lib/commonjs/handlers/PressabilityDebugView.web.js +0 -12
- package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +0 -1
- package/lib/commonjs/handlers/customDirectEventTypes.web.js +0 -11
- package/lib/commonjs/handlers/customDirectEventTypes.web.js.map +0 -1
- package/lib/module/RNGestureHandlerModule.web.js +0 -85
- package/lib/module/RNGestureHandlerModule.web.js.map +0 -1
- package/lib/module/RNRenderer.web.js +0 -4
- package/lib/module/RNRenderer.web.js.map +0 -1
- package/lib/module/components/GestureComponents.web.js +0 -28
- package/lib/module/components/GestureComponents.web.js.map +0 -1
- package/lib/module/components/GestureHandlerButton.web.js +0 -9
- package/lib/module/components/GestureHandlerButton.web.js.map +0 -1
- package/lib/module/components/GestureHandlerRootView.web.js.map +0 -1
- package/lib/module/getReactNativeVersion.web.js +0 -4
- package/lib/module/getReactNativeVersion.web.js.map +0 -1
- package/lib/module/getShadowNodeFromRef.web.js +0 -8
- package/lib/module/getShadowNodeFromRef.web.js.map +0 -1
- package/lib/module/handlers/PressabilityDebugView.web.js +0 -5
- package/lib/module/handlers/PressabilityDebugView.web.js.map +0 -1
- package/lib/module/handlers/customDirectEventTypes.web.js +0 -5
- package/lib/module/handlers/customDirectEventTypes.web.js.map +0 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -15
- package/lib/typescript/RNRenderer.web.d.ts +0 -3
- package/lib/typescript/components/GestureComponents.web.d.ts +0 -8
- package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -4
- package/lib/typescript/getReactNativeVersion.web.d.ts +0 -1
- package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
- package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +0 -2
- package/src/RNGestureHandlerModule.web.ts +0 -105
- package/src/RNRenderer.web.ts +0 -3
- package/src/components/GestureComponents.web.tsx +0 -41
- package/src/components/GestureHandlerButton.web.tsx +0 -6
- package/src/getReactNativeVersion.web.ts +0 -3
- package/src/getShadowNodeFromRef.web.ts +0 -7
- package/src/handlers/PressabilityDebugView.web.tsx +0 -4
- package/src/handlers/customDirectEventTypes.web.ts +0 -5
- /package/lib/typescript/components/{GestureHandlerRootView.web.d.ts → GestureHandlerRootView.native.d.ts} +0 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
3
|
import { View, ViewProps, StyleSheet } from 'react-native';
|
4
|
+
import { maybeInitializeFabric } from '../init';
|
4
5
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
5
6
|
|
6
7
|
export interface GestureHandlerRootViewProps
|
@@ -10,6 +11,11 @@ export default function GestureHandlerRootView({
|
|
10
11
|
style,
|
11
12
|
...rest
|
12
13
|
}: GestureHandlerRootViewProps) {
|
14
|
+
// try initialize fabric on the first render, at this point we can
|
15
|
+
// reliably check if fabric is enabled (the function contains a flag
|
16
|
+
// to make sure it's called only once)
|
17
|
+
maybeInitializeFabric();
|
18
|
+
|
13
19
|
return (
|
14
20
|
<GestureHandlerRootViewContext.Provider value>
|
15
21
|
<View style={style ?? styles.container} {...rest} />
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
3
|
import { View, ViewProps, StyleSheet } from 'react-native';
|
4
|
-
import { maybeInitializeFabric } from '../init';
|
5
4
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
6
5
|
|
7
6
|
export interface GestureHandlerRootViewProps
|
@@ -11,11 +10,6 @@ export default function GestureHandlerRootView({
|
|
11
10
|
style,
|
12
11
|
...rest
|
13
12
|
}: GestureHandlerRootViewProps) {
|
14
|
-
// try initialize fabric on the first render, at this point we can
|
15
|
-
// reliably check if fabric is enabled (the function contains a flag
|
16
|
-
// to make sure it's called only once)
|
17
|
-
maybeInitializeFabric();
|
18
|
-
|
19
13
|
return (
|
20
14
|
<GestureHandlerRootViewContext.Provider value>
|
21
15
|
<View style={style ?? styles.container} {...rest} />
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import pack from 'react-native/package.json';
|
2
|
+
|
3
|
+
const [majorStr, minorStr] = pack.version.split('.');
|
4
|
+
const REACT_NATIVE_VERSION = {
|
5
|
+
major: parseInt(majorStr, 10),
|
6
|
+
minor: parseInt(minorStr, 10),
|
7
|
+
};
|
8
|
+
|
9
|
+
export function getReactNativeVersion() {
|
10
|
+
return REACT_NATIVE_VERSION;
|
11
|
+
}
|
@@ -1,11 +1,3 @@
|
|
1
|
-
import pack from 'react-native/package.json';
|
2
|
-
|
3
|
-
const [majorStr, minorStr] = pack.version.split('.');
|
4
|
-
const REACT_NATIVE_VERSION = {
|
5
|
-
major: parseInt(majorStr, 10),
|
6
|
-
minor: parseInt(minorStr, 10),
|
7
|
-
};
|
8
|
-
|
9
1
|
export function getReactNativeVersion() {
|
10
|
-
|
2
|
+
throw new Error('getReactNativeVersion is not supported on web');
|
11
3
|
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
// Used by GestureDetector (unsupported on web at the moment) to check whether the
|
2
|
+
// attached view may get flattened on Fabric. This implementation causes errors
|
3
|
+
// on web due to the static resolution of `require` statements by webpack breaking
|
4
|
+
// the conditional importing. Solved by making .web file.
|
5
|
+
let findHostInstance_DEPRECATED: (ref: unknown) => void;
|
6
|
+
let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
|
7
|
+
stateNode: { node: unknown };
|
8
|
+
};
|
9
|
+
|
10
|
+
export function getShadowNodeFromRef(ref: unknown) {
|
11
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
12
|
+
if (findHostInstance_DEPRECATED === undefined) {
|
13
|
+
try {
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
15
|
+
findHostInstance_DEPRECATED =
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
17
|
+
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
18
|
+
} catch (e) {
|
19
|
+
findHostInstance_DEPRECATED = (_ref: unknown) => null;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
24
|
+
if (getInternalInstanceHandleFromPublicInstance === undefined) {
|
25
|
+
try {
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
27
|
+
getInternalInstanceHandleFromPublicInstance =
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
29
|
+
require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
|
30
|
+
.getInternalInstanceHandleFromPublicInstance ??
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
32
|
+
((ref: any) => ref._internalInstanceHandle);
|
33
|
+
} catch (e) {
|
34
|
+
getInternalInstanceHandleFromPublicInstance = (ref: any) =>
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
36
|
+
ref._internalInstanceHandle;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
// @ts-ignore Fabric
|
41
|
+
return getInternalInstanceHandleFromPublicInstance(
|
42
|
+
findHostInstance_DEPRECATED(ref)
|
43
|
+
).stateNode.node;
|
44
|
+
}
|
@@ -1,44 +1,7 @@
|
|
1
1
|
// Used by GestureDetector (unsupported on web at the moment) to check whether the
|
2
|
-
// attached view may get flattened on Fabric.
|
2
|
+
// attached view may get flattened on Fabric. Original implementation causes errors
|
3
3
|
// on web due to the static resolution of `require` statements by webpack breaking
|
4
|
-
// the conditional importing.
|
5
|
-
|
6
|
-
|
7
|
-
stateNode: { node: unknown };
|
8
|
-
};
|
9
|
-
|
10
|
-
export function getShadowNodeFromRef(ref: unknown) {
|
11
|
-
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
12
|
-
if (findHostInstance_DEPRECATED === undefined) {
|
13
|
-
try {
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
15
|
-
findHostInstance_DEPRECATED =
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
17
|
-
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
18
|
-
} catch (e) {
|
19
|
-
findHostInstance_DEPRECATED = (_ref: unknown) => null;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
24
|
-
if (getInternalInstanceHandleFromPublicInstance === undefined) {
|
25
|
-
try {
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
27
|
-
getInternalInstanceHandleFromPublicInstance =
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
29
|
-
require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
|
30
|
-
.getInternalInstanceHandleFromPublicInstance ??
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
32
|
-
((ref: any) => ref._internalInstanceHandle);
|
33
|
-
} catch (e) {
|
34
|
-
getInternalInstanceHandleFromPublicInstance = (ref: any) =>
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
36
|
-
ref._internalInstanceHandle;
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
// @ts-ignore Fabric
|
41
|
-
return getInternalInstanceHandleFromPublicInstance(
|
42
|
-
findHostInstance_DEPRECATED(ref)
|
43
|
-
).stateNode.node;
|
4
|
+
// the conditional importing.
|
5
|
+
export function getShadowNodeFromRef(_ref: any) {
|
6
|
+
return null;
|
44
7
|
}
|
@@ -150,7 +150,9 @@ export interface PanGestureHandlerProps
|
|
150
150
|
* to 0. If only one number `p` is given a range of `(-inf, p)` will be used
|
151
151
|
* if `p` is higher or equal to 0 and `(-p, inf)` otherwise.
|
152
152
|
*/
|
153
|
-
activeOffsetY?:
|
153
|
+
activeOffsetY?:
|
154
|
+
| number
|
155
|
+
| [activeOffsetYStart: number, activeOffsetYEnd: number];
|
154
156
|
|
155
157
|
/**
|
156
158
|
* Range along X axis (in points) where fingers travels without activation of
|
@@ -160,7 +162,9 @@ export interface PanGestureHandlerProps
|
|
160
162
|
* to 0. If only one number `p` is given a range of `(-inf, p)` will be used
|
161
163
|
* if `p` is higher or equal to 0 and `(-p, inf)` otherwise.
|
162
164
|
*/
|
163
|
-
activeOffsetX?:
|
165
|
+
activeOffsetX?:
|
166
|
+
| number
|
167
|
+
| [activeOffsetXStart: number, activeOffsetXEnd: number];
|
164
168
|
|
165
169
|
/**
|
166
170
|
* When the finger moves outside this range (in points) along Y axis and
|
@@ -170,7 +174,7 @@ export interface PanGestureHandlerProps
|
|
170
174
|
* to 0. If only one number `p` is given a range of `(-inf, p)` will be used
|
171
175
|
* if `p` is higher or equal to 0 and `(-p, inf)` otherwise.
|
172
176
|
*/
|
173
|
-
failOffsetY?: number | number
|
177
|
+
failOffsetY?: number | [failOffsetYStart: number, failOffsetYEnd: number];
|
174
178
|
|
175
179
|
/**
|
176
180
|
* When the finger moves outside this range (in points) along X axis and
|
@@ -180,7 +184,7 @@ export interface PanGestureHandlerProps
|
|
180
184
|
* to 0. If only one number `p` is given a range of `(-inf, p)` will be used
|
181
185
|
* if `p` is higher or equal to 0 and `(-p, inf)` otherwise.
|
182
186
|
*/
|
183
|
-
failOffsetX?: number | number
|
187
|
+
failOffsetX?: number | [failOffsetXStart: number, failOffsetXEnd: number];
|
184
188
|
}
|
185
189
|
|
186
190
|
export const panHandlerName = 'PanGestureHandler';
|
@@ -1,2 +1,4 @@
|
|
1
|
-
//
|
2
|
-
export
|
1
|
+
// PressabilityDebugView is not implemented in react-native-web
|
2
|
+
export function PressabilityDebugView() {
|
3
|
+
return null;
|
4
|
+
}
|
@@ -341,18 +341,22 @@ export default function createHandler<
|
|
341
341
|
});
|
342
342
|
|
343
343
|
const actionType = (() => {
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
(
|
348
|
-
'
|
349
|
-
|
344
|
+
const onGestureEvent = this.props?.onGestureEvent;
|
345
|
+
const isGestureHandlerWorklet =
|
346
|
+
onGestureEvent &&
|
347
|
+
('current' in onGestureEvent ||
|
348
|
+
'workletEventHandler' in onGestureEvent);
|
349
|
+
const onHandlerStateChange = this.props?.onHandlerStateChange;
|
350
|
+
const isStateChangeHandlerWorklet =
|
351
|
+
onHandlerStateChange &&
|
352
|
+
('current' in onHandlerStateChange ||
|
353
|
+
'workletEventHandler' in onHandlerStateChange);
|
354
|
+
const isReanimatedHandler =
|
355
|
+
isGestureHandlerWorklet || isStateChangeHandlerWorklet;
|
356
|
+
if (isReanimatedHandler) {
|
350
357
|
// Reanimated worklet
|
351
358
|
return ActionType.REANIMATED_WORKLET;
|
352
|
-
} else if (
|
353
|
-
this.props?.onGestureEvent &&
|
354
|
-
'__isNative' in this.props.onGestureEvent
|
355
|
-
) {
|
359
|
+
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
|
356
360
|
// Animated.event with useNativeDriver: true
|
357
361
|
return ActionType.NATIVE_ANIMATED_EVENT;
|
358
362
|
} else {
|
@@ -1,2 +1,5 @@
|
|
1
|
-
//
|
2
|
-
|
1
|
+
// customDirectEventTypes doesn't exist in react-native-web, therefore importing it
|
2
|
+
// directly in createHandler.tsx would end in crash.
|
3
|
+
const customDirectEventTypes = {};
|
4
|
+
|
5
|
+
export { customDirectEventTypes };
|
@@ -42,7 +42,6 @@ import { isFabric, isJestEnv, tagMessage } from '../../utils';
|
|
42
42
|
import { getReactNativeVersion } from '../../getReactNativeVersion';
|
43
43
|
import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
|
44
44
|
import { Platform } from 'react-native';
|
45
|
-
import type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';
|
46
45
|
import { onGestureHandlerEvent } from './eventReceiver';
|
47
46
|
import { RNRenderer } from '../../RNRenderer';
|
48
47
|
import { isNewWebImplementationEnabled } from '../../EnableNewWebImplementation';
|
@@ -50,6 +49,14 @@ import { nativeViewGestureHandlerProps } from '../NativeViewGestureHandler';
|
|
50
49
|
import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext';
|
51
50
|
import { ghQueueMicrotask } from '../../ghQueueMicrotask';
|
52
51
|
|
52
|
+
type AttachGestureHandlerWeb = (
|
53
|
+
handlerTag: number,
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
55
|
+
newView: any,
|
56
|
+
_actionType: ActionType,
|
57
|
+
propsRef: React.RefObject<unknown>
|
58
|
+
) => void;
|
59
|
+
|
53
60
|
declare const global: {
|
54
61
|
isFormsStackingContext: (node: unknown) => boolean | null; // JSI function
|
55
62
|
};
|
@@ -220,9 +227,7 @@ function attachHandlers({
|
|
220
227
|
: ActionType.JS_FUNCTION_NEW_API;
|
221
228
|
|
222
229
|
if (Platform.OS === 'web') {
|
223
|
-
(
|
224
|
-
RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler
|
225
|
-
)(
|
230
|
+
(RNGestureHandlerModule.attachGestureHandler as AttachGestureHandlerWeb)(
|
226
231
|
gesture.handlerTag,
|
227
232
|
viewTag,
|
228
233
|
ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
@@ -625,10 +630,32 @@ const applyTouchActionProp = (
|
|
625
630
|
};
|
626
631
|
|
627
632
|
interface GestureDetectorProps {
|
633
|
+
/**
|
634
|
+
* A gesture object containing the configuration and callbacks.
|
635
|
+
* Can be any of:
|
636
|
+
* - base gestures (`Tap`, `Pan`, ...)
|
637
|
+
* - `ComposedGesture` (`Race`, `Simultaneous`, `Exclusive`)
|
638
|
+
*/
|
628
639
|
gesture: ComposedGesture | GestureType;
|
629
640
|
children?: React.ReactNode;
|
641
|
+
|
642
|
+
/**
|
643
|
+
* #### Web only
|
644
|
+
* This parameter allows to specify which `userSelect` property should be applied to underlying view.
|
645
|
+
* Possible values are `"none" | "auto" | "text"`. Default value is set to `"none"`.
|
646
|
+
*/
|
630
647
|
userSelect?: UserSelect;
|
648
|
+
/**
|
649
|
+
* #### Web only
|
650
|
+
* Specifies whether context menu should be enabled after clicking on underlying view with right mouse button.
|
651
|
+
* Default value is set to `false`.
|
652
|
+
*/
|
631
653
|
enableContextMenu?: boolean;
|
654
|
+
/**
|
655
|
+
* #### Web only
|
656
|
+
* This parameter allows to specify which `touchAction` property should be applied to underlying view.
|
657
|
+
* Supports all CSS touch-action values (e.g. `"none"`, `"pan-y"`). Default value is set to `"none"`.
|
658
|
+
*/
|
632
659
|
touchAction?: TouchAction;
|
633
660
|
}
|
634
661
|
interface GestureDetectorState {
|
@@ -637,6 +664,22 @@ interface GestureDetectorState {
|
|
637
664
|
previousViewTag: number;
|
638
665
|
forceReattach: boolean;
|
639
666
|
}
|
667
|
+
|
668
|
+
/**
|
669
|
+
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
|
670
|
+
*
|
671
|
+
* ### Props
|
672
|
+
* - `gesture`
|
673
|
+
* - `userSelect` (**Web only**)
|
674
|
+
* - `enableContextMenu` (**Web only**)
|
675
|
+
* - `touchAction` (**Web only**)
|
676
|
+
*
|
677
|
+
* ### Remarks
|
678
|
+
* - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
|
679
|
+
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
|
680
|
+
*
|
681
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
|
682
|
+
*/
|
640
683
|
export const GestureDetector = (props: GestureDetectorProps) => {
|
641
684
|
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
642
685
|
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
|
@@ -13,11 +13,22 @@ export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
|
|
13
13
|
this.handlerName = 'FlingGestureHandler';
|
14
14
|
}
|
15
15
|
|
16
|
+
/**
|
17
|
+
* Determine exact number of points required to handle the fling gesture.
|
18
|
+
* @param pointers
|
19
|
+
*/
|
16
20
|
numberOfPointers(pointers: number) {
|
17
21
|
this.config.numberOfPointers = pointers;
|
18
22
|
return this;
|
19
23
|
}
|
20
24
|
|
25
|
+
/**
|
26
|
+
* Expressed allowed direction of movement.
|
27
|
+
* Expected values are exported as constants in the Directions object.
|
28
|
+
* Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.
|
29
|
+
* @param direction
|
30
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
|
31
|
+
*/
|
21
32
|
direction(direction: number) {
|
22
33
|
this.config.direction = direction;
|
23
34
|
return this;
|
@@ -40,16 +40,30 @@ export class ForceTouchGesture extends ContinousBaseGesture<
|
|
40
40
|
this.handlerName = 'ForceTouchGestureHandler';
|
41
41
|
}
|
42
42
|
|
43
|
+
/**
|
44
|
+
* A minimal pressure that is required before gesture can activate.
|
45
|
+
* Should be a value from range [0.0, 1.0]. Default is 0.2.
|
46
|
+
* @param force
|
47
|
+
*/
|
43
48
|
minForce(force: number) {
|
44
49
|
this.config.minForce = force;
|
45
50
|
return this;
|
46
51
|
}
|
47
52
|
|
53
|
+
/**
|
54
|
+
* A maximal pressure that could be applied for gesture.
|
55
|
+
* If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
|
56
|
+
* @param force
|
57
|
+
*/
|
48
58
|
maxForce(force: number) {
|
49
59
|
this.config.maxForce = force;
|
50
60
|
return this;
|
51
61
|
}
|
52
62
|
|
63
|
+
/**
|
64
|
+
* Value defining if haptic feedback has to be performed on activation.
|
65
|
+
* @param value
|
66
|
+
*/
|
53
67
|
feedbackOnActivation(value: boolean) {
|
54
68
|
this.config.feedbackOnActivation = value;
|
55
69
|
return this;
|
@@ -155,6 +155,10 @@ export abstract class BaseGesture<
|
|
155
155
|
: [gesture];
|
156
156
|
}
|
157
157
|
|
158
|
+
/**
|
159
|
+
* Sets a `ref` to the gesture object, allowing for interoperability with the old API.
|
160
|
+
* @param ref
|
161
|
+
*/
|
158
162
|
withRef(ref: React.MutableRefObject<GestureType | undefined>) {
|
159
163
|
this.config.ref = ref;
|
160
164
|
return this;
|
@@ -166,18 +170,32 @@ export abstract class BaseGesture<
|
|
166
170
|
return callback.__workletHash !== undefined;
|
167
171
|
}
|
168
172
|
|
173
|
+
/**
|
174
|
+
* Set the callback that is being called when given gesture handler starts receiving touches.
|
175
|
+
* At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
|
176
|
+
* @param callback
|
177
|
+
*/
|
169
178
|
onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {
|
170
179
|
this.handlers.onBegin = callback;
|
171
180
|
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
|
172
181
|
return this;
|
173
182
|
}
|
174
183
|
|
184
|
+
/**
|
185
|
+
* Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
|
186
|
+
* @param callback
|
187
|
+
*/
|
175
188
|
onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void) {
|
176
189
|
this.handlers.onStart = callback;
|
177
190
|
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
|
178
191
|
return this;
|
179
192
|
}
|
180
193
|
|
194
|
+
/**
|
195
|
+
* Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
|
196
|
+
* It will be called only if the handler was previously in the `ACTIVE` state.
|
197
|
+
* @param callback
|
198
|
+
*/
|
181
199
|
onEnd(
|
182
200
|
callback: (
|
183
201
|
event: GestureStateChangeEvent<EventPayloadT>,
|
@@ -190,6 +208,10 @@ export abstract class BaseGesture<
|
|
190
208
|
return this;
|
191
209
|
}
|
192
210
|
|
211
|
+
/**
|
212
|
+
* Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
|
213
|
+
* @param callback
|
214
|
+
*/
|
193
215
|
onFinalize(
|
194
216
|
callback: (
|
195
217
|
event: GestureStateChangeEvent<EventPayloadT>,
|
@@ -202,6 +224,10 @@ export abstract class BaseGesture<
|
|
202
224
|
return this;
|
203
225
|
}
|
204
226
|
|
227
|
+
/**
|
228
|
+
* Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
|
229
|
+
* @param callback
|
230
|
+
*/
|
205
231
|
onTouchesDown(callback: TouchEventHandlerType) {
|
206
232
|
this.config.needsPointerData = true;
|
207
233
|
this.handlers.onTouchesDown = callback;
|
@@ -211,6 +237,10 @@ export abstract class BaseGesture<
|
|
211
237
|
return this;
|
212
238
|
}
|
213
239
|
|
240
|
+
/**
|
241
|
+
* Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
|
242
|
+
* @param callback
|
243
|
+
*/
|
214
244
|
onTouchesMove(callback: TouchEventHandlerType) {
|
215
245
|
this.config.needsPointerData = true;
|
216
246
|
this.handlers.onTouchesMove = callback;
|
@@ -220,6 +250,10 @@ export abstract class BaseGesture<
|
|
220
250
|
return this;
|
221
251
|
}
|
222
252
|
|
253
|
+
/**
|
254
|
+
* Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
|
255
|
+
* @param callback
|
256
|
+
*/
|
223
257
|
onTouchesUp(callback: TouchEventHandlerType) {
|
224
258
|
this.config.needsPointerData = true;
|
225
259
|
this.handlers.onTouchesUp = callback;
|
@@ -229,6 +263,10 @@ export abstract class BaseGesture<
|
|
229
263
|
return this;
|
230
264
|
}
|
231
265
|
|
266
|
+
/**
|
267
|
+
* Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
|
268
|
+
* @param callback
|
269
|
+
*/
|
232
270
|
onTouchesCancelled(callback: TouchEventHandlerType) {
|
233
271
|
this.config.needsPointerData = true;
|
234
272
|
this.handlers.onTouchesCancelled = callback;
|
@@ -238,36 +276,77 @@ export abstract class BaseGesture<
|
|
238
276
|
return this;
|
239
277
|
}
|
240
278
|
|
279
|
+
/**
|
280
|
+
* Indicates whether the given handler should be analyzing stream of touch events or not.
|
281
|
+
* @param enabled
|
282
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
|
283
|
+
*/
|
241
284
|
enabled(enabled: boolean) {
|
242
285
|
this.config.enabled = enabled;
|
243
286
|
return this;
|
244
287
|
}
|
245
288
|
|
289
|
+
/**
|
290
|
+
* When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
|
291
|
+
* @param value
|
292
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
|
293
|
+
*/
|
246
294
|
shouldCancelWhenOutside(value: boolean) {
|
247
295
|
this.config.shouldCancelWhenOutside = value;
|
248
296
|
return this;
|
249
297
|
}
|
250
298
|
|
299
|
+
/**
|
300
|
+
* This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
|
301
|
+
* When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
|
302
|
+
* @param hitSlop
|
303
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
|
304
|
+
*/
|
251
305
|
hitSlop(hitSlop: HitSlop) {
|
252
306
|
this.config.hitSlop = hitSlop;
|
253
307
|
return this;
|
254
308
|
}
|
255
309
|
|
310
|
+
/**
|
311
|
+
* #### Web only
|
312
|
+
* This parameter allows to specify which `cursor` should be used when gesture activates.
|
313
|
+
* Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
|
314
|
+
* @param activeCursor
|
315
|
+
*/
|
256
316
|
activeCursor(activeCursor: ActiveCursor) {
|
257
317
|
this.config.activeCursor = activeCursor;
|
258
318
|
return this;
|
259
319
|
}
|
260
320
|
|
321
|
+
/**
|
322
|
+
* #### Web & Android only
|
323
|
+
* Allows users to choose which mouse button should handler respond to.
|
324
|
+
* Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
|
325
|
+
* Default value is set to `MouseButton.LEFT`.
|
326
|
+
* @param mouseButton
|
327
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
|
328
|
+
*/
|
261
329
|
mouseButton(mouseButton: MouseButton) {
|
262
330
|
this.config.mouseButton = mouseButton;
|
263
331
|
return this;
|
264
332
|
}
|
265
333
|
|
334
|
+
/**
|
335
|
+
* When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
|
336
|
+
* This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
|
337
|
+
* Defaults to `false`.
|
338
|
+
* @param runOnJS
|
339
|
+
*/
|
266
340
|
runOnJS(runOnJS: boolean) {
|
267
341
|
this.config.runOnJS = runOnJS;
|
268
342
|
return this;
|
269
343
|
}
|
270
344
|
|
345
|
+
/**
|
346
|
+
* Allows gestures across different components to be recognized simultaneously.
|
347
|
+
* @param gestures
|
348
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
|
349
|
+
*/
|
271
350
|
simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]) {
|
272
351
|
for (const gesture of gestures) {
|
273
352
|
this.addDependency('simultaneousWith', gesture);
|
@@ -275,6 +354,11 @@ export abstract class BaseGesture<
|
|
275
354
|
return this;
|
276
355
|
}
|
277
356
|
|
357
|
+
/**
|
358
|
+
* Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
|
359
|
+
* @param gestures
|
360
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
|
361
|
+
*/
|
278
362
|
requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]) {
|
279
363
|
for (const gesture of gestures) {
|
280
364
|
this.addDependency('requireToFail', gesture);
|
@@ -282,6 +366,11 @@ export abstract class BaseGesture<
|
|
282
366
|
return this;
|
283
367
|
}
|
284
368
|
|
369
|
+
/**
|
370
|
+
* Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
|
371
|
+
* @param gestures
|
372
|
+
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
|
373
|
+
*/
|
285
374
|
blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {
|
286
375
|
for (const gesture of gestures) {
|
287
376
|
this.addDependency('blocksHandlers', gesture);
|
@@ -289,11 +378,21 @@ export abstract class BaseGesture<
|
|
289
378
|
return this;
|
290
379
|
}
|
291
380
|
|
381
|
+
/**
|
382
|
+
* Sets a `testID` property for gesture object, allowing for querying for it in tests.
|
383
|
+
* @param id
|
384
|
+
*/
|
292
385
|
withTestId(id: string) {
|
293
386
|
this.config.testId = id;
|
294
387
|
return this;
|
295
388
|
}
|
296
389
|
|
390
|
+
/**
|
391
|
+
* #### iOS only
|
392
|
+
* When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
|
393
|
+
* Default value is `true`.
|
394
|
+
* @param value
|
395
|
+
*/
|
297
396
|
cancelsTouchesInView(value: boolean) {
|
298
397
|
this.config.cancelsTouchesInView = value;
|
299
398
|
return this;
|
@@ -332,12 +431,21 @@ export abstract class ContinousBaseGesture<
|
|
332
431
|
EventPayloadT extends Record<string, unknown>,
|
333
432
|
EventChangePayloadT extends Record<string, unknown>
|
334
433
|
> extends BaseGesture<EventPayloadT> {
|
434
|
+
/**
|
435
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
436
|
+
* @param callback
|
437
|
+
*/
|
335
438
|
onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {
|
336
439
|
this.handlers.onUpdate = callback;
|
337
440
|
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
|
338
441
|
return this;
|
339
442
|
}
|
340
443
|
|
444
|
+
/**
|
445
|
+
* Set the callback that is being called every time the gesture receives an update while it's active.
|
446
|
+
* This callback will receive information about change in value in relation to the last received event.
|
447
|
+
* @param callback
|
448
|
+
*/
|
341
449
|
onChange(
|
342
450
|
callback: (
|
343
451
|
event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>
|
@@ -348,6 +456,11 @@ export abstract class ContinousBaseGesture<
|
|
348
456
|
return this;
|
349
457
|
}
|
350
458
|
|
459
|
+
/**
|
460
|
+
* When `true` the handler will not activate by itself even if its activation criteria are met.
|
461
|
+
* Instead you can manipulate its state using state manager.
|
462
|
+
* @param manualActivation
|
463
|
+
*/
|
351
464
|
manualActivation(manualActivation: boolean) {
|
352
465
|
this.config.manualActivation = manualActivation;
|
353
466
|
return this;
|