mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-05-21 15:46:51 +08:00
fix: don't fire onOpen when screen is unmounting (#137)
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
This commit is contained in:
committed by
Michał Osadnik
parent
031c4d2378
commit
f22abb726c
@@ -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);
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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([
|
||||
@@ -654,7 +640,6 @@ export default class Card extends React.Component<Props> {
|
||||
),
|
||||
]
|
||||
),
|
||||
this.changeVisiblityExec,
|
||||
]);
|
||||
|
||||
private handleGestureEventHorizontal = Animated.event([
|
||||
|
||||
Reference in New Issue
Block a user