Merge pull request #2242 from KietChan/MOBILE-3254_integration
MOBILE-3254 ionic: double click on item some time make it open twicemain
commit
386d9a80b2
|
@ -16,9 +16,10 @@ import {
|
|||
Component, Optional, ElementRef, NgZone, Renderer, ComponentFactoryResolver, ChangeDetectorRef, ErrorHandler, OnInit,
|
||||
OnDestroy, ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { Tab, App, Config, Platform, GestureController, DeepLinker, DomController } from 'ionic-angular';
|
||||
import { Tab, App, Config, Platform, GestureController, DeepLinker, DomController, NavOptions } from 'ionic-angular';
|
||||
import { TransitionController } from 'ionic-angular/transitions/transition-controller';
|
||||
import { CoreIonTabsComponent } from './ion-tabs';
|
||||
import { TransitionDoneFn } from 'ionic-angular/navigation/nav-util';
|
||||
|
||||
/**
|
||||
* Equivalent to ion-tab, but to be used inside core-ion-tabs.
|
||||
|
@ -58,4 +59,35 @@ export class CoreIonTabComponent extends Tab implements OnInit, OnDestroy {
|
|||
|
||||
this.parent.remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a page to the navigation stack. this similar to parent NavController, but perform some check to make
|
||||
* sure one page won't open multiple time.
|
||||
*/
|
||||
push(page: any, params?: any, opts?: NavOptions, done?: TransitionDoneFn): Promise<any> {
|
||||
if (this.isTransitioning()) {
|
||||
// Try again later, the app is transitioning, this also happen when the page is first loaded.
|
||||
return new Promise<any>((resolve, reject): void => {
|
||||
setTimeout(() => {
|
||||
|
||||
return this.push(page, params, opts, done).then(resolve, reject);
|
||||
}, 250);
|
||||
});
|
||||
} else {
|
||||
const previousViews = this.getViews();
|
||||
if (previousViews.length > 0) {
|
||||
const previousView = previousViews[previousViews.length - 1];
|
||||
const previousParam = previousView.getNavParams().data;
|
||||
|
||||
// If the view we pushing in have same page's name and identical params, then we won't do anything.
|
||||
// This is Ionic issue when user clicking too fast on old device or slow internet connection.
|
||||
if (previousView.name === page && JSON.stringify(previousParam) === JSON.stringify(params)) {
|
||||
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
return super.push(page, params, opts, done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue