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 (#137)
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 authored and osdnk committed Oct 22, 2019
1 parent 031c4d2 commit f22abb7
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions packages/stack/src/views/Stack/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,11 @@ 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 All @@ -313,7 +305,11 @@ export default class Card extends React.Component<Props> {
height: new Value(this.props.layout.height),
};

openingSpecConfig =
private gestureVelocityImpact = new Value<number>(
this.props.gestureVelocityImpact
);

private openingSpecConfig =
this.props.transitionSpec.open.animation === 'timing'
? transformTimingConfigToAnimatedValues(
this.props.transitionSpec.open.config
Expand All @@ -322,7 +318,7 @@ export default class Card extends React.Component<Props> {
this.props.transitionSpec.open.config
);

closingSpecConfig =
private closingSpecConfig =
this.props.transitionSpec.close.animation === 'timing'
? transformTimingConfigToAnimatedValues(
this.props.transitionSpec.close.config
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 f22abb7

Please sign in to comment.