Skip to content

Commit 63d495a

Browse files
committed
fix(nav): transitioning state is a boolean not a timer
long async promises in canLeave / canEnter can lead to a false negative of isTransitioning() It is key for the internal consistency of NavController to always know the correct state
1 parent beab06f commit 63d495a

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/navigation/nav-controller-base.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class NavControllerBase extends Ion implements NavController {
3434
_sbThreshold: number;
3535
_sbTrns: Transition;
3636
_trnsId: number = null;
37-
_trnsTm: number = 0;
37+
_trnsTm: boolean = false;
3838
_viewport: ViewContainerRef;
3939
_views: ViewController[] = [];
4040

@@ -597,7 +597,7 @@ export class NavControllerBase extends Ion implements NavController {
597597
const duration = transition.getDuration();
598598

599599
// set that this nav is actively transitioning
600-
this.setTransitioning(true, duration);
600+
this.setTransitioning(true);
601601

602602
if (transition.isRoot()) {
603603
// this is the top most, or only active transition, so disable the app
@@ -883,7 +883,7 @@ export class NavControllerBase extends Ion implements NavController {
883883
if (this._sbTrns && this._sbGesture) {
884884
// continue to disable the app while actively dragging
885885
this._app.setEnabled(false, ACTIVE_TRANSITION_DEFAULT);
886-
this.setTransitioning(true, ACTIVE_TRANSITION_DEFAULT);
886+
this.setTransitioning(true);
887887

888888
// set the transition animation's progress
889889
this._sbTrns.progressStep(stepValue);
@@ -933,15 +933,11 @@ export class NavControllerBase extends Ion implements NavController {
933933
}
934934

935935
isTransitioning(): boolean {
936-
if (this._trnsTm === 0) {
937-
return false;
938-
}
939-
// using a timestamp instead of boolean incase something goes wrong
940-
return (this._trnsTm > Date.now());
936+
return this._trnsTm;
941937
}
942938

943-
setTransitioning(isTransitioning: boolean, durationPadding: number = ACTIVE_TRANSITION_DEFAULT) {
944-
this._trnsTm = (isTransitioning ? (Date.now() + durationPadding + ACTIVE_TRANSITION_OFFSET) : 0);
939+
setTransitioning(isTransitioning: boolean) {
940+
this._trnsTm = isTransitioning;
945941
}
946942

947943
getActive(): ViewController {

0 commit comments

Comments
 (0)