[OpenLayers-Commits] r11920 - in sandbox/elemoine/3272: lib/OpenLayers/Handler tests/Handler

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Thu Apr 28 02:04:00 EDT 2011


Author: erilem
Date: 2011-04-27 23:03:59 -0700 (Wed, 27 Apr 2011)
New Revision: 11920

Modified:
   sandbox/elemoine/3272/lib/OpenLayers/Handler/Path.js
   sandbox/elemoine/3272/lib/OpenLayers/Handler/Point.js
   sandbox/elemoine/3272/tests/Handler/Path.html
   sandbox/elemoine/3272/tests/Handler/Polygon.html
Log:
Revert "touches at the same location shouldn't draw new points"

This reverts commit d4ff66a42fa10d62b87a30f9f51e3bc874f57ad7.

Modified: sandbox/elemoine/3272/lib/OpenLayers/Handler/Path.js
===================================================================
--- sandbox/elemoine/3272/lib/OpenLayers/Handler/Path.js	2011-04-27 15:00:52 UTC (rev 11919)
+++ sandbox/elemoine/3272/lib/OpenLayers/Handler/Path.js	2011-04-28 06:03:59 UTC (rev 11920)
@@ -36,6 +36,14 @@
     maxVertices: null,
 
     /**
+     * Property: doubleTouchTolerance
+     * {Number} Maximum number of pixels between two touches for
+     *     the gesture to be considered a "finalize feature" action.
+     *     Default is 20.
+     */
+    doubleTouchTolerance: 20,
+
+    /**
      * Property: freehand
      * {Boolean} In freehand mode, the handler starts the path on mouse down,
      * adds a point for every mouse move, and finishes the path on mouse up.
@@ -60,13 +68,6 @@
     timerId: null,
 
     /**
-     * Property: acceptDblclick
-     * {Boolean} Indicate if we can finalize the feature on the next dblclick
-     * event.
-     */
-    acceptDblclick: false,
-
-    /**
      * Constructor: OpenLayers.Handler.Path
      * Create a new path hander
      *
@@ -249,7 +250,7 @@
     touchstart: function(evt) {
         if (this.timerId &&
             this.passesTolerance(this.lastTouchPx, evt.xy,
-                                 this.dblclickTolerance)) {
+                                 this.doubleTouchTolerance)) {
             // double-tap, finalize the geometry
             this.finishGeometry();
             window.clearTimeout(this.timerId);
@@ -293,7 +294,6 @@
         }
         this.mouseDown = true;
         this.lastDown = evt.xy;
-        this.acceptDblclick = false;
         this.stoppedDown = stopDown;
         return !stopDown;
     },
@@ -335,33 +335,25 @@
      * {Boolean} Allow event propagation
      */
     up: function (evt) {
-        if (this.mouseDown) {
-            var samePlace = this.lastUp &&
-                            this.passesTolerance(this.lastUp, evt.xy,
-                                                 this.dblclickTolerance);
-            if(!samePlace) {
-                if(this.stoppedDown && this.freehandMode(evt)) {
-                    this.removePoint();
-                    this.finalize();
-                } else {
-                    if (this.passesTolerance(this.lastDown, evt.xy,
-                                             this.pixelTolerance)) {
-                        if (this.touch) {
-                            this.modifyFeature(evt.xy);
-                        }
-                        if(this.lastUp == null && this.persist) {
-                            this.destroyPersistedFeature();
-                        }
-                        this.addPoint(evt.xy);
-                        this.lastUp = evt.xy;
-                        if(this.line.geometry.components.length ===
-                               this.maxVertices + 1) {
-                            this.finishGeometry();
-                        }
+        if (this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
+            if(this.stoppedDown && this.freehandMode(evt)) {
+                this.removePoint();
+                this.finalize();
+            } else {
+                if (this.passesTolerance(this.lastDown, evt.xy,
+                                         this.pixelTolerance)) {
+                    if (this.touch) {
+                        this.modifyFeature(evt.xy);
                     }
+                    if(this.lastUp == null && this.persist) {
+                        this.destroyPersistedFeature();
+                    }
+                    this.addPoint(evt.xy);
+                    this.lastUp = evt.xy;
+                    if(this.line.geometry.components.length === this.maxVertices + 1) {
+                        this.finishGeometry();
+                    }
                 }
-            } else {
-                this.acceptDblclick = true;
             }
         }
         this.stoppedDown = this.stopDown;
@@ -392,13 +384,7 @@
      */
     dblclick: function(evt) {
         if(!this.freehandMode(evt)) {
-            var accept = this.acceptDblclick ||
-                         (this.lastUp &&
-                          this.passesTolerance(this.lastUp, evt.xy,
-                                               this.dblclickTolerance));
-            if(accept) {
-                this.finishGeometry();
-            }
+            this.finishGeometry();
         }
         return false;
     },

Modified: sandbox/elemoine/3272/lib/OpenLayers/Handler/Point.js
===================================================================
--- sandbox/elemoine/3272/lib/OpenLayers/Handler/Point.js	2011-04-27 15:00:52 UTC (rev 11919)
+++ sandbox/elemoine/3272/lib/OpenLayers/Handler/Point.js	2011-04-28 06:03:59 UTC (rev 11920)
@@ -107,15 +107,6 @@
     pixelTolerance: 5,
 
     /**
-     * Property: dblclickTolerance
-     * {Number} Maximum distance in pixels between two clicks (or touches)
-     *     for these clicks to be considered on the same location. Used to
-     *     determine if the feature should be finalized. Default is 20 for
-     *     touch devices, and 0 for non-touch devices.
-     */
-    dblclickTolerance: "ontouchend" in document ? 20 : 0,
-
-    /**
      * Property: touch
      * {Boolean} Indcates the support of touch events.
      */
@@ -528,8 +519,7 @@
             return true;
         }
         // ignore double-clicks
-        if (this.lastUp && this.passesTolerance(this.lastUp, evt.xy,
-                                                this.dblclickTolerance)) {
+        if (this.lastUp && this.lastUp.equals(evt.xy)) {
             return true;
         }
         if (this.lastDown && this.passesTolerance(this.lastDown, evt.xy,

Modified: sandbox/elemoine/3272/tests/Handler/Path.html
===================================================================
--- sandbox/elemoine/3272/tests/Handler/Path.html	2011-04-27 15:00:52 UTC (rev 11919)
+++ sandbox/elemoine/3272/tests/Handler/Path.html	2011-04-28 06:03:59 UTC (rev 11920)
@@ -150,7 +150,7 @@
     }     
 
     function test_callbacks(t) {
-        t.plan(47);
+        t.plan(45);
         var map = new OpenLayers.Map("map", {
             resolutions: [1]
         });
@@ -271,19 +271,11 @@
         // mouse down
         handler.mousedown({type: "mousedown",
                            xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(logs.length, 0, "[mousedown] not called back");
+        t.eq(logs.length, 0, "[mousedown] called back");
         // mouse up
         handler.mouseup({type: "mouseup",
                          xy: new OpenLayers.Pixel(10, 10)});
         t.eq(logs.length, 0, "[mouseup] not called back");
-        // mouse down
-        handler.mousedown({type: "mousedown",
-                           xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(logs.length, 0, "[mousedown] not called back");
-        // mouse up
-        handler.mouseup({type: "mouseup",
-                         xy: new OpenLayers.Pixel(10, 10)});
-        t.eq(logs.length, 0, "[mouseup] not called back");
         // double click
         handler.dblclick({type: "dblclick",
                           xy: new OpenLayers.Pixel(10, 10)});
@@ -396,14 +388,6 @@
             {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
         t.ok(feature1.layer == null, "a) feature1 destroyed");
@@ -418,14 +402,6 @@
             {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
         t.ok(feature2.layer != null, "b) feature2 not destroyed");
@@ -439,14 +415,6 @@
             {type: "mouseup", xy: new OpenLayers.Pixel(0, 0)});
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
         t.ok(feature3.layer != null, "c) feature3 not destroyed");
@@ -659,10 +627,6 @@
             {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(10, 10)});
         t.geom_eq(log.geometry,
@@ -723,10 +687,6 @@
             {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(10, 10)});
         t.geom_eq(log.geometry,
@@ -833,10 +793,6 @@
             {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(1, 1)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(1, 1)});
         t.geom_eq(log.geometry,
@@ -883,7 +839,7 @@
                 log = {type: 'modify', geometry: g, feature: f};
             }
         }, {
-            dblclickTolerance: 2
+            doubleTouchTolerance: 2
         });
         control.handler = handler;
         map.addControl(control);
@@ -962,7 +918,7 @@
                 log = {type: 'modify', geometry: g, feature: f};
             }
         }, {
-            dblclickTolerance: 2
+            doubleTouchTolerance: 2
         });
         control.handler = handler;
         map.addControl(control);

Modified: sandbox/elemoine/3272/tests/Handler/Polygon.html
===================================================================
--- sandbox/elemoine/3272/tests/Handler/Polygon.html	2011-04-27 15:00:52 UTC (rev 11919)
+++ sandbox/elemoine/3272/tests/Handler/Polygon.html	2011-04-28 06:03:59 UTC (rev 11920)
@@ -140,7 +140,7 @@
     }
 
     function test_callbacks(t) {
-        t.plan(47);
+        t.plan(45);
         var map = new OpenLayers.Map("map", {
             resolutions: [1]
         });
@@ -284,14 +284,6 @@
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(0, 10)});
         t.eq(logs.length, 0, "[mouseup] not called back");
-        // mouse down
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(0, 10)});
-        t.eq(logs.length, 0, "[mousedown] not called back");
-        // mouse up
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(0, 10)});
-        t.eq(logs.length, 0, "[mouseup] not called back");
         // dblclick
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(0, 10)});
@@ -412,14 +404,6 @@
             {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(2, 2)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
         t.ok(feature1.layer == null, "a) feature1 destroyed");
@@ -440,14 +424,6 @@
             {type: "mouseup", xy: new OpenLayers.Pixel(1, 1)});
         handler.mousemove(
             {type: "mousemove", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(2, 2)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(2, 2)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(2, 2)});
         t.ok(feature2.layer != null, "b) feature2 not destroyed");
