MDL-35616 import YUI 3.7.2
[moodle.git] / lib / yuilib / 3.7.2 / build / dd-gestures / dd-gestures.js
blob671cc55d9f14a7698f71822faad81d644e8830b2
1 /*
2 YUI 3.7.2 (build 5639)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add('dd-gestures', function (Y, NAME) {
10     /**
11     * This module is the conditional loaded `dd` module to support gesture events
12     * in the event that `dd` is loaded onto a device that support touch based events.
13     *
14     * This module is loaded and over rides 2 key methods on `DD.Drag` and `DD.DDM` to
15     * attach the gesture events. Overrides `DD.Drag._prep` and `DD.DDM._setupListeners`
16     * methods as well as set's the property `DD.Drag.START_EVENT` to `gesturemovestart`
17     * to enable gesture movement instead of mouse based movement.
18     * @module dd
19     * @submodule dd-gestures
20     */
21     
22     Y.DD.Drag.START_EVENT = 'gesturemovestart';
24     Y.DD.Drag.prototype._prep = function() {
25         this._dragThreshMet = false;
26         var node = this.get('node'), DDM = Y.DD.DDM;
28         node.addClass(DDM.CSS_PREFIX + '-draggable');
30         node.on(Y.DD.Drag.START_EVENT, Y.bind(this._handleMouseDownEvent, this), {
31             minDistance: 0,
32             minTime: 0
33         });
35         node.on('gesturemoveend', Y.bind(this._handleMouseUp, this), { standAlone: true });
36         node.on('dragstart', Y.bind(this._fixDragStart, this));
38     };
40     Y.DD.DDM._setupListeners = function() {
41         var DDM = Y.DD.DDM;
43         this._createPG();
44         this._active = true;
45         Y.one(Y.config.doc).on('gesturemove', Y.throttle(Y.bind(DDM._move, DDM), DDM.get('throttleTime')), { standAlone: true });
46     };
50 }, '3.7.2', {"requires": ["dd-drag", "event-synthetic", "event-gestures"]});