mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 05:21:52 +08:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user