]> git.openstreetmap.org Git - rails.git/commitdiff
Ignore clicks on query results if the mouse has moved
authorTom Hughes <tom@compton.nu>
Mon, 31 Mar 2014 10:33:27 +0000 (11:33 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 31 Mar 2014 10:33:27 +0000 (11:33 +0100)
app/assets/javascripts/index/query.js

index 0edc265dcbe3c43181326ed2bfe90ba11332074a..e2c8699ff0ba2a792a8caaeb975901fe3cdd3f0c 100644 (file)
@@ -53,13 +53,20 @@ OSM.Query = function(map) {
       if (geometry) map.removeLayer(geometry);
       $(this).removeClass("selected");
     })
-    .on("click", ".query-results li.query-result", function (e) {
-      var geometry = $(this).data("geometry")
-      if (geometry) map.removeLayer(geometry);
-
-      if (!$(e.target).is('a')) {
-        $(this).find("a").simulate("click", e);
-      }
+    .on("mousedown", ".query-results li.query-result", function (e) {
+      var moved = false;
+      $(this).one("click", function (e) {
+        if (!moved) {
+          var geometry = $(this).data("geometry")
+          if (geometry) map.removeLayer(geometry);
+
+          if (!$(e.target).is('a')) {
+            $(this).find("a").simulate("click", e);
+          }
+        }
+      }).one("mousemove", function () {
+        moved = true;
+      });
     });
 
   function interestingFeature(feature, origin, radius) {