Skip to content

Commit e33d436

Browse files
committed
move to utils
1 parent 97d894b commit e33d436

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

packages/react-native-gesture-handler/src/v3/hooks/useJSResponderHandler.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,12 @@ import { use, useCallback, useEffect, useRef, useState } from 'react';
33
import { Reanimated } from '../../handlers/gestures/reanimatedWrapper';
44
import { JSResponderContext } from '../components/ScrollViewResponderInterceptor';
55
import { type Gesture, type SharedValue, SingleGestureName } from '../types';
6-
import { isComposedGesture, maybeUnpackValue } from './utils';
6+
import { isComposedGesture, isGestureEnabled } from './utils';
77
import { SHARED_VALUE_OFFSET } from './utils/reanimatedUtils';
88

99
// adding 0.5 to not call Math.random and to make sure that listener ID is not an integer to avoid conflicts
1010
let nextJSResponderContextListenerId = SHARED_VALUE_OFFSET + 0.5;
1111

12-
function isGestureEnabled<
13-
TConfig,
14-
THandlerData,
15-
TExtendedHandlerData extends THandlerData,
16-
>(gesture: Gesture<TConfig, THandlerData, TExtendedHandlerData>): boolean {
17-
if (isComposedGesture(gesture)) {
18-
// For composed gestures, we need to check if at least one of the composed gestures is enabled
19-
return gesture.gestures.some(isGestureEnabled);
20-
}
21-
22-
return maybeUnpackValue(gesture.config.enabled) !== false;
23-
}
24-
2512
function isSupportedGesture<
2613
TConfig,
2714
THandlerData,

packages/react-native-gesture-handler/src/v3/hooks/utils/configUtils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { tagMessage } from '../../../utils';
55
import type {
66
BaseGestureConfig,
77
ExcludeInternalConfigProps,
8+
Gesture,
89
SingleGestureName,
910
} from '../../types';
1011
import { isNativeAnimatedEvent, shouldHandleTouchEvents } from './eventUtils';
@@ -15,6 +16,20 @@ import {
1516
PropsWhiteLists,
1617
} from './propsWhiteList';
1718
import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils';
19+
import { isComposedGesture } from './relationUtils';
20+
21+
export function isGestureEnabled<
22+
TConfig,
23+
THandlerData,
24+
TExtendedHandlerData extends THandlerData,
25+
>(gesture: Gesture<TConfig, THandlerData, TExtendedHandlerData>): boolean {
26+
if (isComposedGesture(gesture)) {
27+
// For composed gestures, we need to check if at least one of the composed gestures is enabled
28+
return gesture.gestures.some(isGestureEnabled);
29+
}
30+
31+
return maybeUnpackValue(gesture.config.enabled) !== false;
32+
}
1833

1934
export function resolveInternalConfigProps<
2035
TConfig extends object,

packages/react-native-gesture-handler/src/v3/hooks/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export {
2+
isGestureEnabled,
23
prepareConfigForNativeSide,
34
useClonedAndRemappedConfig,
45
} from './configUtils';

0 commit comments

Comments
 (0)