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

View File

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

View File

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