Skip to content

Commit

Permalink
fix(): move resize logic to viewCtrl
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartington committed Oct 20, 2017
1 parent dd66f9a commit ebdf22d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/content/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, HostListener, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, NgZone, OnDestroy, Optional, Output, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';

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

_viewCtrl: any;

private _imgReqBfr: number;
private _imgRndBfr: number;
private _imgVelMax: number;
Expand Down Expand Up @@ -410,6 +412,8 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
}

if (viewCtrl) {
this._viewCtrl = viewCtrl;

// content has a view controller
viewCtrl._setIONContent(this);
viewCtrl._setIONContentRef(elementRef);
Expand Down Expand Up @@ -670,7 +674,6 @@ export class Content extends Ion implements OnDestroy, AfterViewInit, IContent {
* Tell the content to recalculate its dimensions. This should be called
* after dynamically adding/removing headers, footers, or tabs.
*/
@HostListener('window:orientationchange')
resize() {
this._dom.read(this._readDimensions.bind(this));
this._dom.write(this._writeDimensions.bind(this));
Expand Down
8 changes: 8 additions & 0 deletions src/navigation/view-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ export class ViewController {

this._cssClass = rootCssClass;
this._ts = Date.now();
window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
}

handleOrientationChange() {
if (this.getNav().isActive(this)) {
this.getContent().resize();
}
}

/**
Expand Down Expand Up @@ -533,6 +540,7 @@ export class ViewController {
renderer.setElementAttribute(cmpEle, 'style', null);
}

window.removeEventListener('orienationchagne', this.handleOrientationChange.bind(this));

This comment has been minimized.

Copy link
@saschwarz

saschwarz Oct 21, 2017

Looks like a typo on the event name: "orienationchagne" => "orientationchange"

This comment has been minimized.

Copy link
@mhartington

mhartington Oct 21, 2017

Author Contributor

You are correct

// completely destroy this component. boom.
this._cmp.destroy();
}
Expand Down

0 comments on commit ebdf22d

Please sign in to comment.