mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-18 14:45:12 +02:00
Add .hoverEnable to map and disable it for drawing-related modes. Fixes #234
This commit is contained in:
@@ -12,6 +12,7 @@ iD.modes.AddArea = function() {
|
||||
controller = mode.controller;
|
||||
|
||||
map.dblclickEnable(false)
|
||||
.hoverEnable(false)
|
||||
.hint('Click on the map to start drawing an area, like a park, lake, or building.');
|
||||
|
||||
map.surface.on('click.addarea', function() {
|
||||
@@ -47,7 +48,8 @@ iD.modes.AddArea = function() {
|
||||
|
||||
mode.exit = function() {
|
||||
window.setTimeout(function() {
|
||||
mode.map.dblclickEnable(true);
|
||||
mode.map.dblclickEnable(true)
|
||||
.hoverEnable(true);
|
||||
}, 1000);
|
||||
mode.map.hint(false);
|
||||
mode.map.surface.on('click.addarea', null);
|
||||
|
||||
@@ -13,6 +13,8 @@ iD.modes.AddLine = function() {
|
||||
controller = mode.controller;
|
||||
|
||||
map.dblclickEnable(false)
|
||||
.hoverEnable(false)
|
||||
.hoverEnable(false)
|
||||
.hint('Click on the map to start drawing an road, path, or route.');
|
||||
|
||||
map.surface.on('click.addline', function() {
|
||||
@@ -68,7 +70,7 @@ iD.modes.AddLine = function() {
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
mode.map.dblclickEnable(true);
|
||||
mode.map.dblclickEnable(true).hoverEnable(true);
|
||||
mode.map.hint(false);
|
||||
mode.map.surface.on('click.addline', null);
|
||||
mode.map.keybinding().on('⎋.addline', null);
|
||||
|
||||
@@ -10,6 +10,8 @@ iD.modes.AddPoint = function() {
|
||||
history = mode.history,
|
||||
controller = mode.controller;
|
||||
|
||||
map.hoverEnable(false);
|
||||
|
||||
map.hint('Click on the map to add a point.');
|
||||
|
||||
map.surface.on('click.addpoint', function() {
|
||||
@@ -28,6 +30,7 @@ iD.modes.AddPoint = function() {
|
||||
};
|
||||
|
||||
mode.exit = function() {
|
||||
map.hoverEnable(true);
|
||||
mode.map.hint(false);
|
||||
mode.map.surface.on('click.addpoint', null);
|
||||
mode.map.keybinding().on('⎋.addpoint', null);
|
||||
|
||||
@@ -16,6 +16,7 @@ iD.modes.DrawArea = function(wayId) {
|
||||
node = iD.Node({loc: map.mouseCoordinates()});
|
||||
|
||||
map.dblclickEnable(false)
|
||||
.hoverEnable(false)
|
||||
.fastEnable(false);
|
||||
map.hint('Click on the map to add points to your area. Finish the ' +
|
||||
'area by clicking on your first point');
|
||||
@@ -125,7 +126,8 @@ iD.modes.DrawArea = function(wayId) {
|
||||
|
||||
mode.exit = function() {
|
||||
mode.map.hint(false);
|
||||
mode.map.fastEnable(true);
|
||||
mode.map.fastEnable(true)
|
||||
.hoverEnable(true);
|
||||
|
||||
mode.map.surface
|
||||
.on('mousemove.drawarea', null)
|
||||
|
||||
@@ -16,6 +16,7 @@ iD.modes.DrawLine = function(wayId, direction) {
|
||||
|
||||
map.dblclickEnable(false)
|
||||
.fastEnable(false)
|
||||
.hoverEnable(false)
|
||||
.hint('Click to add more points to the line. ' +
|
||||
'Click on other lines to connect to them, and double-click to ' +
|
||||
'end the line.');
|
||||
@@ -121,7 +122,8 @@ iD.modes.DrawLine = function(wayId, direction) {
|
||||
|
||||
mode.exit = function() {
|
||||
mode.map.hint(false);
|
||||
mode.map.fastEnable(true);
|
||||
mode.map.fastEnable(true)
|
||||
.hoverEnable(true);
|
||||
|
||||
mode.map.surface
|
||||
.on('mousemove.drawline', null)
|
||||
|
||||
@@ -12,6 +12,7 @@ iD.Map = function() {
|
||||
.scaleExtent([1024, 256 * Math.pow(2, 24)])
|
||||
.on('zoom', zoomPan),
|
||||
dblclickEnabled = true,
|
||||
hoverEnabled = true,
|
||||
fastEnabled = true,
|
||||
notice,
|
||||
background = iD.Background()
|
||||
@@ -265,6 +266,7 @@ iD.Map = function() {
|
||||
}
|
||||
|
||||
function hoverIn() {
|
||||
if (!hoverEnabled) return;
|
||||
var datum = d3.select(d3.event.target).datum();
|
||||
if (datum instanceof iD.Entity) {
|
||||
hover = datum.id;
|
||||
@@ -274,7 +276,7 @@ iD.Map = function() {
|
||||
}
|
||||
|
||||
function hoverOut() {
|
||||
if (hover) {
|
||||
if (hoverEnabled && hover) {
|
||||
var oldHover = hover;
|
||||
hover = null;
|
||||
redraw([oldHover]);
|
||||
@@ -350,6 +352,12 @@ iD.Map = function() {
|
||||
return map;
|
||||
};
|
||||
|
||||
map.hoverEnable = function(_) {
|
||||
if (!arguments.length) return hoverEnabled;
|
||||
hoverEnabled = _;
|
||||
return map;
|
||||
};
|
||||
|
||||
map.fastEnable = function(_) {
|
||||
if (!arguments.length) return fastEnabled;
|
||||
fastEnabled = _;
|
||||
|
||||
Reference in New Issue
Block a user