@@ -623,8 +599,6 @@
         event = {xy: new OpenLayers.Pixel(-9, 1)};
         trigger("mousedown", event);
         trigger("mouseup", event);
-        trigger("mousedown", event);
-        trigger("mouseup", event);
         trigger("dblclick", event);
         
         // make assertions
@@ -658,8 +632,6 @@
         event = {xy: new OpenLayers.Pixel(-6, 3), altKey: true};
         trigger("mousedown", event);
         trigger("mouseup", event);
-        trigger("mousedown", event);
-        trigger("mouseup", event);
         trigger("dblclick", event);
         
         // make assertions
@@ -694,8 +666,6 @@
         event = {xy: new OpenLayers.Pixel(-2, -2)};
         trigger("mousedown", event);
         trigger("mouseup", event);
-        trigger("mousedown", event);
-        trigger("mouseup", event);
         trigger("dblclick", event);
         
         // make assertions
@@ -734,8 +704,6 @@
         event = {xy: new OpenLayers.Pixel(-1, 1), altKey: true};
         trigger("mousedown", event);
         trigger("mouseup", event);
-        trigger("mousedown", event);
-        trigger("mouseup", event);
         trigger("dblclick", event);
         
         // make assertions
@@ -850,10 +818,6 @@
             {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(10, 10)});
         t.geom_eq(log.geometry,
@@ -926,10 +890,6 @@
             {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
         handler.mouseup(
             {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mousedown(
-            {type: "mousedown", xy: new OpenLayers.Pixel(10, 10)});
-        handler.mouseup(
-            {type: "mouseup", xy: new OpenLayers.Pixel(10, 10)});
         handler.dblclick(
             {type: "dblclick", xy: new OpenLayers.Pixel(10, 10)});
         t.geom_eq(log.geometry,
@@ -968,7 +928,7 @@
                 log = {type: 'modify', geometry: g, feature: f};
             }
         }, {
-            dblclickTolerance: 2
+            doubleTouchTolerance: 2
         });
         control.handler = handler;
         map.addControl(control);
@@ -1065,7 +1025,7 @@
                 log = {type: 'modify', geometry: g, feature: f};
             }
         }, {
-            dblclickTolerance: 2
+            doubleTouchTolerance: 2
         });
         control.handler = handler;
         map.addControl(control);



More information about the Commits mailing list