diff --git a/modules/behavior/draw.js b/modules/behavior/draw.js index dd6b9e0a0..81461c4e7 100644 --- a/modules/behavior/draw.js +++ b/modules/behavior/draw.js @@ -27,7 +27,7 @@ export function behaviorDraw(context) { var keybinding = utilKeybinding('draw'); - var hover = behaviorHover(context).altDisables(true).ignoreVertex(true) + var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true) .on('hover', context.ui().sidebar.hover); var tail = behaviorTail(); var edit = behaviorEdit(context); @@ -195,7 +195,7 @@ export function behaviorDraw(context) { function behavior(selection) { - context.install(hover); + context.install(_hover); context.install(edit); if (!context.inIntro() && !_usedTails[tail.text()]) { @@ -225,7 +225,7 @@ export function behaviorDraw(context) { behavior.off = function(selection) { context.ui().sidebar.hover.cancel(); - context.uninstall(hover); + context.uninstall(_hover); context.uninstall(edit); if (!context.inIntro() && !_usedTails[tail.text()]) { @@ -253,6 +253,10 @@ export function behaviorDraw(context) { return behavior; }; + behavior.hover = function() { + return _hover; + }; + return utilRebind(behavior, dispatch, 'on'); } diff --git a/modules/behavior/draw_way.js b/modules/behavior/draw_way.js index 93846eb0b..f40938821 100644 --- a/modules/behavior/draw_way.js +++ b/modules/behavior/draw_way.js @@ -17,15 +17,16 @@ import { modeBrowse, modeSelect } from '../modes'; import { osmNode } from '../osm'; import { utilKeybinding } from '../util'; -import _isEmpty from 'lodash-es/isEmpty'; - export function behaviorDrawWay(context, wayId, index, mode, startGraph) { var origWay = context.entity(wayId); var annotation = t((origWay.isDegenerate() ? 'operations.start.annotation.' : 'operations.continue.annotation.') + context.geometry(wayId) ); + var behavior = behaviorDraw(context); + behavior.hover().initialNodeId(index ? origWay.nodes[index] : origWay.nodes[origWay.nodes.length - 1]); + var _tempEdits = 0; var end = osmNode({ loc: context.map().mouseCoordinates() }); @@ -67,7 +68,7 @@ export function behaviorDrawWay(context, wayId, index, mode, startGraph) { } function allowsVertex(d) { - return _isEmpty(d.tags) || context.presets().allowsVertex(d, context.graph()); + return context.presets().allowsVertex(d, context.graph()); } // related code diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index 4291abdd8..20f759a22 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -20,7 +20,8 @@ import { utilKeybinding, utilRebind } from '../util'; export function behaviorHover(context) { var dispatch = d3_dispatch('hover'); var _selection = d3_select(null); - var _newId = null; + var _newNodeId = null; + var _initialNodeId = null; var _buttonDown; var _altDisables; var _ignoreVertex; @@ -57,7 +58,13 @@ export function behaviorHover(context) { function behavior(selection) { _selection = selection; - _newId = null; + + if (_initialNodeId) { + _newNodeId = _initialNodeId; + _initialNodeId = null; + } else { + _newNodeId = null; + } _selection .on('mouseover.hover', mouseover) @@ -134,11 +141,11 @@ export function behaviorHover(context) { } // Update hover state and dispatch event - if (entity && entity.id !== _newId) { + if (entity && entity.id !== _newNodeId) { // If drawing a way, don't hover on a node that was just placed. #3974 var mode = context.mode() && context.mode().id; - if ((mode === 'draw-line' || mode === 'draw-area') && !_newId && entity.type === 'node') { - _newId = entity.id; + if ((mode === 'draw-line' || mode === 'draw-area') && !_newNodeId && entity.type === 'node') { + _newNodeId = entity.id; return; } @@ -187,5 +194,10 @@ export function behaviorHover(context) { return behavior; }; + behavior.initialNodeId = function(nodeId) { + _initialNodeId = nodeId; + return behavior; + }; + return utilRebind(behavior, dispatch, 'on'); }