From 16079d10506eb4bfa8abdce8449932676db7c4da Mon Sep 17 00:00:00 2001 From: "satyajit.happy" Date: Sun, 6 Oct 2019 04:17:49 +0200 Subject: [PATCH] fix: actually expose gestureVelocityImpact in the public API --- packages/stack/src/types.tsx | 5 +++++ packages/stack/src/views/Stack/Card.tsx | 4 ++-- packages/stack/src/views/Stack/Stack.tsx | 4 +++- packages/stack/src/views/Stack/StackItem.tsx | 12 ++++++------ 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/stack/src/types.tsx b/packages/stack/src/types.tsx index 54f15dfc..8d0cbbbb 100644 --- a/packages/stack/src/types.tsx +++ b/packages/stack/src/types.tsx @@ -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 = { diff --git a/packages/stack/src/views/Stack/Card.tsx b/packages/stack/src/views/Stack/Card.tsx index b08f93a8..0e38e98f 100755 --- a/packages/stack/src/views/Stack/Card.tsx +++ b/packages/stack/src/views/Stack/Card.tsx @@ -50,12 +50,12 @@ type Props = ViewProps & { vertical?: number; horizontal?: number; }; + gestureVelocityImpact: number; transitionSpec: { open: TransitionSpec; close: TransitionSpec; }; styleInterpolator: StackCardStyleInterpolator; - gestureVelocityImpact: number; containerStyle?: StyleProp; contentStyle?: StyleProp; }; @@ -238,8 +238,8 @@ export default class Card extends React.Component { const { layout, gestureDirection, - closing, gestureVelocityImpact, + closing, } = this.props; const { width, height } = layout; diff --git a/packages/stack/src/views/Stack/Stack.tsx b/packages/stack/src/views/Stack/Stack.tsx index 89944170..68586b9c 100755 --- a/packages/stack/src/views/Stack/Stack.tsx +++ b/packages/stack/src/views/Stack/Stack.tsx @@ -360,6 +360,7 @@ export default class Stack extends React.Component { cardOverlayEnabled, cardStyle, gestureResponseDistance, + gestureVelocityImpact, gestureDirection = defaultTransitionPreset.gestureDirection, transitionSpec = defaultTransitionPreset.transitionSpec, cardStyleInterpolator = defaultTransitionPreset.cardStyleInterpolator, @@ -424,7 +425,6 @@ export default class Stack extends React.Component { cardOverlayEnabled={cardOverlayEnabled} cardShadowEnabled={cardShadowEnabled} cardStyle={cardStyle} - gestureEnabled={index !== 0 && getGesturesEnabled({ route })} onPageChangeStart={onPageChangeStart} onPageChangeConfirm={onPageChangeConfirm} onPageChangeCancel={onPageChangeCancel} @@ -441,6 +441,8 @@ export default class Stack extends React.Component { onTransitionStart={this.handleTransitionStart} onTransitionEnd={this.handleTransitionEnd} onGoBack={onGoBack} + gestureEnabled={index !== 0 && getGesturesEnabled({ route })} + gestureVelocityImpact={gestureVelocityImpact} gestureDirection={gestureDirection} {...transitionConfig} /> diff --git a/packages/stack/src/views/Stack/StackItem.tsx b/packages/stack/src/views/Stack/StackItem.tsx index 230ea4a2..218bfbd1 100644 --- a/packages/stack/src/views/Stack/StackItem.tsx +++ b/packages/stack/src/views/Stack/StackItem.tsx @@ -30,7 +30,6 @@ type Props = TransitionPreset & { cardOverlayEnabled?: boolean; cardShadowEnabled?: boolean; cardStyle?: StyleProp; - gestureEnabled?: boolean; getPreviousRoute: (props: { route: Route; }) => Route | undefined; @@ -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 { @@ -108,10 +108,11 @@ export default class StackItem extends React.PureComponent { cardOverlayEnabled, cardShadowEnabled, cardStyle, - gestureEnabled, onPageChangeStart, onPageChangeCancel, + gestureEnabled, gestureResponseDistance, + gestureVelocityImpact, floatingHeaderHeight, hasCustomHeader, getPreviousRoute, @@ -123,7 +124,6 @@ export default class StackItem extends React.PureComponent { transitionSpec, cardStyleInterpolator, headerStyleInterpolator, - gestureVelocityImpact, } = this.props; return ( @@ -141,11 +141,12 @@ export default class StackItem extends React.PureComponent { 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} @@ -158,7 +159,6 @@ export default class StackItem extends React.PureComponent { } contentStyle={cardStyle} style={StyleSheet.absoluteFill} - gestureVelocityImpact={gestureVelocityImpact} >