mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 09:42:56 +00:00
Exit select mode if selected DOM elements have disappeared
This commit is contained in:
@@ -205,7 +205,7 @@ window.iD = function () {
|
|||||||
context.background = function() { return background; };
|
context.background = function() { return background; };
|
||||||
|
|
||||||
/* Features */
|
/* Features */
|
||||||
var features = iD.Features(context);
|
var features = iD.Features();
|
||||||
context.features = function() { return features; };
|
context.features = function() { return features; };
|
||||||
context.hasHiddenConnections = function(id) {
|
context.hasHiddenConnections = function(id) {
|
||||||
var graph = history.graph(),
|
var graph = history.graph(),
|
||||||
|
|||||||
@@ -137,9 +137,16 @@ iD.modes.Select = function(context, selectedIDs) {
|
|||||||
.call(keybinding);
|
.call(keybinding);
|
||||||
|
|
||||||
function selectElements() {
|
function selectElements() {
|
||||||
context.surface()
|
var selection = context.surface()
|
||||||
.selectAll(iD.util.entityOrMemberSelector(selectedIDs, context.graph()))
|
.selectAll(iD.util.entityOrMemberSelector(selectedIDs, context.graph()));
|
||||||
.classed('selected', true);
|
|
||||||
|
if (selection.empty()) {
|
||||||
|
// Exit mode if selected DOM elements have disappeared..
|
||||||
|
context.enter(iD.modes.Browse(context));
|
||||||
|
} else {
|
||||||
|
selection
|
||||||
|
.classed('selected', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
context.map().on('drawn.select', selectElements);
|
context.map().on('drawn.select', selectElements);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
iD.Features = function(context) {
|
iD.Features = function() {
|
||||||
var major_roads = {
|
var major_roads = {
|
||||||
'motorway': true,
|
'motorway': true,
|
||||||
'motorway_link': true,
|
'motorway_link': true,
|
||||||
@@ -378,21 +378,13 @@ iD.Features = function(context) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
features.filter = function(d, resolver) {
|
features.filter = function(d, resolver) {
|
||||||
var selected = context.selectedIDs(),
|
var result = [];
|
||||||
result = [];
|
|
||||||
|
|
||||||
if (!_hidden.length) {
|
if (!_hidden.length) {
|
||||||
return d;
|
return d;
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0, imax = d.length; i !== imax; i++) {
|
for (var i = 0, imax = d.length; i !== imax; i++) {
|
||||||
if (features.isHidden(d[i], resolver)) {
|
if (!features.isHidden(d[i], resolver)) {
|
||||||
for (var j = 0, jmax = selected.length; j !== jmax; j++) {
|
|
||||||
if (selected[j] === d[i].id) {
|
|
||||||
context.enter(iD.modes.Browse(context));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result.push(d[i]);
|
result.push(d[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user