mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(router): prevent double navs
This commit is contained in:
@@ -229,8 +229,7 @@ export class NavController extends Ion {
|
||||
}
|
||||
|
||||
if (this.isTransitioning()) {
|
||||
console.debug('nav controller actively transitioning');
|
||||
return Promise.reject();
|
||||
return Promise.reject('nav controller actively transitioning');
|
||||
}
|
||||
|
||||
this.setTransitioning(true, 500);
|
||||
@@ -301,12 +300,11 @@ export class NavController extends Ion {
|
||||
*/
|
||||
pop(opts = {}) {
|
||||
if (!opts.animateFirst && !this.canGoBack()) {
|
||||
return Promise.reject();
|
||||
return Promise.reject('pop cannot go back');
|
||||
}
|
||||
|
||||
if (this.isTransitioning()) {
|
||||
console.debug('nav controller actively transitioning');
|
||||
return Promise.reject();
|
||||
return Promise.reject('nav controller actively transitioning';
|
||||
}
|
||||
|
||||
this.setTransitioning(true, 500);
|
||||
@@ -422,7 +420,7 @@ export class NavController extends Ion {
|
||||
*/
|
||||
insert(index, componentType, params = {}, opts = {}) {
|
||||
if (!componentType || index < 0) {
|
||||
return Promise.reject();
|
||||
return Promise.reject('invalid insert');
|
||||
}
|
||||
|
||||
// push it onto the end
|
||||
@@ -464,7 +462,7 @@ export class NavController extends Ion {
|
||||
*/
|
||||
remove(index, opts = {}) {
|
||||
if (index < 0 || index >= this._views.length) {
|
||||
return Promise.reject("Index out of range");
|
||||
return Promise.reject("index out of range");
|
||||
}
|
||||
|
||||
let viewToRemove = this._views[index];
|
||||
|
||||
@@ -51,7 +51,7 @@ export class NavRouter extends RouterOutlet {
|
||||
|
||||
// prevent double navigations to the same view
|
||||
var lastView = this.nav.last();
|
||||
if (lastView && lastView.componentType === componentType && lastView.params.data === nextInstruction.params) {
|
||||
if (this.nav.isTransitioning() || lastView && lastView.componentType === componentType && lastView.params.data === nextInstruction.params) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
@@ -102,15 +102,14 @@ export class Tab extends NavController {
|
||||
} else if (this.parent.preloadTabs) {
|
||||
this._loadTimer = setTimeout(() => {
|
||||
if (!this._loaded) {
|
||||
let opts = {
|
||||
this.load({
|
||||
animate: false,
|
||||
preload: true,
|
||||
postLoad: (viewCtrl) => {
|
||||
let navbar = viewCtrl.getNavbar();
|
||||
navbar && navbar.setHidden(true);
|
||||
}
|
||||
};
|
||||
this.load(opts);
|
||||
}, function(){});
|
||||
}
|
||||
}, 1000 * this.index);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class SignIn {
|
||||
|
||||
push() {
|
||||
setTimeout(() => {
|
||||
this.nav.setRoot(TabsPage, null, { animate: true });
|
||||
this.nav.push(TabsPage);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user