Fire DragDrop2:start only after moving the mouse more than the defined threshold.
authorJan Schneider <jan@horde.org>
Mon, 15 Mar 2010 16:32:18 +0000 (17:32 +0100)
committerJan Schneider <jan@horde.org>
Mon, 15 Mar 2010 16:59:09 +0000 (17:59 +0100)
horde/js/dragdrop2.js

index 7ea6f52..f1c3736 100644 (file)
  *   Fired on mousemove.
  *
  * 'DragDrop2:end'
- *   Fired on mousedown.
+ *   Fired on mouseup.
  *
  * 'DragDrop2:start'
- *   Fired on mouseup.
+ *   Fired when first moved more than 'threshold'.
  *
  *
  * new Drop(element, {
@@ -263,9 +263,9 @@ Drag = Class.create({
         DragDrop.Drags.activate(this);
         this.move = 0;
         this.wasDragged = false;
+        this.wasMoved = false;
         this.lastcaption = null;
-
-        this.element.fire('DragDrop2:start', e);
+        this.clickEvent = e;
 
         if (this.options.ghosting || this.options.caption) {
             if (!DragDrop.Drags.cover) {
@@ -305,6 +305,9 @@ Drag = Class.create({
 
         if (++this.move <= this.options.threshold) {
             return;
+        } else if (!this.wasMoved) {
+            this.element.fire('DragDrop2:start', this.clickEvent);
+            this.wasMoved = true;
         }
 
         this.lastCoord = xy = [ e.pointerX(), e.pointerY() ];