Skip to content

Fix: Navigation gesture gestureResponseDistance failure #1016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

kazhoang
Copy link

@kazhoang kazhoang commented Aug 1, 2025

Summary

#Before

Screen.Recording.2025-08-01.at.14.49.12.mov

#After

Screen.Recording.2025-08-01.at.14.47.45.mov

Test Plan

"react-native": "0.79.5" (New Architect)
"react-native-pager-view": "^6.8.1"
"@react-navigation/native": "^7.1.16",
"@react-navigation/native-stack": "^7.3.23",

Set screen options:

<RootStack.Screen
        name="SecurityUpdate"
        component={SecurityUpdateScreen}
        options={{
          fullScreenGestureEnabled: true,
          gestureResponseDistance: {
            start: 0,
            end: Constants.deviceWidth
          }
       }}
/>

then in the screen:

return (
    <PagerView style={{ flex: 1 }} initialPage={0}>
      <View key="1" style={{ backgroundColor: 'pink', flex: 1 }}>
        <Text>First page</Text>
      </View>
      <View key="2" style={{ backgroundColor: 'green', flex: 1 }}>
        <Text>Second page</Text>
      </View>
    </PagerView>
)

What's required for testing (prerequisites)?

What are the steps to reproduce (after prerequisites)?

Compatibility

OS Implemented
iOS
Android

Checklist

  • I have tested this on a device and a simulator
  • I added the documentation in README.md
  • I updated the typed files (TS and Flow)

@troZee
Copy link
Member

troZee commented Aug 1, 2025

@kazhoang could you resolve the conflicts 🙏 ?

@troZee troZee requested a review from Copilot August 2, 2025 19:28
Copilot

This comment was marked as outdated.

@kazhoang kazhoang requested a review from troZee August 6, 2025 06:59
@troZee troZee requested review from Copilot and krozniata August 6, 2025 07:00
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a navigation gesture issue in PagerView where iOS fullscreen swipe-back gestures fail when using React Navigation's native stack with gestureResponseDistance. The fix allows navigation gestures to work properly when the pager is at index 0.

Key changes:

  • Added allowNavFullscreenGesture prop to enable navigation gesture passthrough
  • Implemented gesture recognition logic to handle conflicts between pager and navigation gestures
  • Added comprehensive gesture state management for iOS

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/PagerViewNativeComponent.ts Added TypeScript interface for new allowNavFullscreenGesture prop
ios/RNCPagerViewComponentView.mm Implemented core gesture handling logic with UIGestureRecognizerDelegate
android/src/main/java/com/reactnativepagerview/PagerViewViewManager.kt Added stub implementation for Android compatibility
README.md Added documentation for the new prop
Comments suppressed due to low confidence (1)

ios/RNCPagerViewComponentView.mm:103

  • The variable name 'p' is too short and ambiguous. Consider renaming it to 'panGestureRecognizer' or 'panGesture' for better readability.
        UIPanGestureRecognizer* p = (UIPanGestureRecognizer*) gestureRecognizer;

@troZee troZee requested a review from MrRefactor August 6, 2025 07:01
Copy link
Member

@troZee troZee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kazhoang
Thank you for addressing all our feedback. Let's wait for more feedback from other devs. I will try to find time this week to check it.

Once everything is in order, we will merge and release it.

@@ -173,6 +205,22 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props oldProps:(cons
_overdrag = newScreenProps.overdrag;
}

if (newScreenProps.allowNavFullscreenGesture != _allowNavFullscreenGesture) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should check previous screen properties in here. Same as other props

@@ -173,6 +205,22 @@ - (void)updateProps:(const facebook::react::Props::Shared &)props oldProps:(cons
_overdrag = newScreenProps.overdrag;
}

if (newScreenProps.allowNavFullscreenGesture != _allowNavFullscreenGesture) {
_allowNavFullscreenGesture = newScreenProps.allowNavFullscreenGesture;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also don't need to store this as it's stored in _props.allowNavFullscreenGesture for us.

Copy link
Author

@kazhoang kazhoang Aug 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@okwasniewski
I’m encountering issues with oldScreenProps.allowNavFullscreenGesture due to the recycling process while re-enter the pager-view. (It keeps the old properties)
This is why I’m using an additional local property to control it
(as otherwise, it skips attaching the navGestureRecognizer since it’s already been cleaned up)

screenshot_1754629457

…ure for clarity and consistency and remove unnecessary properties
@kazhoang kazhoang requested a review from okwasniewski August 8, 2025 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants