mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-07 20:01:33 +00:00
Disable double-clicking when drawing. Fixes #134
This commit is contained in:
@@ -62,6 +62,7 @@ iD.modes.AddRoad = {
|
||||
});
|
||||
},
|
||||
enter: function() {
|
||||
this.map.dblclickEnable(false);
|
||||
var surface = this.map.surface;
|
||||
var teaser = surface.selectAll('g#temp-g')
|
||||
.append('g').attr('id', 'addroad');
|
||||
@@ -104,6 +105,7 @@ iD.modes.AddRoad = {
|
||||
}.bind(this));
|
||||
},
|
||||
exit: function() {
|
||||
this.map.dblclickEnable(true);
|
||||
this.map.surface.on('click.addroad', null);
|
||||
this.map.surface.on('mousemove.addroad', null);
|
||||
d3.select(document).on('keydown.addroad', null);
|
||||
@@ -114,6 +116,7 @@ iD.modes.AddRoad = {
|
||||
iD.modes.DrawRoad = function(way_id) {
|
||||
return {
|
||||
enter: function() {
|
||||
this.map.dblclickEnable(false);
|
||||
var surface = this.map.surface,
|
||||
|
||||
nextnode = iD.modes._node([NaN, NaN]);
|
||||
@@ -167,6 +170,9 @@ iD.modes.DrawRoad = function(way_id) {
|
||||
this.map.surface.on('click.drawroad', null);
|
||||
d3.select(document).on('.drawroad', null);
|
||||
d3.selectAll('#drawroad').remove();
|
||||
window.setTimeout(function() {
|
||||
this.map.dblclickEnable(true);
|
||||
}.bind(this), 1000);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,6 +16,7 @@ iD.Map = function(elem, connection) {
|
||||
.scaleExtent([256, 134217728])
|
||||
.on('zoom', zoomPan),
|
||||
only,
|
||||
dblclickEnabled = false,
|
||||
dragbehavior = d3.behavior.drag()
|
||||
.origin(function(entity) {
|
||||
var p = projection(ll2a(entity));
|
||||
@@ -385,6 +386,8 @@ iD.Map = function(elem, connection) {
|
||||
});
|
||||
|
||||
function zoomPan() {
|
||||
if (d3.event && d3.event.sourceEvent.type === "dblclick" &&
|
||||
!dblclickEnabled) return;
|
||||
var fast = (d3.event.scale === projection.scale());
|
||||
projection
|
||||
.translate(d3.event.translate)
|
||||
@@ -424,7 +427,6 @@ iD.Map = function(elem, connection) {
|
||||
}
|
||||
|
||||
function update() {
|
||||
// map.update();
|
||||
redraw();
|
||||
}
|
||||
|
||||
@@ -443,6 +445,12 @@ iD.Map = function(elem, connection) {
|
||||
update();
|
||||
}
|
||||
|
||||
function dblclickEnable(_) {
|
||||
if (!arguments.length) return dblclickEnabled;
|
||||
dblclickEnabled = _;
|
||||
return map;
|
||||
}
|
||||
|
||||
function getExtent() {
|
||||
return [projection.invert([0, 0]), projection.invert(dimensions)];
|
||||
}
|
||||
@@ -533,6 +541,7 @@ iD.Map = function(elem, connection) {
|
||||
map.redraw = redraw;
|
||||
|
||||
map.flush = flush;
|
||||
map.dblclickEnable = dblclickEnable;
|
||||
|
||||
setSize([parent.node().offsetWidth, parent.node().offsetHeight]);
|
||||
hideInspector();
|
||||
|
||||
Reference in New Issue
Block a user