Skip to content

Commit 979ee4a

Browse files
Merge pull request #2 from ChefSteps/enable-gestures-from-props
Add ability to set gesturesEnabled within same route.
2 parents 0d467ab + 024cda9 commit 979ee4a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/views/CardStack/CardStack.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ const animatedSubscribeValue = (animatedValue: Animated.Value) => {
103103
};
104104

105105
class CardStack extends React.Component<Props> {
106-
static defaultProps = {
107-
globalGesturesEnabled: Platform.OS === 'ios',
108-
};
109106
/**
110107
* Used to identify the starting point of the position when the gesture starts, such that it can
111108
* be updated according to its relative position. This means that a card can effectively be
@@ -260,6 +257,11 @@ class CardStack extends React.Component<Props> {
260257
if (index !== scene.index) {
261258
return false;
262259
}
260+
// $FlowFixMe
261+
const { getIsBackNavigationEnabled } = this.props.navigation;
262+
if (typeof getIsBackNavigationEnabled === 'function') {
263+
if (!getIsBackNavigationEnabled()) return false;
264+
}
263265
const immediateIndex =
264266
this._immediateIndex == null ? index : this._immediateIndex;
265267
const currentDragDistance = gesture[isVertical ? 'dy' : 'dx'];
@@ -358,13 +360,12 @@ class CardStack extends React.Component<Props> {
358360
});
359361

360362
const { options } = this._getScreenDetails(scene);
361-
const screenGesturesEnabled =
362-
typeof options.gesturesEnabled === 'boolean' && options.gesturesEnabled;
363363

364364
const gesturesEnabled =
365-
this.props.globalGesturesEnabled && screenGesturesEnabled;
365+
typeof options.gesturesEnabled === 'boolean' && options.gesturesEnabled;
366366

367-
const handlers = gesturesEnabled ? responder.panHandlers : {};
367+
const handlers =
368+
gesturesEnabled && Platform.OS === 'ios' ? responder.panHandlers : {};
368369
const containerStyle = [
369370
styles.container,
370371
this._getTransitionConfig().containerStyle,

0 commit comments

Comments
 (0)