mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
fix(menu): drag menu to close. Fixes #189
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
import {Menu} from './menu';
|
||||
import {SlideEdgeGesture} from 'ionic/gestures/slide-edge-gesture';
|
||||
|
||||
import * as util from 'ionic/util';
|
||||
|
||||
class MenuContentGesture extends SlideEdgeGesture {
|
||||
constructor(menu: Menu) {
|
||||
constructor(menu: Menu, targetEl: Element, options = {}) {
|
||||
|
||||
super(menu.getContentElement(), {
|
||||
super(targetEl, util.extend({
|
||||
direction: (menu.side === 'left' || menu.side === 'right') ? 'x' : 'y',
|
||||
edge: menu.side,
|
||||
threshold: 75
|
||||
});
|
||||
}, options));
|
||||
|
||||
this.menu = menu;
|
||||
this.listen();
|
||||
@ -45,15 +46,27 @@ class MenuContentGesture extends SlideEdgeGesture {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Support dragging the target menu as well as the content.
|
||||
*/
|
||||
export class TargetGesture extends MenuContentGesture {
|
||||
constructor(menu: Menu) {
|
||||
super(menu, menu.getNativeElement(), {
|
||||
threshold: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class LeftMenuGesture extends MenuContentGesture {
|
||||
constructor(menu: Menu) {
|
||||
super(menu);
|
||||
super(menu, menu.getContentElement());
|
||||
}
|
||||
}
|
||||
|
||||
export class RightMenuGesture extends MenuContentGesture {
|
||||
constructor(menu: Menu) {
|
||||
super(menu);
|
||||
super(menu, menu.getContentElement());
|
||||
}
|
||||
|
||||
onSlide(slide, ev) {
|
||||
|
@ -123,6 +123,7 @@ export class Menu extends Ion {
|
||||
this._gesture = new gestures.LeftMenuGesture(this);
|
||||
break;
|
||||
}
|
||||
this._targetGesture = new gestures.TargetGesture(this);
|
||||
}
|
||||
|
||||
_initType(type) {
|
||||
@ -278,6 +279,7 @@ export class Menu extends Ion {
|
||||
onDestroy() {
|
||||
this.app.unregister(this.id);
|
||||
this._gesture && this._gesture.destroy();
|
||||
this._targetGesture && this._targetGesture.destroy();
|
||||
this._type && this._type.onDestroy();
|
||||
this._cntEle = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user