API Docs for: 3.17.2
Show:

File: dd/js/drag-gestures.js

  1.  
  2. /**
  3. * This module is the conditional loaded `dd` module to support gesture events
  4. * in the event that `dd` is loaded onto a device that support touch based events.
  5. *
  6. * This module is loaded and over rides 2 key methods on `DD.Drag` and `DD.DDM` to
  7. * attach the gesture events. Overrides `DD.Drag._prep` and `DD.DDM._setupListeners`
  8. * methods as well as set's the property `DD.Drag.START_EVENT` to `gesturemovestart`
  9. * to enable gesture movement instead of mouse based movement.
  10. * @module dd
  11. * @submodule dd-gestures
  12. */
  13. Y.log('Drag gesture support loaded', 'info', 'drag-gestures');
  14.  
  15. Y.DD.Drag.START_EVENT = 'gesturemovestart';
  16.  
  17. Y.DD.Drag.prototype._prep = function() {
  18. Y.log('Using DD override prep to attach gesture events', 'info', 'drag-gestures');
  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.