react-native-gesture-handler 2.29.0 → 2.30.0-20251030-c99169d35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +1 -0
 - package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +8 -1
 - package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +1 -1
 - package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +73 -41
 - package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +0 -3
 - package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +12 -4
 - package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +6 -0
 - package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
 - package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
 - package/lib/commonjs/components/Pressable/Pressable.js +3 -1
 - package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
 - package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js +4 -2
 - package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
 - package/lib/commonjs/handlers/gestures/GestureDetector/index.js +2 -1
 - package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
 - package/lib/commonjs/handlers/gestures/GestureDetector/utils.js +7 -7
 - package/lib/commonjs/handlers/gestures/GestureDetector/utils.js.map +1 -1
 - package/lib/commonjs/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
 - package/lib/commonjs/useIsomorphicLayoutEffect.js +20 -0
 - package/lib/commonjs/useIsomorphicLayoutEffect.js.map +1 -0
 - package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
 - package/lib/module/components/GestureHandlerRootView.js.map +1 -1
 - package/lib/module/components/Pressable/Pressable.js +3 -1
 - package/lib/module/components/Pressable/Pressable.js.map +1 -1
 - package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +5 -3
 - package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
 - package/lib/module/handlers/gestures/GestureDetector/index.js +3 -2
 - package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
 - package/lib/module/handlers/gestures/GestureDetector/utils.js +7 -7
 - package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
 - package/lib/module/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
 - package/lib/module/useIsomorphicLayoutEffect.js +15 -0
 - package/lib/module/useIsomorphicLayoutEffect.js.map +1 -0
 - package/lib/typescript/components/GestureHandlerRootView.android.d.ts +2 -2
 - package/lib/typescript/components/GestureHandlerRootView.android.d.ts.map +1 -1
 - package/lib/typescript/components/GestureHandlerRootView.d.ts +2 -2
 - package/lib/typescript/components/GestureHandlerRootView.d.ts.map +1 -1
 - package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
 - package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
 - package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts.map +1 -1
 - package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +4 -4
 - package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
 - package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +3 -2
 - package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts.map +1 -1
 - package/lib/typescript/useIsomorphicLayoutEffect.d.ts +3 -0
 - package/lib/typescript/useIsomorphicLayoutEffect.d.ts.map +1 -0
 - package/package.json +1 -1
 - package/src/components/GestureHandlerRootView.android.tsx +3 -2
 - package/src/components/GestureHandlerRootView.tsx +3 -2
 - package/src/components/Pressable/Pressable.tsx +4 -1
 - package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +12 -3
 - package/src/handlers/gestures/GestureDetector/index.tsx +3 -8
 - package/src/handlers/gestures/GestureDetector/utils.ts +14 -8
 - package/src/specs/RNGestureHandlerRootViewNativeComponent.ts +6 -2
 - package/src/useIsomorphicLayoutEffect.tsx +19 -0
 
