From cb55cdafe201f331c8d1fac52944282be89cad8a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Dec 2012 16:29:41 -0500 Subject: [PATCH 1/3] Defer drag events until first move (fixes #105) --- js/id/renderer/map.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index cee9ab0eb..edc284b23 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -14,24 +14,34 @@ iD.Map = function() { .on('zoom', zoomPan), only, dblclickEnabled = true, + dragging = false, dragbehavior = d3.behavior.drag() .origin(function(entity) { var p = projection(ll2a(entity)); - only = iD.Util.trueObj([entity.id].concat( - _.pluck(map.history.graph().parents(entity.id), 'id'))); return { x: p[0], y: p[1] }; }) - .on('dragstart', function() { - map.history.perform(iD.actions.noop()); - d3.event.sourceEvent.stopPropagation(); - }) .on('drag', function(entity) { - var to = projection.invert([d3.event.x, d3.event.y]); d3.event.sourceEvent.stopPropagation(); + + if (!dragging) { + dragging = true; + only = iD.Util.trueObj([entity.id].concat( + _.pluck(map.history.graph().parents(entity.id), 'id'))); + map.history.perform(iD.actions.noop()); + } + + var to = projection.invert([d3.event.x, d3.event.y]); map.history.replace(iD.actions.move(entity, to)); + redraw(only); }) - .on('dragend', redraw), + .on('dragend', function () { + if (dragging) { + dragging = false; + map.update(); + redraw(); + } + }), nodeline = function(d) { return 'M' + d.nodes.map(ll2a).map(projection).map(roundCoords).join('L'); }, From c1be31912fc084b5d6715ae68601ad7f44ebf53d Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Dec 2012 17:00:06 -0500 Subject: [PATCH 2/3] Fix specs --- test/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/test/index.html b/test/index.html index 970f0f52c..a3442fc15 100644 --- a/test/index.html +++ b/test/index.html @@ -28,6 +28,7 @@ + From 65c1d632ede552742d746ba9e5e4fe48789e2548 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 3 Dec 2012 17:01:12 -0500 Subject: [PATCH 3/3] text/javascript is default script type --- index.html | 64 +++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/index.html b/index.html index 0d917d083..00328236d 100644 --- a/index.html +++ b/index.html @@ -12,43 +12,43 @@ - - - - - - - - + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - + - - - + + + - - - - - + + + + +