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) {