From be00a526b6c8caf611e18b864dcee8cee8d6a88c Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 22 Dec 2017 11:42:21 -0500 Subject: [PATCH] Make sure all targets are redrawn during a mode change There was an issue where the lines did not redraw their targets right away when entering drag node, which could make it possible for a quick drag node to try to connect to its parent line. With the chooseEdge exclusion it would not connect to the parent nearby, but in another weird part of the line. --- modules/renderer/map.js | 30 ++++++++++++++++++++++++------ modules/svg/vertices.js | 8 ++++++-- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index b2718ec25..a4ebac8a4 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -201,17 +201,35 @@ export function rendererMap(context) { context.on('enter.map', function() { if (map.editable() && !transformed) { - // redraw immediately the objects that are affected by a chnage in selectedIDs. - var all = context.intersects(map.extent()); - var filter = utilFunctor(true); - var graph = context.graph(); - all = context.features().filter(all, graph); + // redraw immediately any objects affected by a change in selectedIDs. + var graph = context.graph(); + var selectedAndParents = {}; + context.selectedIDs().forEach(function(id) { + var entity = graph.hasEntity(id); + if (entity) { + selectedAndParents[entity.id] = entity; + if (entity.type === 'node') { + graph.parentWays(entity).forEach(function(parent) { + selectedAndParents[parent.id] = parent; + }); + } + } + }); + var data = _values(selectedAndParents); + var filter = function(d) { return d.id in selectedAndParents; }; + + data = context.features().filter(data, graph); + surface.selectAll('.data-layer-osm') .call(drawVertices.drawSelected, graph, map.extent()) - .call(drawMidpoints, graph, all, filter, map.trimmedExtent()); + .call(drawLines, graph, data, filter) + .call(drawAreas, graph, data, filter) + .call(drawMidpoints, graph, data, filter, map.trimmedExtent()); + dispatch.call('drawn', this, { full: false }); + // redraw everything else later scheduleRedraw(); } diff --git a/modules/svg/vertices.js b/modules/svg/vertices.js index a0584b501..1a5ed0a88 100644 --- a/modules/svg/vertices.js +++ b/modules/svg/vertices.js @@ -345,7 +345,7 @@ export function svgVertices(projection, context) { // Draw the vertices.. // The filter function controls the scope of what objects d3 will touch (exit/enter/update) - // It's important to adjust the filter function to expand the scope beyond whatever entities were passed in. + // Adjust the filter function to expand the scope beyond whatever entities were passed in. var filterRendered = function(d) { return d.id in _currPersistent || d.id in _currSelected || d.id in _currHover || filter(d); }; @@ -353,8 +353,12 @@ export function svgVertices(projection, context) { .call(draw, graph, currentVisible(all), sets, filterRendered); // Draw touch targets.. + // When drawing, render all targets (not just those affected by a partial redraw) + var filterTouch = function(d) { + return isMoving ? true : filterRendered(d); + }; selection.selectAll('.layer-points .layer-points-targets') - .call(drawTargets, graph, currentVisible(all), filterRendered); + .call(drawTargets, graph, currentVisible(all), filterTouch); function currentVisible(which) {