feat(content): add a resize function to recalculate the content size

this should be called when dynamically displaying/hiding headers,
footers, or tabs.

references #7131
This commit is contained in:
Brandy Carney
2016-06-30 16:32:30 -04:00
parent cd6ad23ef3
commit 1fe1c1e291
3 changed files with 53 additions and 2 deletions

View File

@ -442,6 +442,45 @@ export class Content extends Ion {
}
}
/**
* Tell the content to recalculate its dimensions. This should be called
* after dynamically adding headers, footers, or tabs.
*
* ```ts
* @Component({
* template: `
* <ion-header>
* <ion-navbar>
* <ion-title>Main Navbar</ion-title>
* </ion-navbar>
* <ion-toolbar *ngIf="showToolbar">
* <ion-title>Dynamic Toolbar</ion-title>
* </ion-toolbar>
* </ion-header>
* <ion-content>
* <button (click)="toggleToolbar()">Toggle Toolbar</button>
* </ion-content>
* `})
*
* class E2EPage {
* @ViewChild(Content) content: Content;
* showToolbar: boolean = false;
*
* toggleToolbar() {
* this.showToolbar = !this.showToolbar;
* this.content.resize();
* }
* }
* ```
*
*/
resize() {
nativeRaf(() => {
this.readDimensions();
this.writeDimensions();
});
}
/**
* @private
* DOM READ