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

Commit 4495d9a

Browse files
committed
fix: don't fire onOpen when screen is unmounting
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
1 parent bd269ef commit 4495d9a

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

src/views/Stack/Card.tsx

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -289,20 +289,13 @@ export default class Card extends React.Component<Props> {
289289
// during running. However, we need to invoke listener onClose
290290
// manually in this case
291291
if (this.isRunningAnimation || this.noAnimationStartedSoFar) {
292-
if (this.isVisibleValue) {
293-
this.props.onOpen(false);
294-
} else {
295-
this.props.onClose(false);
296-
}
292+
this.props.onClose(false);
297293
}
298294
}
299295

300296
private isVisible = new Value<Binary>(TRUE);
301-
private gestureVelocityImpact = new Value<number>(
302-
this.props.gestureVelocityImpact
303-
);
304-
private isVisibleValue: Binary = TRUE;
305297
private nextIsVisible = new Value<Binary | -1>(UNSET);
298+
306299
private verticalGestureDirection = new Value(
307300
this.props.gestureDirection === 'vertical-inverted' ? TOP : BOTTOM
308301
);
@@ -325,7 +318,11 @@ export default class Card extends React.Component<Props> {
325318
height: new Value(this.props.layout.height),
326319
};
327320

328-
openingSpecConfig =
321+
private gestureVelocityImpact = new Value<number>(
322+
this.props.gestureVelocityImpact
323+
);
324+
325+
private openingSpecConfig =
329326
this.props.transitionSpec.open.animation === 'timing'
330327
? transformTimingConfigToAnimatedValues(
331328
this.props.transitionSpec.open.config
@@ -334,7 +331,7 @@ export default class Card extends React.Component<Props> {
334331
this.props.transitionSpec.open.config
335332
);
336333

337-
closingSpecConfig =
334+
private closingSpecConfig =
338335
this.props.transitionSpec.close.animation === 'timing'
339336
? transformTimingConfigToAnimatedValues(
340337
this.props.transitionSpec.close.config
@@ -543,25 +540,11 @@ export default class Card extends React.Component<Props> {
543540
set(this.nextIsVisible, UNSET_NODE),
544541
])
545542
),
546-
onChange(
547-
this.isVisible,
548-
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
549-
),
550543
];
551544

552-
private changeVisiblityExec = onChange(
553-
this.isVisible,
554-
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
555-
);
556-
557545
private execNoGesture = block([
558546
...this.exec,
559547
this.runTransition(this.isVisible),
560-
onChange(
561-
this.isVisible,
562-
call([this.isVisible], ([isVisible]) => (this.isVisibleValue = isVisible))
563-
),
564-
this.changeVisiblityExec,
565548
]);
566549

567550
private execWithGesture = block([
@@ -676,7 +659,6 @@ export default class Card extends React.Component<Props> {
676659
),
677660
]
678661
),
679-
this.changeVisiblityExec,
680662
]);
681663

682664
private handleGestureEventHorizontal = Animated.event([

0 commit comments

Comments
 (0)