mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
add standard
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
export * from './components/sidemenu/sidemenu';
|
||||
|
||||
import './components/sidemenu/behaviors/direction/direction';
|
||||
|
||||
@@ -6,17 +6,18 @@ import * as util from '../../util';
|
||||
|
||||
export var sideMenuConfig = new IonConfig();
|
||||
|
||||
// TODO defaults or bindings?
|
||||
sideMenuConfig.defaults({
|
||||
side: 'left',
|
||||
dragThreshold: '50'
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'ion-side-menu'
|
||||
// bind: {
|
||||
// side: 'side',
|
||||
// dragThreshold: 'dragThreshold'
|
||||
// },
|
||||
selector: 'ion-side-menu',
|
||||
bind: {
|
||||
side: 'side',
|
||||
dragThreshold: 'dragThreshold'
|
||||
},
|
||||
})
|
||||
@Template({
|
||||
inline: `<content></content>`
|
||||
@@ -26,7 +27,6 @@ export class SideMenu extends Ion {
|
||||
@Parent() sideMenuParent: SideMenuParent,
|
||||
@NgElement() element: NgElement
|
||||
) {
|
||||
debugger;
|
||||
this.domElement = element.domElement;
|
||||
|
||||
this._drag = {};
|
||||
@@ -68,7 +68,6 @@ export class SideMenu extends Ion {
|
||||
});
|
||||
}
|
||||
onDrag(ev) {
|
||||
console.log('ondrag');
|
||||
if (!this._drag) return;
|
||||
this.dragMethods.onDrag(this._drag, ev);
|
||||
}
|
||||
|
||||
@@ -12,22 +12,18 @@ export class DragGesture extends Gesture {
|
||||
}
|
||||
listen() {
|
||||
super.listen();
|
||||
console.log('listening');
|
||||
this.hammertime.on('panstart', ev => {
|
||||
console.log('panstart');
|
||||
if (this.onDragStart && this.onDragStart(ev) !== false) {
|
||||
this.dragging = true;
|
||||
}
|
||||
});
|
||||
this.hammertime.on('panmove', ev => {
|
||||
console.log('panmove');
|
||||
if (!this.dragging) return;
|
||||
if (this.onDrag && this.onDrag(ev) === false) {
|
||||
this.dragging = false;
|
||||
}
|
||||
});
|
||||
this.hammertime.on('panend', ev => {
|
||||
console.log('panend');
|
||||
if (!this.dragging) return;
|
||||
this.onDragEnd && this.onDragEnd(ev);
|
||||
this.dragging = false;
|
||||
|
||||
34
src/views/view-history.js
Normal file
34
src/views/view-history.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
export class ViewHistory {
|
||||
constructor() {
|
||||
this._array = [];
|
||||
}
|
||||
|
||||
indexOf(item) {
|
||||
return this._array.indexOf(item);
|
||||
}
|
||||
|
||||
push(item) {
|
||||
return this._array.push(item);
|
||||
}
|
||||
|
||||
pop() {
|
||||
return this._array.pop();
|
||||
}
|
||||
popTo(index) {
|
||||
var item = this._array[index];
|
||||
if (index !== -1) {
|
||||
this._array.length = index + 1;
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
peek(index) {
|
||||
if (!arguments.length) index = this._array.length - 1;
|
||||
return this._array[this._array.length - 1];
|
||||
}
|
||||
|
||||
length() {
|
||||
return this._array.length;
|
||||
}
|
||||
}
|
||||
33
src/views/view.js
Normal file
33
src/views/view.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as util from '../util';
|
||||
import {ViewHistory} from './view-history';
|
||||
|
||||
export class View extends ViewSwitcher {
|
||||
constructor(el) {
|
||||
super(el);
|
||||
|
||||
// A linear history of views that this switcher has gone
|
||||
// through.
|
||||
this.history = new ViewHistory();
|
||||
this.currentChild = null;
|
||||
}
|
||||
|
||||
setChild(view, options = {}) {
|
||||
var direction = options.direction || 'forward';
|
||||
var viewIndex = this.history.indexOf(view);
|
||||
|
||||
if (viewIndex !== -1) {
|
||||
direction = 'back';
|
||||
this.history.popTo(viewIndex);
|
||||
} else {
|
||||
this.history.push(view);
|
||||
}
|
||||
|
||||
if (this.currentView) {
|
||||
this.element.removeChild(this.currentView.element);
|
||||
}
|
||||
this.element.appendChild(view.element);
|
||||
this.currentView = view.element;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user