Skip to content

Commit ebdf22d

Browse files
committed
fix(): move resize logic to viewCtrl
1 parent dd66f9a commit ebdf22d

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/components/content/content.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, HostListener, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
1+
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
22

33
import { App } from '../app/app';
44
import { Config } from '../../config/config';
@@ -227,6 +227,8 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
227227
/** @internal */
228228
_scrollDownOnLoad: boolean = false;
229229

230+
_viewCtrl: any;
231+
230232
private _imgReqBfr: number;
231233
private _imgRndBfr: number;
232234
private _imgVelMax: number;
@@ -410,6 +412,8 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
410412
}
411413

412414
if (viewCtrl) {
415+
this._viewCtrl = viewCtrl;
416+
413417
// content has a view controller
414418
viewCtrl._setIONContent(this);
415419
viewCtrl._setIONContentRef(elementRef);
@@ -670,7 +674,6 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
670674
* Tell the content to recalculate its dimensions. This should be called
671675
* after dynamically adding/removing headers, footers, or tabs.
672676
*/
673-
@HostListener('window:orientationchange')
674677
resize() {
675678
this._dom.read(this._readDimensions.bind(this));
676679
this._dom.write(this._writeDimensions.bind(this));

src/navigation/view-controller.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ export class ViewController {
113113

114114
this._cssClass = rootCssClass;
115115
this._ts = Date.now();
116+
window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
117+
}
118+
119+
handleOrientationChange() {
120+
if (this.getNav().isActive(this)) {
121+
this.getContent().resize();
122+
}
116123
}
117124

118125
/**
@@ -533,6 +540,7 @@ export class ViewController {
533540
renderer.setElementAttribute(cmpEle, 'style', null);
534541
}
535542

543+
window.removeEventListener('orienationchagne', this.handleOrientationChange.bind(this));
536544
// completely destroy this component. boom.
537545
this._cmp.destroy();
538546
}

0 commit comments

Comments
 (0)