Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

Commit

Permalink
fix: actually expose gestureVelocityImpact in the public API
Browse files Browse the repository at this point in the history
  • Loading branch information
satya164 committed Oct 6, 2019
1 parent b4a7681 commit 16079d1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions packages/stack/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ export type StackNavigationOptions = StackHeaderOptions &
*/
horizontal?: number;
};
/**
* Number which determines the relevance of velocity for the gesture.
* Defaults to 0.3.
*/
gestureVelocityImpact?: number;
};

export type StackNavigationConfig = {
Expand Down
4 changes: 2 additions & 2 deletions packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ type Props = ViewProps & {
vertical?: number;
horizontal?: number;
};
gestureVelocityImpact: number;
transitionSpec: {
open: TransitionSpec;
close: TransitionSpec;
};
styleInterpolator: StackCardStyleInterpolator;
gestureVelocityImpact: number;
containerStyle?: StyleProp<ViewStyle>;
contentStyle?: StyleProp<ViewStyle>;
};
Expand Down Expand Up @@ -238,8 +238,8 @@ export default class Card extends React.Component<Props> {
const {
layout,
gestureDirection,
closing,
gestureVelocityImpact,
closing,
} = this.props;
const { width, height } = layout;

Expand Down
4 changes: 3 additions & 1 deletion packages/stack/src/views/Stack/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export default class Stack extends React.Component<Props, State> {
cardOverlayEnabled,
cardStyle,
gestureResponseDistance,
gestureVelocityImpact,
gestureDirection = defaultTransitionPreset.gestureDirection,
transitionSpec = defaultTransitionPreset.transitionSpec,
cardStyleInterpolator = defaultTransitionPreset.cardStyleInterpolator,
Expand Down Expand Up @@ -424,7 +425,6 @@ export default class Stack extends React.Component<Props, State> {
cardOverlayEnabled={cardOverlayEnabled}
cardShadowEnabled={cardShadowEnabled}
cardStyle={cardStyle}
gestureEnabled={index !== 0 && getGesturesEnabled({ route })}
onPageChangeStart={onPageChangeStart}
onPageChangeConfirm={onPageChangeConfirm}
onPageChangeCancel={onPageChangeCancel}
Expand All @@ -441,6 +441,8 @@ export default class Stack extends React.Component<Props, State> {
onTransitionStart={this.handleTransitionStart}
onTransitionEnd={this.handleTransitionEnd}
onGoBack={onGoBack}
gestureEnabled={index !== 0 && getGesturesEnabled({ route })}
gestureVelocityImpact={gestureVelocityImpact}
gestureDirection={gestureDirection}
{...transitionConfig}
/>
Expand Down
12 changes: 6 additions & 6 deletions packages/stack/src/views/Stack/StackItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type Props = TransitionPreset & {
cardOverlayEnabled?: boolean;
cardShadowEnabled?: boolean;
cardStyle?: StyleProp<ViewStyle>;
gestureEnabled?: boolean;
getPreviousRoute: (props: {
route: Route<string>;
}) => Route<string> | undefined;
Expand All @@ -47,15 +46,16 @@ type Props = TransitionPreset & {
onPageChangeStart?: () => void;
onPageChangeConfirm?: () => void;
onPageChangeCancel?: () => void;
gestureEnabled?: boolean;
gestureResponseDistance?: {
vertical?: number;
horizontal?: number;
};
gestureVelocityImpact?: number;
headerMode: StackHeaderMode;
headerTransparent?: boolean;
floatingHeaderHeight: number;
hasCustomHeader: boolean;
gestureVelocityImpact?: number;
};

export default class StackItem extends React.PureComponent<Props> {
Expand Down Expand Up @@ -108,10 +108,11 @@ export default class StackItem extends React.PureComponent<Props> {
cardOverlayEnabled,
cardShadowEnabled,
cardStyle,
gestureEnabled,
onPageChangeStart,
onPageChangeCancel,
gestureEnabled,
gestureResponseDistance,
gestureVelocityImpact,
floatingHeaderHeight,
hasCustomHeader,
getPreviousRoute,
Expand All @@ -123,7 +124,6 @@ export default class StackItem extends React.PureComponent<Props> {
transitionSpec,
cardStyleInterpolator,
headerStyleInterpolator,
gestureVelocityImpact,
} = this.props;

return (
Expand All @@ -141,11 +141,12 @@ export default class StackItem extends React.PureComponent<Props> {
onClose={this.handleClose}
overlayEnabled={cardOverlayEnabled}
shadowEnabled={cardShadowEnabled}
gestureEnabled={gestureEnabled}
onTransitionStart={this.handleTransitionStart}
onGestureBegin={onPageChangeStart}
onGestureCanceled={onPageChangeCancel}
gestureEnabled={gestureEnabled}
gestureResponseDistance={gestureResponseDistance}
gestureVelocityImpact={gestureVelocityImpact}
transitionSpec={transitionSpec}
styleInterpolator={cardStyleInterpolator}
accessibilityElementsHidden={!focused}
Expand All @@ -158,7 +159,6 @@ export default class StackItem extends React.PureComponent<Props> {
}
contentStyle={cardStyle}
style={StyleSheet.absoluteFill}
gestureVelocityImpact={gestureVelocityImpact}
>
<View style={styles.container}>
<View style={styles.scene}>
Expand Down

0 comments on commit 16079d1

Please sign in to comment.