Skip to content

Commit

Permalink
Merge pull request #2 from ChefSteps/enable-gestures-from-props
Browse files Browse the repository at this point in the history
Add ability to set gesturesEnabled within same route.
  • Loading branch information
coffeeexistence authored Nov 8, 2017
2 parents 0d467ab + 024cda9 commit 979ee4a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/views/CardStack/CardStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ const animatedSubscribeValue = (animatedValue: Animated.Value) => {
};

class CardStack extends React.Component<Props> {
static defaultProps = {
globalGesturesEnabled: Platform.OS === 'ios',
};
/**
* Used to identify the starting point of the position when the gesture starts, such that it can
* be updated according to its relative position. This means that a card can effectively be
Expand Down Expand Up @@ -260,6 +257,11 @@ class CardStack extends React.Component<Props> {
if (index !== scene.index) {
return false;
}
// $FlowFixMe
const { getIsBackNavigationEnabled } = this.props.navigation;
if (typeof getIsBackNavigationEnabled === 'function') {
if (!getIsBackNavigationEnabled()) return false;
}
const immediateIndex =
this._immediateIndex == null ? index : this._immediateIndex;
const currentDragDistance = gesture[isVertical ? 'dy' : 'dx'];
Expand Down Expand Up @@ -358,13 +360,12 @@ class CardStack extends React.Component<Props> {
});

const { options } = this._getScreenDetails(scene);
const screenGesturesEnabled =
typeof options.gesturesEnabled === 'boolean' && options.gesturesEnabled;

const gesturesEnabled =
this.props.globalGesturesEnabled && screenGesturesEnabled;
typeof options.gesturesEnabled === 'boolean' && options.gesturesEnabled;

const handlers = gesturesEnabled ? responder.panHandlers : {};
const handlers =
gesturesEnabled && Platform.OS === 'ios' ? responder.panHandlers : {};
const containerStyle = [
styles.container,
this._getTransitionConfig().containerStyle,
Expand Down

0 comments on commit 979ee4a

Please sign in to comment.