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

Commit 34f3c51

Browse files
authored
fix: gesture vertical inverted (#281)
1 parent c10bd88 commit 34f3c51

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

src/views/Stack/Card.tsx

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,18 +412,25 @@ export default class Card extends React.Component<Props> {
412412
cond(
413413
eq(this.props.current, isVisible),
414414
call(
415-
[this.didMovementHappen, this.isVisible],
416-
([didMovementHappen]: ReadonlyArray<Binary>) => {
415+
[this.didMovementHappen, isVisible],
416+
([didMovementHappen, isVisibleVal]: ReadonlyArray<
417+
Binary | number
418+
>) => {
417419
if (didMovementHappen) {
418420
// if we go back to the same position,
419421
// let's pretend that whole animation happen
420422
// for making the logic consistent
421423
// It's especially vital for having inputs properly focused.
422424
this.handleStartInteraction();
423425
const { onTransitionStart } = this.props;
424-
onTransitionStart && onTransitionStart({ closing: false });
426+
onTransitionStart &&
427+
onTransitionStart({ closing: !isVisibleVal });
425428
this.handleTransitionEnd();
426-
this.props.onOpen(true);
429+
if (isVisibleVal) {
430+
this.props.onOpen(true);
431+
} else {
432+
this.props.onClose(true);
433+
}
427434
}
428435
}
429436
),
@@ -514,7 +521,6 @@ export default class Card extends React.Component<Props> {
514521
call([this.isVisible], ([value]: ReadonlyArray<Binary>) => {
515522
const isOpen = Boolean(value);
516523
const { onOpen, onClose } = this.props;
517-
518524
this.handleTransitionEnd();
519525

520526
if (isOpen) {
@@ -544,14 +550,18 @@ export default class Card extends React.Component<Props> {
544550
this.gestureUntraversed,
545551
I18nManager.isRTL ? MINUS_ONE_NODE : TRUE_NODE
546552
),
547-
this.gestureUntraversed
553+
multiply(this.gestureUntraversed, this.verticalGestureDirection)
548554
)
549555
),
550556
set(
551557
this.velocity,
552-
multiply(
553-
this.velocityUntraversed,
554-
I18nManager.isRTL ? MINUS_ONE_NODE : TRUE_NODE
558+
cond(
559+
eq(this.direction, DIRECTION_HORIZONTAL),
560+
multiply(
561+
this.velocityUntraversed,
562+
I18nManager.isRTL ? MINUS_ONE_NODE : TRUE_NODE
563+
),
564+
multiply(this.velocityUntraversed, this.verticalGestureDirection)
555565
)
556566
),
557567
onChange(
@@ -636,7 +646,10 @@ export default class Card extends React.Component<Props> {
636646
this.gestureUntraversed,
637647
I18nManager.isRTL ? MINUS_ONE_NODE : TRUE_NODE
638648
),
639-
this.gestureUntraversed
649+
multiply(
650+
this.gestureUntraversed,
651+
this.verticalGestureDirection
652+
)
640653
),
641654
this.distance
642655
),

0 commit comments

Comments
 (0)