Skip to content

Commit

Permalink
Merge pull request #1 from ChefSteps/enable-gestures-from-props
Browse files Browse the repository at this point in the history
Enable gestures from props
  • Loading branch information
coffeeexistence authored Nov 6, 2017
2 parents ffb95fd + cb0dae3 commit 0d467ab
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/views/CardStack/CardStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import TransitionConfigs from './TransitionConfigs';
const emptyFunction = () => {};

type Props = {
globalGesturesEnabled?: boolean,
screenProps?: {},
headerMode: HeaderMode,
headerComponent?: React.ComponentType<*>,
Expand Down Expand Up @@ -69,7 +70,7 @@ type Props = {

/**
* The max duration of the card animation in milliseconds after released gesture.
* The actual duration should be always less then that because the rest distance
* The actual duration should be always less then that because the rest distance
* is always less then the full distance of the layout.
*/
const ANIMATION_DURATION = 500;
Expand Down Expand Up @@ -102,6 +103,9 @@ 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 @@ -354,10 +358,11 @@ class CardStack extends React.Component<Props> {
});

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

const gesturesEnabled =
typeof options.gesturesEnabled === 'boolean'
? options.gesturesEnabled
: Platform.OS === 'ios';
this.props.globalGesturesEnabled && screenGesturesEnabled;

const handlers = gesturesEnabled ? responder.panHandlers : {};
const containerStyle = [
Expand Down

0 comments on commit 0d467ab

Please sign in to comment.