mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
40 lines
754 B
TypeScript
40 lines
754 B
TypeScript
import {Gesture} from './gesture';
|
|
import * as util from '../util';
|
|
|
|
|
|
export class DragGesture extends Gesture {
|
|
constructor(element, opts = {}) {
|
|
util.defaults(opts, {});
|
|
super(element, opts);
|
|
}
|
|
|
|
listen() {
|
|
super.listen();
|
|
|
|
this.on('panstart', ev => {
|
|
if (this.onDragStart(ev) !== false) {
|
|
this.dragging = true;
|
|
}
|
|
});
|
|
|
|
this.on('panmove', ev => {
|
|
if (!this.dragging) return;
|
|
if (this.onDrag(ev) === false) {
|
|
this.dragging = false;
|
|
}
|
|
});
|
|
|
|
this.on('panend', ev => {
|
|
if (!this.dragging) return;
|
|
this.onDragEnd(ev);
|
|
this.dragging = false;
|
|
});
|
|
|
|
this.hammertime.get('pan').set(this._options);
|
|
}
|
|
|
|
onDrag() {}
|
|
onDragStart() {}
|
|
onDragEnd() {}
|
|
}
|