perf(menu): using passive events in menu

This commit is contained in:
Manu Mtz.-Almeida
2016-11-26 15:45:55 +01:00
parent a722107d88
commit 788a7b61f9
3 changed files with 7 additions and 3 deletions

View File

@ -22,6 +22,7 @@ export class MenuContentGesture extends SlideEdgeGesture {
threshold: 0, threshold: 0,
maxEdgeStart: menu.maxEdgeStart || 50, maxEdgeStart: menu.maxEdgeStart || 50,
zone: false, zone: false,
passive: true,
debouncer: new NativeRafDebouncer(), debouncer: new NativeRafDebouncer(),
gesture: gestureCtrl.createGesture({ gesture: gestureCtrl.createGesture({
name: GESTURE_MENU_SWIPE, name: GESTURE_MENU_SWIPE,

View File

@ -339,7 +339,7 @@ export class Menu {
this.setElementAttribute('type', this.type); this.setElementAttribute('type', this.type);
// add the gestures // add the gestures
this._cntGesture = new MenuContentGesture(this, document.body, this._gestureCtrl); this._cntGesture = new MenuContentGesture(this, <any>document, this._gestureCtrl);
// register listeners if this menu is enabled // register listeners if this menu is enabled
// check if more than one menu is on the same side // check if more than one menu is on the same side
@ -502,9 +502,9 @@ export class Menu {
// this places the menu into the correct location before it animates in // this places the menu into the correct location before it animates in
// this css class doesn't actually kick off any animations // this css class doesn't actually kick off any animations
this.menuContent && this.menuContent.resize();
this.setElementClass('show-menu', true); this.setElementClass('show-menu', true);
this.backdrop.setElementClass('show-backdrop', true); this.backdrop.setElementClass('show-backdrop', true);
this.menuContent && this.menuContent.resize();
this._keyboard.close(); this._keyboard.close();
this._isAnimating = true; this._isAnimating = true;
} }

View File

@ -16,6 +16,7 @@ export interface PanGestureConfig {
debouncer?: Debouncer; debouncer?: Debouncer;
zone?: boolean; zone?: boolean;
capture?: boolean; capture?: boolean;
passive?: boolean;
} }
/** /**
@ -40,6 +41,7 @@ export class PanGesture {
direction: 'x', direction: 'x',
zone: true, zone: true,
capture: false, capture: false,
passive: false,
}); });
this.debouncer = (opts.debouncer) this.debouncer = (opts.debouncer)
@ -53,7 +55,8 @@ export class PanGesture {
pointerMove: this.pointerMove.bind(this), pointerMove: this.pointerMove.bind(this),
pointerUp: this.pointerUp.bind(this), pointerUp: this.pointerUp.bind(this),
zone: opts.zone, zone: opts.zone,
capture: opts.capture capture: opts.capture,
passive: opts.passive
}; };
this.detector = new PanRecognizer(opts.direction, opts.threshold, opts.maxAngle); this.detector = new PanRecognizer(opts.direction, opts.threshold, opts.maxAngle);
} }