| 
         @@ -1,4 +1,10 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import { 
     | 
| 
      
 1 
     | 
    
         
            +
            import {
         
     | 
| 
      
 2 
     | 
    
         
            +
              useMemo,
         
     | 
| 
      
 3 
     | 
    
         
            +
              useCallback,
         
     | 
| 
      
 4 
     | 
    
         
            +
              useImperativeHandle,
         
     | 
| 
      
 5 
     | 
    
         
            +
              ForwardedRef,
         
     | 
| 
      
 6 
     | 
    
         
            +
              useState,
         
     | 
| 
      
 7 
     | 
    
         
            +
            } from 'react';
         
     | 
| 
       2 
8 
     | 
    
         
             
            import { LayoutChangeEvent, View, I18nManager, StyleSheet } from 'react-native';
         
     | 
| 
       3 
9 
     | 
    
         
             
            import Animated, {
         
     | 
| 
       4 
10 
     | 
    
         
             
              useSharedValue,
         
     | 
| 
         @@ -82,6 +88,7 @@ const Swipeable = (props: SwipeableProps) => { 
     | 
|
| 
       82 
88 
     | 
    
         
             
                ]
         
     | 
| 
       83 
89 
     | 
    
         
             
              );
         
     | 
| 
       84 
90 
     | 
    
         | 
| 
      
 91 
     | 
    
         
            +
              const [shouldEnableTap, setShouldEnableTap] = useState(false);
         
     | 
| 
       85 
92 
     | 
    
         
             
              const rowState = useSharedValue<number>(0);
         
     | 
| 
       86 
93 
     | 
    
         | 
| 
       87 
94 
     | 
    
         
             
              const userDrag = useSharedValue<number>(0);
         
     | 
| 
         @@ -255,6 +262,8 @@ const Swipeable = (props: SwipeableProps) => { 
     | 
|
| 
       255 
262 
     | 
    
         
             
                  dispatchImmediateEvents(frozenRowState, toValue);
         
     | 
| 
       256 
263 
     | 
    
         | 
| 
       257 
264 
     | 
    
         
             
                  rowState.value = Math.sign(toValue);
         
     | 
| 
      
 265 
     | 
    
         
            +
             
     | 
| 
      
 266 
     | 
    
         
            +
                  runOnJS(setShouldEnableTap)(rowState.value !== 0);
         
     | 
| 
       258 
267 
     | 
    
         
             
                },
         
     | 
| 
       259 
268 
     | 
    
         
             
                [
         
     | 
| 
       260 
269 
     | 
    
         
             
                  rowState,
         
     | 
| 
         @@ -472,6 +481,7 @@ const Swipeable = (props: SwipeableProps) => { 
     | 
|
| 
       472 
481 
     | 
    
         
             
              const tapGesture = useMemo(() => {
         
     | 
| 
       473 
482 
     | 
    
         
             
                const tap = Gesture.Tap()
         
     | 
| 
       474 
483 
     | 
    
         
             
                  .shouldCancelWhenOutside(true)
         
     | 
| 
      
 484 
     | 
    
         
            +
                  .enabled(shouldEnableTap)
         
     | 
| 
       475 
485 
     | 
    
         
             
                  .onStart(() => {
         
     | 
| 
       476 
486 
     | 
    
         
             
                    if (rowState.value !== 0) {
         
     | 
| 
       477 
487 
     | 
    
         
             
                      close();
         
     | 
| 
         @@ -485,9 +495,8 @@ const Swipeable = (props: SwipeableProps) => { 
     | 
|
| 
       485 
495 
     | 
    
         
             
                    relation as RelationPropType
         
     | 
| 
       486 
496 
     | 
    
         
             
                  );
         
     | 
| 
       487 
497 
     | 
    
         
             
                });
         
     | 
| 
       488 
     | 
    
         
            -
             
     | 
| 
       489 
498 
     | 
    
         
             
                return tap;
         
     | 
| 
       490 
     | 
    
         
            -
              }, [close, relationProps, rowState]);
         
     | 
| 
      
 499 
     | 
    
         
            +
              }, [close, relationProps, rowState, shouldEnableTap]);
         
     | 
| 
       491 
500 
     | 
    
         | 
| 
       492 
501 
     | 
    
         
             
              const panGesture = useMemo(() => {
         
     | 
| 
       493 
502 
     | 
    
         
             
                const pan = Gesture.Pan()
         
     | 
| 
         @@ -1,11 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            /* eslint-disable react/no-unused-prop-types */
         
     | 
| 
       2 
     | 
    
         
            -
            import React, {
         
     | 
| 
       3 
     | 
    
         
            -
              useContext,
         
     | 
| 
       4 
     | 
    
         
            -
              useEffect,
         
     | 
| 
       5 
     | 
    
         
            -
              useLayoutEffect,
         
     | 
| 
       6 
     | 
    
         
            -
              useMemo,
         
     | 
| 
       7 
     | 
    
         
            -
              useRef,
         
     | 
| 
       8 
     | 
    
         
            -
            } from 'react';
         
     | 
| 
      
 2 
     | 
    
         
            +
            import React, { useContext, useEffect, useMemo, useRef } from 'react';
         
     | 
| 
       9 
3 
     | 
    
         
             
            import { Platform } from 'react-native';
         
     | 
| 
       10 
4 
     | 
    
         
             
            import findNodeHandle from '../../../findNodeHandle';
         
     | 
| 
       11 
5 
     | 
    
         
             
            import { GestureType } from '../gesture';
         
     | 
| 
         @@ -24,6 +18,7 @@ import { Wrap, AnimatedWrap } from './Wrap'; 
     | 
|
| 
       24 
18 
     | 
    
         
             
            import { useDetectorUpdater } from './useDetectorUpdater';
         
     | 
| 
       25 
19 
     | 
    
         
             
            import { useViewRefHandler } from './useViewRefHandler';
         
     | 
| 
       26 
20 
     | 
    
         
             
            import { useMountReactions } from './useMountReactions';
         
     | 
| 
      
 21 
     | 
    
         
            +
            import { useIsomorphicLayoutEffect } from '../../../useIsomorphicLayoutEffect';
         
     | 
| 
       27 
22 
     | 
    
         | 
| 
       28 
23 
     | 
    
         
             
            function propagateDetectorConfig(
         
     | 
| 
       29 
24 
     | 
    
         
             
              props: GestureDetectorProps,
         
     | 
| 
         @@ -149,7 +144,7 @@ export const GestureDetector = (props: GestureDetectorProps) => { 
     | 
|
| 
       149 
144 
     | 
    
         | 
| 
       150 
145 
     | 
    
         
             
              useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
         
     | 
| 
       151 
146 
     | 
    
         | 
| 
       152 
     | 
    
         
            -
               
     | 
| 
      
 147 
     | 
    
         
            +
              useIsomorphicLayoutEffect(() => {
         
     | 
| 
       153 
148 
     | 
    
         
             
                const viewTag = findNodeHandle(state.viewRef) as number;
         
     | 
| 
       154 
149 
     | 
    
         
             
                preparedGesture.isMounted = true;
         
     | 
| 
       155 
150 
     | 
    
         | 
| 
         @@ -49,22 +49,28 @@ function convertToHandlerTag(ref: GestureRef): number { 
     | 
|
| 
       49 
49 
     | 
    
         
             
            }
         
     | 
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
            function extractValidHandlerTags(interactionGroup: GestureRef[] | undefined) {
         
     | 
| 
       52 
     | 
    
         
            -
              return (
         
     | 
| 
       53 
     | 
    
         
            -
                 
     | 
| 
      
 52 
     | 
    
         
            +
              return Array.from(
         
     | 
| 
      
 53 
     | 
    
         
            +
                new Set(
         
     | 
| 
      
 54 
     | 
    
         
            +
                  interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []
         
     | 
| 
      
 55 
     | 
    
         
            +
                )
         
     | 
| 
       54 
56 
     | 
    
         
             
              );
         
     | 
| 
       55 
57 
     | 
    
         
             
            }
         
     | 
| 
       56 
58 
     | 
    
         | 
| 
       57 
59 
     | 
    
         
             
            export function extractGestureRelations(gesture: GestureType) {
         
     | 
| 
       58 
     | 
    
         
            -
               
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 60 
     | 
    
         
            +
              gesture.config.requireToFail = extractValidHandlerTags(
         
     | 
| 
      
 61 
     | 
    
         
            +
                gesture.config.requireToFail
         
     | 
| 
      
 62 
     | 
    
         
            +
              );
         
     | 
| 
      
 63 
     | 
    
         
            +
              gesture.config.simultaneousWith = extractValidHandlerTags(
         
     | 
| 
       60 
64 
     | 
    
         
             
                gesture.config.simultaneousWith
         
     | 
| 
       61 
65 
     | 
    
         
             
              );
         
     | 
| 
       62 
     | 
    
         
            -
               
     | 
| 
      
 66 
     | 
    
         
            +
              gesture.config.blocksHandlers = extractValidHandlerTags(
         
     | 
| 
      
 67 
     | 
    
         
            +
                gesture.config.blocksHandlers
         
     | 
| 
      
 68 
     | 
    
         
            +
              );
         
     | 
| 
       63 
69 
     | 
    
         | 
| 
       64 
70 
     | 
    
         
             
              return {
         
     | 
| 
       65 
     | 
    
         
            -
                waitFor: requireToFail,
         
     | 
| 
       66 
     | 
    
         
            -
                simultaneousHandlers: simultaneousWith,
         
     | 
| 
       67 
     | 
    
         
            -
                blocksHandlers: blocksHandlers,
         
     | 
| 
      
 71 
     | 
    
         
            +
                waitFor: gesture.config.requireToFail,
         
     | 
| 
      
 72 
     | 
    
         
            +
                simultaneousHandlers: gesture.config.simultaneousWith,
         
     | 
| 
      
 73 
     | 
    
         
            +
                blocksHandlers: gesture.config.blocksHandlers,
         
     | 
| 
       68 
74 
     | 
    
         
             
              };
         
     | 
| 
       69 
75 
     | 
    
         
             
            }
         
     | 
| 
       70 
76 
     | 
    
         | 
| 
         @@ -1,6 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
         
     | 
| 
       2 
2 
     | 
    
         
             
            import type { ViewProps } from 'react-native';
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            interface  
     | 
| 
      
 4 
     | 
    
         
            +
            export interface RootViewNativeProps extends ViewProps {
         
     | 
| 
      
 5 
     | 
    
         
            +
              unstable_forceActive?: boolean;
         
     | 
| 
      
 6 
     | 
    
         
            +
            }
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            export default codegenNativeComponent< 
     | 
| 
      
 8 
     | 
    
         
            +
            export default codegenNativeComponent<RootViewNativeProps>(
         
     | 
| 
      
 9 
     | 
    
         
            +
              'RNGestureHandlerRootView'
         
     | 
| 
      
 10 
     | 
    
         
            +
            );
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import React from 'react';
         
     | 
| 
      
 2 
     | 
    
         
            +
            // code below is modified version of the code found in:
         
     | 
| 
      
 3 
     | 
    
         
            +
            // https://github.com/reduxjs/react-redux/blob/7e2fdd4ee2021e4282e12ba9fc722f09124e30cd/src/utils/useIsomorphicLayoutEffect.ts#L36
         
     | 
| 
      
 4 
     | 
    
         
            +
            // React currently throws a warning when using useLayoutEffect on the server.
         
     | 
| 
      
 5 
     | 
    
         
            +
            // To get around it, we can conditionally useEffect on the server (no-op) and
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            // useLayoutEffect in the browser.
         
     | 
| 
      
 8 
     | 
    
         
            +
            const isDOM = !!(
         
     | 
| 
      
 9 
     | 
    
         
            +
              typeof window !== 'undefined' &&
         
     | 
| 
      
 10 
     | 
    
         
            +
              typeof window.document !== 'undefined' &&
         
     | 
| 
      
 11 
     | 
    
         
            +
              typeof window.document.createElement !== 'undefined'
         
     | 
| 
      
 12 
     | 
    
         
            +
            );
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            // Under React Native, we know that we always want to use useLayoutEffect
         
     | 
| 
      
 15 
     | 
    
         
            +
            const isReactNative =
         
     | 
| 
      
 16 
     | 
    
         
            +
              typeof navigator !== 'undefined' && navigator.product === 'ReactNative';
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            export const useIsomorphicLayoutEffect =
         
     | 
| 
      
 19 
     | 
    
         
            +
              isDOM || isReactNative ? React.useLayoutEffect : React.useEffect;
         
     |