[OpenLayers-Commits] r11888 - in trunk/openlayers: lib/OpenLayers/Control tests/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sat Apr 9 08:22:57 EDT 2011


Author: ahocevar
Date: 2011-04-09 05:22:52 -0700 (Sat, 09 Apr 2011)
New Revision: 11888

Modified:
   trunk/openlayers/lib/OpenLayers/Control/DragFeature.js
   trunk/openlayers/tests/Control/DragFeature.html
Log:
Only start dragging when we are over a feature. r=tschaub (closes #3252)

Modified: trunk/openlayers/lib/OpenLayers/Control/DragFeature.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/DragFeature.js	2011-04-07 19:15:45 UTC (rev 11887)
+++ trunk/openlayers/lib/OpenLayers/Control/DragFeature.js	2011-04-09 12:22:52 UTC (rev 11888)
@@ -171,7 +171,7 @@
      * feature - {<OpenLayers.Feature.Vector>}
      */
     clickFeature: function(feature) {
-        if (this.overFeature(feature)) {
+        if (!this.over && this.overFeature(feature)) {
             this.handlers.drag.dragstart(this.handlers.feature.evt);
             // to let the events propagate to the feature handler (click callback)
             this.handlers.drag.stopDown = false;
@@ -186,8 +186,10 @@
      * feature - {<OpenLayers.Feature.Vector>}
      */
     clickoutFeature: function(feature) {
-        this.outFeature(feature);
-        this.handlers.drag.stopDown = true;
+        if (this.over) {
+            this.outFeature(feature);
+            this.handlers.drag.stopDown = true;
+        }
     },
 
     /**

Modified: trunk/openlayers/tests/Control/DragFeature.html
===================================================================
--- trunk/openlayers/tests/Control/DragFeature.html	2011-04-07 19:15:45 UTC (rev 11887)
+++ trunk/openlayers/tests/Control/DragFeature.html	2011-04-09 12:22:52 UTC (rev 11888)
@@ -357,6 +357,24 @@
              "onLeave called with expected feature");
     }
 
+    function test_Control_DragFeature_click(t) {
+        t.plan(1);
+        var map = new OpenLayers.Map("map");
+        var layer = new OpenLayers.Layer.Vector();
+        map.addLayer(layer);
+        var feature = new OpenLayers.Feature.Vector();
+        feature.layer = layer;
+        var control = new OpenLayers.Control.DragFeature(layer);
+        map.addControl(control);
+
+        control.activate();
+
+        control.overFeature(feature);
+        control.handlers.feature.evt = {which: 1};
+        control.clickFeature(feature);
+        t.eq(control.handlers.drag.started, false, "click after over does not start drag handler");
+    }
+
     </script>
 </head>
 <body>



More information about the Commits mailing list