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

Commit

Permalink
fix: don't fire onOpen when screen is unmounting
Browse files Browse the repository at this point in the history
I can't think of a scenario a screen would unmount when opening.
So it's probably a safe-bet to always call onClose.

Fixes #136
  • Loading branch information
satya164 committed Oct 22, 2019
1 parent 2b5955e commit f341858
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,15 @@ export default class Card extends React.Component<Props> {
// during running. However, we need to invoke listener onClose
// manually in this case
if (this.isRunningAnimation || this.noAnimationStartedSoFar) {
if (this.isVisibleValue) {
this.props.onOpen(false);
} else {
this.props.onClose(false);
}
this.props.onClose(false);
}
}

private isVisible = new Value<Binary>(TRUE);
private gestureVelocityImpact = new Value<number>(
this.props.gestureVelocityImpact
);
private isVisibleValue: Binary = TRUE;

private nextIsVisible = new Value<Binary | -1>(UNSET);

private isClosing = new Value<Binary>(FALSE);
Expand Down Expand Up @@ -533,19 +529,9 @@ export default class Card extends React.Component<Props> {
),
];

private changeVisiblityExec = onChange(
this.isVisible,
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
);

private execNoGesture = block([
...this.exec,
this.runTransition(this.isVisible),
onChange(
this.isVisible,
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
),
this.changeVisiblityExec,
]);

private execWithGesture = block([
Expand Down Expand Up @@ -654,7 +640,6 @@ export default class Card extends React.Component<Props> {
),
]
),
this.changeVisiblityExec,
]);

private handleGestureEventHorizontal = Animated.event([
Expand Down

0 comments on commit f341858

Please sign in to comment.