[OpenLayers-Commits] r11110 - in sandbox/elemoine/draw-feature: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Sat Feb 12 15:16:42 EST 2011


Author: erilem
Date: 2011-02-12 12:16:42 -0800 (Sat, 12 Feb 2011)
New Revision: 11110

Modified:
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
   sandbox/elemoine/draw-feature/tests/Handler/Point.html
Log:
path and point handlers - do not modify feature on mousemove when the mouse is down, this eliminates flickering when paning the map

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-12 20:16:31 UTC (rev 11109)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-12 20:16:42 UTC (rev 11110)
@@ -258,7 +258,9 @@
             this.addPoint(evt.xy);
             return false;
         }
-        this.modifyFeature(evt.xy, !!this.lastUp);
+        if(!this.mouseDown) {
+            this.modifyFeature(evt.xy, !!this.lastUp);
+        }
         return true;
     },
     

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js	2011-02-12 20:16:31 UTC (rev 11109)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Point.js	2011-02-12 20:16:42 UTC (rev 11110)
@@ -339,6 +339,7 @@
      * {Boolean} Allow event propagation
      */
     mousedown: function(evt) {
+        this.mouseDown = true;
         this.lastDown = evt.xy;
         return !this.stopDown;
     },
@@ -355,7 +356,9 @@
      * {Boolean} Allow event propagation
      */
     mousemove: function (evt) {
-        this.modifyFeature(evt.xy);
+        if(!this.mouseDown) {
+            this.modifyFeature(evt.xy);
+        }
         return true;
     },
 
@@ -371,6 +374,7 @@
      * {Boolean} Allow event propagation
      */
     mouseup: function (evt) {
+         this.mouseDown = false;
         // check keyboard modifiers
         if(!this.checkModifiers(evt)) {
             return true;

Modified: sandbox/elemoine/draw-feature/tests/Handler/Point.html
===================================================================
--- sandbox/elemoine/draw-feature/tests/Handler/Point.html	2011-02-12 20:16:31 UTC (rev 11109)
+++ sandbox/elemoine/draw-feature/tests/Handler/Point.html	2011-02-12 20:16:42 UTC (rev 11110)
@@ -142,7 +142,7 @@
     }
     
     function test_callbacks(t) {
-        t.plan(25);
+        t.plan(22);
         var map = new OpenLayers.Map("map", {
             resolutions: [1]
         });
@@ -185,14 +185,7 @@
         // mouse move
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(1, 0)});
-        t.eq(logs.length, 1, "[mousemove] called back");
-        log = logs.shift();
-        t.eq(log.type, "modify", "[mousemove] modify called");
-        t.geom_eq(log.args[0], new OpenLayers.Geometry.Point(-149, 75),
-                  "[mousemove] correct point");
-        t.geom_eq(log.args[1].geometry,
-                  new OpenLayers.Geometry.Point(-149, 75),
-                  "[mousemove] correct feature");
+        t.eq(logs.length, 0, "[mousemove] not called back");
         // mouse up (no finalize - we moved)
         handler.mouseup({type: "mouseup", xy: new OpenLayers.Pixel(1, 0)});
         t.eq(logs.length, 0, "[mouseup] not called back");



More information about the Commits mailing list