mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-14 09:42:56 +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) {
|
function start(entity) {
|
||||||
wasMidpoint = entity.type === 'midpoint';
|
wasMidpoint = entity.type === 'midpoint';
|
||||||
|
|
||||||
var editableIDs = [ entity.id ];
|
// vertices classed "sibling" include: (see svg/vertices.js)
|
||||||
context.graph().parentWays(entity).forEach(function (parentWay) {
|
// - children of selected ways or multipolygons
|
||||||
editableIDs.push(parentWay.id);
|
// - vertices sharing a way with selected vertices
|
||||||
editableIDs = editableIDs.concat(_.map(context.graph().parentRelations(parentWay), 'id'));
|
var selection = d3.selectAll('g.' + entity.id),
|
||||||
});
|
isSibling = !selection.empty() && selection.classed('sibling');
|
||||||
|
|
||||||
isCancelled = d3.event.sourceEvent.shiftKey ||
|
isCancelled = d3.event.sourceEvent.shiftKey || !(wasMidpoint || isSibling) ||
|
||||||
!(wasMidpoint || _.some(editableIDs, function (editableID) { return selectedIDs.indexOf(editableID) !== -1; })) ||
|
|
||||||
context.features().hasHiddenConnections(entity, context.graph());
|
context.features().hasHiddenConnections(entity, context.graph());
|
||||||
|
|
||||||
if (isCancelled) return behavior.cancel();
|
if (isCancelled) {
|
||||||
|
return behavior.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
if (wasMidpoint) {
|
if (wasMidpoint) {
|
||||||
var midpoint = entity;
|
var midpoint = entity;
|
||||||
@@ -105,10 +106,12 @@ export function modeDragNode(context) {
|
|||||||
context.perform(actionNoop());
|
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 = _.map(context.graph().parentWays(entity), 'id');
|
||||||
activeIDs.push(entity.id);
|
activeIDs.push(entity.id);
|
||||||
|
|
||||||
setActiveElements();
|
setActiveElements();
|
||||||
|
|
||||||
context.enter(mode);
|
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) {
|
function icon(entity) {
|
||||||
if (entity.id in icons) return icons[entity.id];
|
if (entity.id in icons) return icons[entity.id];
|
||||||
@@ -105,6 +105,8 @@ export function svgVertices(projection, context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
siblings = siblings || {};
|
||||||
|
|
||||||
var icons = {},
|
var icons = {},
|
||||||
z = (zoom < 17 ? 0 : zoom < 18 ? 1 : 2);
|
z = (zoom < 17 ? 0 : zoom < 18 ? 1 : 2);
|
||||||
|
|
||||||
@@ -141,6 +143,7 @@ export function svgVertices(projection, context) {
|
|||||||
groups
|
groups
|
||||||
.merge(enter)
|
.merge(enter)
|
||||||
.attr('transform', svgPointTransform(projection))
|
.attr('transform', svgPointTransform(projection))
|
||||||
|
.classed('sibling', function(entity) { return entity.id in siblings; })
|
||||||
.classed('shared', function(entity) { return graph.isShared(entity); })
|
.classed('shared', function(entity) { return graph.isShared(entity); })
|
||||||
.classed('endpoint', function(entity) { return entity.isEndpoint(graph); })
|
.classed('endpoint', function(entity) { return entity.isEndpoint(graph); })
|
||||||
.call(setAttributes);
|
.call(setAttributes);
|
||||||
@@ -148,7 +151,7 @@ export function svgVertices(projection, context) {
|
|||||||
|
|
||||||
|
|
||||||
function drawVertices(selection, graph, entities, filter, extent, zoom) {
|
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'),
|
wireframe = context.surface().classed('fill-wireframe'),
|
||||||
vertices = [];
|
vertices = [];
|
||||||
|
|
||||||
@@ -164,7 +167,7 @@ export function svgVertices(projection, context) {
|
|||||||
if (geometry !== 'vertex')
|
if (geometry !== 'vertex')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (entity.id in selected ||
|
if (entity.id in siblings ||
|
||||||
entity.hasInterestingTags() ||
|
entity.hasInterestingTags() ||
|
||||||
entity.isEndpoint(graph) ||
|
entity.isEndpoint(graph) ||
|
||||||
entity.isConnected(graph)) {
|
entity.isConnected(graph)) {
|
||||||
@@ -175,7 +178,7 @@ export function svgVertices(projection, context) {
|
|||||||
var layer = selection.selectAll('.layer-hit');
|
var layer = selection.selectAll('.layer-hit');
|
||||||
layer.selectAll('g.vertex.vertex-persistent')
|
layer.selectAll('g.vertex.vertex-persistent')
|
||||||
.filter(filter)
|
.filter(filter)
|
||||||
.call(draw, vertices, 'vertex-persistent', graph, zoom);
|
.call(draw, vertices, 'vertex-persistent', graph, zoom, siblings);
|
||||||
|
|
||||||
drawHover(selection, graph, extent, zoom);
|
drawHover(selection, graph, extent, zoom);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user