ngZone.runOutsideAngular navbar title

This commit is contained in:
Adam Bradley
2015-05-28 22:50:48 -05:00
parent baf9e1c4e4
commit 2360bb8cc9
2 changed files with 9 additions and 11 deletions

View File

@@ -2,6 +2,7 @@ import {Component, Directive} from 'angular2/src/core/annotations_impl/annotatio
import {View} from 'angular2/src/core/annotations_impl/view';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import * as dom from '../../util/dom';
import {Platform} from 'ionic/platform/platform';
@@ -32,13 +33,14 @@ import {BackButton} from './back-button';
directives: [BackButton]
})
export class Navbar {
constructor(navItem: NavItem, elementRef: ElementRef) {
constructor(navItem:NavItem, elementRef:ElementRef, ngZone:NgZone) {
this.navItem = navItem;
this.domElement = elementRef.domElement;
// http://davidwalsh.name/detect-node-insertion
dom.animationStart(this.domElement, 'nodeInserted').then(() => {
this.alignTitle();
ngZone.runOutsideAngular(() => {
setTimeout(() => {
this.alignTitle();
}, 32);
});
}

View File

@@ -104,9 +104,6 @@ export class NavBase {
opts.isAnimated = opts.animation !== 'none';
// block possible clicks during transition
ClickBlock(opts.isAnimated, 520);
this.transitionStart(opts);
// wait for the new item to complete setup
@@ -175,9 +172,6 @@ export class NavBase {
let enteringItem = this.getPrevious(leavingItem);
enteringItem.shouldDestroy = false;
// block possible clicks during transition
ClickBlock(true);
// start the transition
this.transitionStart({ isAnimated: true });
@@ -265,6 +259,8 @@ export class NavBase {
transitionStart(opts) {
if (opts.isAnimated) {
// block possible clicks during transition
ClickBlock(true, 520);
this.getNavElement().classList.add('transitioning');
}
}
@@ -290,7 +286,7 @@ export class NavBase {
}
isTransitioning() {
var state;
let state;
for (let i = 0, ii = this.items.length; i < ii; i++) {
state = this.items[i].state;
if (state === ACTIVELY_ENTERING_STATE ||