Refine selection behavior when dragging a node

* Preserve the sidebar state (fixes #1401)
* Show vertices of selected way (fixes #1478)
* Reselect exact previous selection when finished
This commit is contained in:
John Firebaugh
2013-05-29 10:32:11 -07:00
parent 8e6dd17cfc
commit a97e61803c
2 changed files with 15 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ iD.modes.DragNode = function(context) {
activeIDs,
wasMidpoint,
cancelled,
selection = [],
hover = iD.behavior.Hover(context).altDisables(true);
function edge(point, size) {
@@ -120,7 +121,6 @@ iD.modes.DragNode = function(context) {
connectAnnotation(d));
} else if (d.type === 'node' && d.id !== entity.id) {
// `entity` is last so it will survive and it's parent ways can be selected below.
context.replace(
iD.actions.Connect([d.id, entity.id]),
connectAnnotation(d));
@@ -136,11 +136,13 @@ iD.modes.DragNode = function(context) {
moveAnnotation(entity));
}
var parentWays = _.pluck(context.graph().parentWays(entity), 'id');
var reselection = selection.filter(function(id) {
return context.graph().hasEntity(id);
});
if (parentWays.length) {
if (reselection.length) {
context.enter(
iD.modes.Select(context, parentWays)
iD.modes.Select(context, reselection)
.suppressMenu(true));
} else {
context.enter(iD.modes.Browse(context));
@@ -193,6 +195,12 @@ iD.modes.DragNode = function(context) {
stopNudge();
};
mode.selection = function(_) {
if (!arguments.length) return selection;
selection = _;
return mode;
};
mode.behavior = behavior;
return mode;

View File

@@ -10,7 +10,9 @@ iD.modes.Select = function(context, selection) {
iD.behavior.Hover(context),
iD.behavior.Select(context),
iD.behavior.Lasso(context),
iD.modes.DragNode(context).behavior],
iD.modes.DragNode(context)
.selection(selection)
.behavior],
inspector,
radialMenu,
newFeature = false,