diff --git a/packages/stack/src/views/Stack/Card.tsx b/packages/stack/src/views/Stack/Card.tsx index b71a1e55609580..b08f93a8bc4655 100755 --- a/packages/stack/src/views/Stack/Card.tsx +++ b/packages/stack/src/views/Stack/Card.tsx @@ -55,6 +55,7 @@ type Props = ViewProps & { close: TransitionSpec; }; styleInterpolator: StackCardStyleInterpolator; + gestureVelocityImpact: number; containerStyle?: StyleProp; contentStyle?: StyleProp; }; @@ -88,7 +89,7 @@ const MINUS_ONE_NODE = UNSET_NODE; const DIRECTION_VERTICAL = -1; const DIRECTION_HORIZONTAL = 1; -const SWIPE_VELOCITY_IMPACT = 0.3; +const GESTURE_VELOCITY_IMPACT = 0.3; /** * The distance of touch start from the edge of the screen where the gesture will be recognized @@ -230,10 +231,16 @@ export default class Card extends React.Component { overlayEnabled: Platform.OS !== 'ios', shadowEnabled: true, gestureEnabled: true, + gestureVelocityImpact: GESTURE_VELOCITY_IMPACT, }; componentDidUpdate(prevProps: Props) { - const { layout, gestureDirection, closing } = this.props; + const { + layout, + gestureDirection, + closing, + gestureVelocityImpact, + } = this.props; const { width, height } = layout; if (width !== prevProps.layout.width) { @@ -244,6 +251,10 @@ export default class Card extends React.Component { this.layout.height.setValue(height); } + if (gestureVelocityImpact !== prevProps.gestureVelocityImpact) { + this.gestureVelocityImpact.setValue(gestureVelocityImpact); + } + if (gestureDirection !== prevProps.gestureDirection) { this.direction.setValue( gestureDirection === 'vertical' @@ -279,6 +290,9 @@ export default class Card extends React.Component { } private isVisible = new Value(TRUE); + private gestureVelocityImpact = new Value( + this.props.gestureVelocityImpact + ); private isVisibleValue: Binary = TRUE; private nextIsVisible = new Value(UNSET); @@ -474,7 +488,7 @@ export default class Card extends React.Component { private extrapolatedPosition = add( this.gesture, - multiply(this.velocity, SWIPE_VELOCITY_IMPACT) + multiply(this.velocity, this.gestureVelocityImpact) ); private exec = [ diff --git a/packages/stack/src/views/Stack/StackItem.tsx b/packages/stack/src/views/Stack/StackItem.tsx index 510c816b729fc2..230ea4a22ad4d1 100644 --- a/packages/stack/src/views/Stack/StackItem.tsx +++ b/packages/stack/src/views/Stack/StackItem.tsx @@ -55,6 +55,7 @@ type Props = TransitionPreset & { headerTransparent?: boolean; floatingHeaderHeight: number; hasCustomHeader: boolean; + gestureVelocityImpact?: number; }; export default class StackItem extends React.PureComponent { @@ -122,6 +123,7 @@ export default class StackItem extends React.PureComponent { transitionSpec, cardStyleInterpolator, headerStyleInterpolator, + gestureVelocityImpact, } = this.props; return ( @@ -156,6 +158,7 @@ export default class StackItem extends React.PureComponent { } contentStyle={cardStyle} style={StyleSheet.absoluteFill} + gestureVelocityImpact={gestureVelocityImpact} >