mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(nav): ion-nav inside ion-content work properly
This commit is contained in:
@ -173,8 +173,8 @@ export class Content extends Ion {
|
|||||||
this._sbPadding = config.getBoolean('statusbarPadding', false);
|
this._sbPadding = config.getBoolean('statusbarPadding', false);
|
||||||
|
|
||||||
if (viewCtrl) {
|
if (viewCtrl) {
|
||||||
viewCtrl._setContent(this);
|
viewCtrl._setIONContent(this);
|
||||||
viewCtrl._setContentRef(elementRef);
|
viewCtrl._setIONContentRef(elementRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export class MyCmpTest {}
|
|||||||
<button ion-item [navPush]="'FirstPage'">Push w/ [navPush] and string view name</button>
|
<button ion-item [navPush]="'FirstPage'">Push w/ [navPush] and string view name</button>
|
||||||
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="navCtrl.pop()">Pop</button>
|
<button ion-item (click)="pop()">Pop</button>
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label>Toggle Can Leave</ion-label>
|
<ion-label>Toggle Can Leave</ion-label>
|
||||||
<ion-toggle (click)="canLeave = !canLeave"></ion-toggle>
|
<ion-toggle (click)="canLeave = !canLeave"></ion-toggle>
|
||||||
@ -174,6 +174,10 @@ export class FirstPage {
|
|||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pop() {
|
||||||
|
this.navCtrl.pop().catch(() => {});
|
||||||
|
}
|
||||||
|
|
||||||
viewDismiss() {
|
viewDismiss() {
|
||||||
this.viewCtrl.dismiss();
|
this.viewCtrl.dismiss();
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,15 @@ export class E2EApp {
|
|||||||
})
|
})
|
||||||
export class LandingPage {
|
export class LandingPage {
|
||||||
|
|
||||||
constructor(public navCtrl: NavController) {
|
constructor(public navCtrl: NavController) {}
|
||||||
}
|
|
||||||
|
|
||||||
goToPage() {
|
goToPage() {
|
||||||
this.navCtrl.push(FirstPage);
|
this.navCtrl.push(FirstPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ionViewDidLoad() {
|
||||||
|
this.goToPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
0
src/components/nav/test/child-navs/e2e.ts
Normal file
0
src/components/nav/test/child-navs/e2e.ts
Normal file
@ -421,8 +421,8 @@ export class Tabs extends Ion implements AfterViewInit {
|
|||||||
// to refresh the tabbar and content dimensions to be sure
|
// to refresh the tabbar and content dimensions to be sure
|
||||||
// they're lined up correctly
|
// they're lined up correctly
|
||||||
if (alreadyLoaded && selectedPage) {
|
if (alreadyLoaded && selectedPage) {
|
||||||
let content = <Content>selectedPage.getContent();
|
let content = <Content>selectedPage.getIONContent();
|
||||||
if (content && content instanceof Content) {
|
if (content) {
|
||||||
content.resize();
|
content.resize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,20 +175,17 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ti.resolve = (hasCompleted: boolean, isAsync: boolean, enteringName: string, leavingName: string, direction: string) => {
|
ti.resolve = (hasCompleted: boolean, isAsync: boolean, enteringName: string, leavingName: string, direction: string) => {
|
||||||
this.setTransitioning(false);
|
|
||||||
|
|
||||||
// transition has successfully resolved
|
// transition has successfully resolved
|
||||||
this._trnsId = null;
|
this._trnsId = null;
|
||||||
resolve && resolve(hasCompleted, isAsync, enteringName, leavingName, direction);
|
resolve && resolve(hasCompleted, isAsync, enteringName, leavingName, direction);
|
||||||
this._sbCheck();
|
this._sbCheck();
|
||||||
|
|
||||||
// let's see if there's another to kick off
|
// let's see if there's another to kick off
|
||||||
|
this.setTransitioning(false);
|
||||||
this._nextTrns();
|
this._nextTrns();
|
||||||
};
|
};
|
||||||
|
|
||||||
ti.reject = (rejectReason: any, trns: Transition) => {
|
ti.reject = (rejectReason: any, trns: Transition) => {
|
||||||
this.setTransitioning(false);
|
|
||||||
|
|
||||||
// rut row raggy, something rejected this transition
|
// rut row raggy, something rejected this transition
|
||||||
this._trnsId = null;
|
this._trnsId = null;
|
||||||
this._queue.length = 0;
|
this._queue.length = 0;
|
||||||
@ -209,6 +206,7 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
|
|
||||||
reject && reject(false, false, rejectReason);
|
reject && reject(false, false, rejectReason);
|
||||||
|
|
||||||
|
this.setTransitioning(false);
|
||||||
this._nextTrns();
|
this._nextTrns();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,6 +246,8 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
if (!ti) {
|
if (!ti) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// set that this nav is actively transitioning
|
||||||
|
this.setTransitioning(true);
|
||||||
|
|
||||||
// Get entering and leaving views
|
// Get entering and leaving views
|
||||||
const leavingView = this.getActive();
|
const leavingView = this.getActive();
|
||||||
@ -325,7 +325,6 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
|
|
||||||
_postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) {
|
_postViewInit(enteringView: ViewController, leavingView: ViewController, ti: TransitionInstruction, resolve: TransitionResolveFn) {
|
||||||
const opts = ti.opts || {};
|
const opts = ti.opts || {};
|
||||||
|
|
||||||
const insertViews = ti.insertViews;
|
const insertViews = ti.insertViews;
|
||||||
const removeStart = ti.removeStart;
|
const removeStart = ti.removeStart;
|
||||||
|
|
||||||
@ -822,8 +821,8 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
swipeBackProgress(stepValue: number) {
|
swipeBackProgress(stepValue: number) {
|
||||||
if (this._sbTrns && this._sbGesture) {
|
if (this._sbTrns && this._sbGesture) {
|
||||||
// continue to disable the app while actively dragging
|
// continue to disable the app while actively dragging
|
||||||
this._app.setEnabled(false, ACTIVE_TRANSITION_MAX_TIME);
|
this._app.setEnabled(false, ACTIVE_TRANSITION_DEFAULT);
|
||||||
this.setTransitioning(true, ACTIVE_TRANSITION_MAX_TIME);
|
this.setTransitioning(true);
|
||||||
|
|
||||||
// set the transition animation's progress
|
// set the transition animation's progress
|
||||||
this._sbTrns.progressStep(stepValue);
|
this._sbTrns.progressStep(stepValue);
|
||||||
@ -890,7 +889,7 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
return (this._trnsTm > Date.now());
|
return (this._trnsTm > Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
setTransitioning(isTransitioning: boolean, durationPadding: number = 2000) {
|
setTransitioning(isTransitioning: boolean, durationPadding: number = ACTIVE_TRANSITION_DEFAULT) {
|
||||||
this._trnsTm = (isTransitioning ? (Date.now() + durationPadding + ACTIVE_TRANSITION_OFFSET) : 0);
|
this._trnsTm = (isTransitioning ? (Date.now() + durationPadding + ACTIVE_TRANSITION_OFFSET) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -962,5 +961,5 @@ export class NavControllerBase extends Ion implements NavController {
|
|||||||
let ctrlIds = -1;
|
let ctrlIds = -1;
|
||||||
|
|
||||||
const DISABLE_APP_MINIMUM_DURATION = 64;
|
const DISABLE_APP_MINIMUM_DURATION = 64;
|
||||||
const ACTIVE_TRANSITION_MAX_TIME = 5000;
|
const ACTIVE_TRANSITION_DEFAULT = 5000;
|
||||||
const ACTIVE_TRANSITION_OFFSET = 2000;
|
const ACTIVE_TRANSITION_OFFSET = 2000;
|
||||||
|
@ -6,6 +6,7 @@ import { Navbar } from '../components/navbar/navbar';
|
|||||||
import { NavControllerBase } from './nav-controller-base';
|
import { NavControllerBase } from './nav-controller-base';
|
||||||
import { NavOptions, ViewState } from './nav-util';
|
import { NavOptions, ViewState } from './nav-util';
|
||||||
import { NavParams } from './nav-params';
|
import { NavParams } from './nav-params';
|
||||||
|
import { Content } from '../components/content/content';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,6 +29,8 @@ import { NavParams } from './nav-params';
|
|||||||
export class ViewController {
|
export class ViewController {
|
||||||
private _cntDir: any;
|
private _cntDir: any;
|
||||||
private _cntRef: ElementRef;
|
private _cntRef: ElementRef;
|
||||||
|
private _ionCntDir: Content;
|
||||||
|
private _ionCntRef: ElementRef;
|
||||||
private _hdrDir: Header;
|
private _hdrDir: Header;
|
||||||
private _ftrDir: Footer;
|
private _ftrDir: Footer;
|
||||||
private _isHidden: boolean = false;
|
private _isHidden: boolean = false;
|
||||||
@ -308,7 +311,7 @@ export class ViewController {
|
|||||||
/**
|
/**
|
||||||
* @returns {component} Returns the Page's Content component reference.
|
* @returns {component} Returns the Page's Content component reference.
|
||||||
*/
|
*/
|
||||||
getContent() {
|
getContent(): any {
|
||||||
return this._cntDir;
|
return this._cntDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,6 +329,36 @@ export class ViewController {
|
|||||||
return this._cntRef;
|
return this._cntRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_setIONContent(content: Content) {
|
||||||
|
this._setContent(content);
|
||||||
|
this._ionCntDir = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
getIONContent(): Content {
|
||||||
|
return this._ionCntDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
_setIONContentRef(elementRef: ElementRef) {
|
||||||
|
this._setContentRef(elementRef);
|
||||||
|
this._ionCntRef = elementRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
getIONContentRef(): ElementRef {
|
||||||
|
return this._ionCntRef;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
@ -24,8 +24,8 @@ export class PageTransition extends Transition {
|
|||||||
* DOM READ
|
* DOM READ
|
||||||
*/
|
*/
|
||||||
readDimensions() {
|
readDimensions() {
|
||||||
const content = <Content>this.enteringView.getContent();
|
const content = <Content>this.enteringView.getIONContent();
|
||||||
if (content && content instanceof Content) {
|
if (content) {
|
||||||
content.readDimensions();
|
content.readDimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,8 +34,8 @@ export class PageTransition extends Transition {
|
|||||||
* DOM WRITE
|
* DOM WRITE
|
||||||
*/
|
*/
|
||||||
writeDimensions() {
|
writeDimensions() {
|
||||||
const content = <Content>this.enteringView.getContent();
|
const content = <Content>this.enteringView.getIONContent();
|
||||||
if (content && content instanceof Content) {
|
if (content) {
|
||||||
content.writeDimensions();
|
content.writeDimensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user