[OpenLayers-Commits] r11122 - sandbox/elemoine/draw-feature/lib/OpenLayers/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Feb 16 03:17:22 EST 2011


Author: erilem
Date: 2011-02-16 00:17:22 -0800 (Wed, 16 Feb 2011)
New Revision: 11122

Modified:
   sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
Log:
big refactoring in Path.js, based on bugs/regressions found by jorix, the Path.html and Polygon.html tests now fail, next step is to fix them

Modified: sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-16 08:17:15 UTC (rev 11121)
+++ sandbox/elemoine/draw-feature/lib/OpenLayers/Handler/Path.js	2011-02-16 08:17:22 UTC (rev 11122)
@@ -231,22 +231,16 @@
      * {Boolean} Allow event propagation
      */
     mousedown: function(evt) {
-        // consecutive mousedowns at the same location are
-        // ignored (occurs when finalizing the line on
-        // double-click)
-        if (this.lastDown && this.lastDown.equals(evt.xy)) {
-            return false;
-        }
         this.mouseDown = true;
-        this.lastDown = evt.xy;
-        this.modifyFeature(evt.xy, !!this.lastUp);
-        if (this.freehandMode(evt)) {
-            this.stoppedDown = true;
-            return false;
-        } else {
-            this.stoppedDown = this.stopDown;
-            return !this.stopDown;
+        if(this.freehandMode(evt)) {
+            var stopDown = true;
+        } else if(!this.lastDown || !this.lastDown.equals(evt.xy)) {
+            this.lastDown = evt.xy;
+            this.modifyFeature(evt.xy, !!this.lastUp);
+            var stopDown = this.stopDown;
         }
+        this.stoppedDown = stopDown;
+        return !stopDown;
     },
 
     /**
@@ -269,7 +263,7 @@
             return false;
         }
         if(!this.mouseDown || this.stoppedDown) {
-            this.modifyFeature(evt.xy, !!this.lastUp);
+            this.modifyFeature(evt.xy, !!this.lastUp); // FIXME measure immediate
         }
         return true;
     },
@@ -286,16 +280,12 @@
      * {Boolean} Allow event propagation
      */
     mouseup: function (evt) {
-        // consecutive mouseups at the same location are ignored
-        if (this.lastUp && this.lastUp.equals(evt.xy)) {
-            return false;
-        }
-        if(this.mouseDown) {
+        if(this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
             if(this.stoppedDown && this.freehandMode(evt)) {
                 this.removePoint();
                 this.finalize();
             } else {
-                if(this.lastDown.equals(evt.xy) || this.stoppedDown) {
+                if(this.lastDown.equals(evt.xy)) {
                     var first = this.lastUp == null;
                     if(first && this.persist) {
                         this.destroyPersistedFeature();
@@ -304,10 +294,9 @@
                     this.lastUp = evt.xy;
                 }
             }
+            this.stoppedDown = this.stopDown;
             this.mouseDown = false;
-            return !this.stopUp;
         }
-        return true;
     },
 
     /**



More information about the Commits mailing list