1 |
efrain |
1 |
YUI.add('dd-gestures', function (Y, NAME) {
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* This module is the conditional loaded `dd` module to support gesture events
|
|
|
6 |
* in the event that `dd` is loaded onto a device that support touch based events.
|
|
|
7 |
*
|
|
|
8 |
* This module is loaded and over rides 2 key methods on `DD.Drag` and `DD.DDM` to
|
|
|
9 |
* attach the gesture events. Overrides `DD.Drag._prep` and `DD.DDM._setupListeners`
|
|
|
10 |
* methods as well as set's the property `DD.Drag.START_EVENT` to `gesturemovestart`
|
|
|
11 |
* to enable gesture movement instead of mouse based movement.
|
|
|
12 |
* @module dd
|
|
|
13 |
* @submodule dd-gestures
|
|
|
14 |
*/
|
|
|
15 |
|
|
|
16 |
Y.DD.Drag.START_EVENT = 'gesturemovestart';
|
|
|
17 |
|
|
|
18 |
Y.DD.Drag.prototype._prep = function() {
|
|
|
19 |
this._dragThreshMet = false;
|
|
|
20 |
var node = this.get('node'), DDM = Y.DD.DDM;
|
|
|
21 |
|
|
|
22 |
node.addClass(DDM.CSS_PREFIX + '-draggable');
|
|
|
23 |
|
|
|
24 |
node.on(Y.DD.Drag.START_EVENT, Y.bind(this._handleMouseDownEvent, this), {
|
|
|
25 |
minDistance: this.get('clickPixelThresh'),
|
|
|
26 |
minTime: this.get('clickTimeThresh')
|
|
|
27 |
});
|
|
|
28 |
|
|
|
29 |
node.on('gesturemoveend', Y.bind(this._handleMouseUp, this), { standAlone: true });
|
|
|
30 |
node.on('dragstart', Y.bind(this._fixDragStart, this));
|
|
|
31 |
|
|
|
32 |
};
|
|
|
33 |
|
|
|
34 |
var _unprep = Y.DD.Drag.prototype._unprep;
|
|
|
35 |
|
|
|
36 |
Y.DD.Drag.prototype._unprep = function() {
|
|
|
37 |
var node = this.get('node');
|
|
|
38 |
_unprep.call(this);
|
|
|
39 |
node.detachAll('gesturemoveend');
|
|
|
40 |
};
|
|
|
41 |
|
|
|
42 |
Y.DD.DDM._setupListeners = function() {
|
|
|
43 |
var DDM = Y.DD.DDM;
|
|
|
44 |
|
|
|
45 |
this._createPG();
|
|
|
46 |
this._active = true;
|
|
|
47 |
Y.one(Y.config.doc).on('gesturemove', Y.throttle(Y.bind(DDM._move, DDM), DDM.get('throttleTime')), {
|
|
|
48 |
standAlone: true
|
|
|
49 |
});
|
|
|
50 |
};
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
54 |
}, '3.18.1', {"requires": ["dd-drag", "event-synthetic", "event-gestures"]});
|