fix(menu): run gestures outside of zone

Closes #755
This commit is contained in:
Adam Bradley
2015-12-18 10:58:08 -06:00
parent 829442dffe
commit c118009a7c
3 changed files with 23 additions and 17 deletions

View File

@ -1,4 +1,4 @@
import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef} from 'angular2/core'; import {Component, forwardRef, Directive, Host, EventEmitter, ElementRef, NgZone} from 'angular2/core';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {IonicApp} from '../app/app'; import {IonicApp} from '../app/app';
@ -113,16 +113,14 @@ import * as gestures from './menu-gestures';
export class Menu extends Ion { export class Menu extends Ion {
constructor( constructor(
app: IonicApp,
elementRef: ElementRef, elementRef: ElementRef,
config: Config, config: Config,
platform: Platform, private app: IonicApp,
keyboard: Keyboard private platform: Platform,
private keyboard: Keyboard,
private zone: NgZone
) { ) {
super(elementRef, config); super(elementRef, config);
this.app = app;
this.platform = platform;
this.keyboard = keyboard;
this.opening = new EventEmitter('opening'); this.opening = new EventEmitter('opening');
this.isOpen = false; this.isOpen = false;
@ -177,16 +175,18 @@ export class Menu extends Ion {
* @private * @private
*/ */
_initGesture() { _initGesture() {
switch(this.side) { this.zone.runOutsideAngular(() => {
case 'right': switch(this.side) {
this._gesture = new gestures.RightMenuGesture(this); case 'right':
break; this._gesture = new gestures.RightMenuGesture(this);
break;
case 'left': case 'left':
this._gesture = new gestures.LeftMenuGesture(this); this._gesture = new gestures.LeftMenuGesture(this);
break; break;
} }
this._targetGesture = new gestures.TargetGesture(this); this._targetGesture = new gestures.TargetGesture(this);
});
} }
/** /**

View File

@ -40,6 +40,7 @@ class E2EApp {
constructor(app: IonicApp) { constructor(app: IonicApp) {
this.app = app; this.app = app;
this.rootView = Page1; this.rootView = Page1;
this.changeDectionCount = 0;
this.pages = [ this.pages = [
{ title: 'Page 1', component: Page1 }, { title: 'Page 1', component: Page1 },
@ -62,4 +63,9 @@ class E2EApp {
onMenuOpening(ev) { onMenuOpening(ev) {
console.log('onMenuOpening', ev); console.log('onMenuOpening', ev);
} }
isHidden() {
console.log('Change detection', ++this.changeDectionCount);
return false;
}
} }

View File

@ -12,7 +12,7 @@
{{p.title}} {{p.title}}
</button> </button>
<button ion-item menuClose="leftMenu" detail-none> <button ion-item menuClose="leftMenu" detail-none [hidden]="isHidden()">
Close Menu Close Menu
</button> </button>