@@ -26,7 +26,7 @@ type Props = ViewProps & {
2626 next ?: Animated . Node < number > ;
2727 current : Animated . Value < number > ;
2828 layout : Layout ;
29- gestureDirection : 'horizontal' | 'vertical' ;
29+ gestureDirection : 'horizontal' | 'vertical' | 'vertical-inverted' ;
3030 onOpen : ( isFinished : boolean ) => void ;
3131 onClose : ( isFinished : boolean ) => void ;
3232 onTransitionStart ?: ( props : { closing : boolean } ) => void ;
@@ -56,6 +56,8 @@ const TRUE = 1;
5656const FALSE = 0 ;
5757const NOOP = 0 ;
5858const UNSET = - 1 ;
59+ const TOP = - 1 ;
60+ const BOTTOM = 1 ;
5961
6062const DIRECTION_VERTICAL = - 1 ;
6163const DIRECTION_HORIZONTAL = 1 ;
@@ -115,10 +117,14 @@ export default class Card extends React.Component<Props> {
115117
116118 if ( gestureDirection !== prevProps . gestureDirection ) {
117119 this . direction . setValue (
118- gestureDirection === 'vertical'
120+ gestureDirection === 'vertical' ||
121+ gestureDirection === 'vertical-inverted'
119122 ? DIRECTION_VERTICAL
120123 : DIRECTION_HORIZONTAL
121124 ) ;
125+ this . verticalGestureDirection . setValue (
126+ gestureDirection === 'vertical-inverted' ? TOP : BOTTOM
127+ ) ;
122128 }
123129
124130 if ( closing !== prevProps . closing ) {
@@ -129,6 +135,9 @@ export default class Card extends React.Component<Props> {
129135 private isVisible = new Value < Binary > ( TRUE ) ;
130136 private isVisibleValue : Binary = TRUE ;
131137 private nextIsVisible = new Value < Binary | - 1 > ( UNSET ) ;
138+ private verticalGestureDirection = new Value (
139+ this . props . gestureDirection === 'vertical-inverted' ? TOP : BOTTOM
140+ ) ;
132141
133142 private isClosing = new Value < Binary > ( FALSE ) ;
134143 private noAnimationStartedSoFar = true ;
@@ -137,7 +146,8 @@ export default class Card extends React.Component<Props> {
137146 private clock = new Clock ( ) ;
138147
139148 private direction = new Value (
140- this . props . gestureDirection === 'vertical'
149+ this . props . gestureDirection === 'vertical' ||
150+ this . props . gestureDirection === 'vertical-inverted'
141151 ? DIRECTION_VERTICAL
142152 : DIRECTION_HORIZONTAL
143153 ) ;
@@ -370,9 +380,9 @@ export default class Card extends React.Component<Props> {
370380 private handleGestureEventHorizontal = Animated . event ( [
371381 {
372382 nativeEvent : {
373- translationX : ( x : Animated . Adaptable < number > ) =>
383+ translationX : ( x : Animated . Node < number > ) =>
374384 set ( this . gesture , multiply ( x , I18nManager . isRTL ? - 1 : 1 ) ) ,
375- velocityX : ( x : Animated . Adaptable < number > ) =>
385+ velocityX : ( x : Animated . Node < number > ) =>
376386 set ( this . velocity , multiply ( x , I18nManager . isRTL ? - 1 : 1 ) ) ,
377387 state : this . gestureState ,
378388 } ,
@@ -382,8 +392,10 @@ export default class Card extends React.Component<Props> {
382392 private handleGestureEventVertical = Animated . event ( [
383393 {
384394 nativeEvent : {
385- translationY : this . gesture ,
386- velocityY : this . velocity ,
395+ translationY : ( y : Animated . Node < number > ) =>
396+ set ( this . gesture , multiply ( y , this . verticalGestureDirection ) ) ,
397+ velocityY : ( y : Animated . Node < number > ) =>
398+ set ( this . velocity , multiply ( y , this . verticalGestureDirection ) ) ,
387399 state : this . gestureState ,
388400 } ,
389401 } ,
@@ -431,7 +443,8 @@ export default class Card extends React.Component<Props> {
431443
432444 // Doesn't make sense for a response distance of 0, so this works fine
433445 const distance =
434- gestureDirection === 'vertical'
446+ gestureDirection === 'vertical' ||
447+ gestureDirection === 'vertical-inverted'
435448 ? ( gestureResponseDistance && gestureResponseDistance . vertical ) ||
436449 GESTURE_RESPONSE_DISTANCE_VERTICAL
437450 : ( gestureResponseDistance && gestureResponseDistance . horizontal ) ||
@@ -443,6 +456,12 @@ export default class Card extends React.Component<Props> {
443456 minOffsetY : 5 ,
444457 hitSlop : { bottom : - layout . height + distance } ,
445458 } ;
459+ } else if ( gestureDirection === 'vertical-inverted' ) {
460+ return {
461+ maxDeltaX : 15 ,
462+ minOffsetY : - 5 ,
463+ hitSlop : { top : - layout . height + distance } ,
464+ } ;
446465 } else {
447466 const hitSlop = - layout . width + distance ;
448467
@@ -497,7 +516,8 @@ export default class Card extends React.Component<Props> {
497516 ) ;
498517
499518 const handleGestureEvent =
500- gestureDirection === 'vertical'
519+ gestureDirection === 'vertical' ||
520+ gestureDirection === 'vertical-inverted'
501521 ? this . handleGestureEventVertical
502522 : this . handleGestureEventHorizontal ;
503523
0 commit comments