Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type Props = {
renderScene: NavigationSceneRenderer,
cardStyle?: any,
style: any,
gestureResponseDistance?: ?number,
};

type DefaultProps = {
Expand Down Expand Up @@ -95,6 +96,7 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
renderOverlay: PropTypes.func,
renderScene: PropTypes.func.isRequired,
cardStyle: View.propTypes.style,
gestureResponseDistance: PropTypes.number,
};

static defaultProps: DefaultProps = {
Expand Down Expand Up @@ -164,6 +166,7 @@ class NavigationCardStack extends React.Component<DefaultProps, Props, void> {
const panHandlersProps = {
...props,
onNavigateBack: this.props.onNavigateBack,
gestureResponseDistance: this.props.gestureResponseDistance,
};

Choose a reason for hiding this comment

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

please also update static propTypes = {

const panHandlers = isVertical ?
NavigationCardStackPanResponder.forVertical(panHandlersProps) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ const POSITION_THRESHOLD = 1 / 3;
*/
const RESPOND_THRESHOLD = 15;

/**
* The distance from the edge of the navigator which gesture response can start for.
* For horizontal scroll views, a distance of 30 from the left of the screen is the
* standard maximum position to start touch responsiveness.
*/
const RESPOND_POSITION_MAX_HORIZONTAL = 30;
const RESPOND_POSITION_MAX_VERTICAL = null;

/**
* The threshold (in pixels) to finish the gesture action.
*/
Expand All @@ -64,6 +56,10 @@ export type NavigationGestureDirection = 'horizontal' | 'vertical';

type Props = NavigationSceneRendererProps & {
onNavigateBack: ?Function,
/**
* The distance from the edge of the navigator which gesture response can start for.
**/
gestureResponseDistance: ?number,
};

/**
Expand Down Expand Up @@ -115,8 +111,12 @@ class NavigationCardStackPanResponder extends NavigationAbstractPanResponder {
layout.width.__getValue();

const positionMax = isVertical ?
RESPOND_POSITION_MAX_VERTICAL :
RESPOND_POSITION_MAX_HORIZONTAL;
props.gestureResponseDistance :
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm wondering if we should or not add a default value for gestureResponseDistance with vertical direction

/**
* For horizontal scroll views, a distance of 30 from the left of the screen is the
* standard maximum position to start touch responsiveness.
*/
props.gestureResponseDistance || 30;

if (positionMax != null && currentDragPosition > positionMax) {
return false;
Expand Down
3 changes: 3 additions & 0 deletions Libraries/NavigationExperimental/NavigationTypeDefinition.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export type NavigationTransitionProps = {
// The active scene, corresponding to the route at
// `navigationState.routes[navigationState.index]`.
scene: NavigationScene,

// The gesture distance for `horizontal` and `vertical` transitions
gestureResponseDistance?: ?number,
};

// Similar to `NavigationTransitionProps`, except that the prop `scene`
Expand Down