mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 17:23:02 +00:00
Child and sibling vertices should be eligible for drag_node
(closes #3799, see also #3801)
This commit is contained in:
@@ -81,17 +81,18 @@ export function modeDragNode(context) {
|
||||
function start(entity) {
|
||||
wasMidpoint = entity.type === 'midpoint';
|
||||
|
||||
var editableIDs = [ entity.id ];
|
||||
context.graph().parentWays(entity).forEach(function (parentWay) {
|
||||
editableIDs.push(parentWay.id);
|
||||
editableIDs = editableIDs.concat(_.map(context.graph().parentRelations(parentWay), 'id'));
|
||||
});
|
||||
// vertices classed "sibling" include: (see svg/vertices.js)
|
||||
// - children of selected ways or multipolygons
|
||||
// - vertices sharing a way with selected vertices
|
||||
var selection = d3.selectAll('g.' + entity.id),
|
||||
isSibling = !selection.empty() && selection.classed('sibling');
|
||||
|
||||
isCancelled = d3.event.sourceEvent.shiftKey ||
|
||||
!(wasMidpoint || _.some(editableIDs, function (editableID) { return selectedIDs.indexOf(editableID) !== -1; })) ||
|
||||
isCancelled = d3.event.sourceEvent.shiftKey || !(wasMidpoint || isSibling) ||
|
||||
context.features().hasHiddenConnections(entity, context.graph());
|
||||
|
||||
if (isCancelled) return behavior.cancel();
|
||||
if (isCancelled) {
|
||||
return behavior.cancel();
|
||||
}
|
||||
|
||||
if (wasMidpoint) {
|
||||
var midpoint = entity;
|
||||
@@ -105,10 +106,12 @@ export function modeDragNode(context) {
|
||||
context.perform(actionNoop());
|
||||
}
|
||||
|
||||
// activeIDs generate no pointer events. This prevents the node or vertex
|
||||
// being dragged from trying to connect to itself or its parent element.
|
||||
activeIDs = _.map(context.graph().parentWays(entity), 'id');
|
||||
activeIDs.push(entity.id);
|
||||
|
||||
setActiveElements();
|
||||
|
||||
context.enter(mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ export function svgVertices(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
function draw(selection, vertices, klass, graph, zoom) {
|
||||
function draw(selection, vertices, klass, graph, zoom, siblings) {
|
||||
|
||||
function icon(entity) {
|
||||
if (entity.id in icons) return icons[entity.id];
|
||||
@@ -105,6 +105,8 @@ export function svgVertices(projection, context) {
|
||||
}
|
||||
|
||||
|
||||
siblings = siblings || {};
|
||||
|
||||
var icons = {},
|
||||
z = (zoom < 17 ? 0 : zoom < 18 ? 1 : 2);
|
||||
|
||||
@@ -141,6 +143,7 @@ export function svgVertices(projection, context) {
|
||||
groups
|
||||
.merge(enter)
|
||||
.attr('transform', svgPointTransform(projection))
|
||||
.classed('sibling', function(entity) { return entity.id in siblings; })
|
||||
.classed('shared', function(entity) { return graph.isShared(entity); })
|
||||
.classed('endpoint', function(entity) { return entity.isEndpoint(graph); })
|
||||
.call(setAttributes);
|
||||
@@ -148,7 +151,7 @@ export function svgVertices(projection, context) {
|
||||
|
||||
|
||||
function drawVertices(selection, graph, entities, filter, extent, zoom) {
|
||||
var selected = siblingAndChildVertices(context.selectedIDs(), graph, extent),
|
||||
var siblings = siblingAndChildVertices(context.selectedIDs(), graph, extent),
|
||||
wireframe = context.surface().classed('fill-wireframe'),
|
||||
vertices = [];
|
||||
|
||||
@@ -164,7 +167,7 @@ export function svgVertices(projection, context) {
|
||||
if (geometry !== 'vertex')
|
||||
continue;
|
||||
|
||||
if (entity.id in selected ||
|
||||
if (entity.id in siblings ||
|
||||
entity.hasInterestingTags() ||
|
||||
entity.isEndpoint(graph) ||
|
||||
entity.isConnected(graph)) {
|
||||
@@ -175,7 +178,7 @@ export function svgVertices(projection, context) {
|
||||
var layer = selection.selectAll('.layer-hit');
|
||||
layer.selectAll('g.vertex.vertex-persistent')
|
||||
.filter(filter)
|
||||
.call(draw, vertices, 'vertex-persistent', graph, zoom);
|
||||
.call(draw, vertices, 'vertex-persistent', graph, zoom, siblings);
|
||||
|
||||
drawHover(selection, graph, extent, zoom);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user