diff --git a/modules/behavior/hover.js b/modules/behavior/hover.js index 311f51d92..4291abdd8 100644 --- a/modules/behavior/hover.js +++ b/modules/behavior/hover.js @@ -8,8 +8,6 @@ import { import { osmEntity, osmNote, qaError } from '../osm'; import { utilKeybinding, utilRebind } from '../util'; -import _isEmpty from 'lodash-es/isEmpty'; - /* The hover behavior adds the `.hover` class on mouseover to all elements to which the identical datum is bound, and removes it on mouseout. @@ -98,10 +96,6 @@ export function behaviorHover(context) { .on('mouseup.hover', null, true); } - function allowsVertex(d) { - return _isEmpty(d.tags) || context.presets().allowsVertex(d, context.graph()); - } - function enter(datum) { if (datum === _target) return; _target = datum; @@ -149,7 +143,7 @@ export function behaviorHover(context) { } var suppressed = (_altDisables && d3_event && d3_event.altKey) || - (entity === 'node' && _ignoreVertex && !allowsVertex(entity, context.graph())); + (entity.type === 'node' && _ignoreVertex && !context.presets().allowsVertex(entity, context.graph())); _selection.selectAll(selector) .classed(suppressed ? 'hover-suppressed' : 'hover', true); diff --git a/modules/modes/drag_node.js b/modules/modes/drag_node.js index cd121d920..66dd2dfa0 100644 --- a/modules/modes/drag_node.js +++ b/modules/modes/drag_node.js @@ -96,6 +96,12 @@ export function modeDragNode(context) { } + function shouldSnapToNode(target) { + return _activeEntity.geometry(context.graph()) !== 'vertex' || + context.presets().allowsVertex(target, context.graph()); + } + + function origin(entity) { return context.projection(entity.loc); } @@ -158,6 +164,8 @@ export function modeDragNode(context) { _activeEntity = entity; _startLoc = entity.loc; + hover.ignoreVertex(entity.geometry(context.graph()) === 'vertex'); + context.surface().selectAll('.' + _activeEntity.id) .classed('active', true); @@ -199,7 +207,9 @@ export function modeDragNode(context) { var edge; if (targetLoc) { // snap to node/vertex - a point target with `.loc` - loc = targetLoc; + if (shouldSnapToNode(target)) { + loc = targetLoc; + } } else if (targetNodes) { // snap to way - a line target with `.nodes` edge = geoChooseEdge(targetNodes, context.mouse(), context.projection, end.id); @@ -377,7 +387,7 @@ export function modeDragNode(context) { connectAnnotation(entity, target) ); - } else if (target && target.type === 'node') { + } else if (target && target.type === 'node' && shouldSnapToNode(target)) { context.replace( actionConnect([target.id, entity.id]), connectAnnotation(entity, target) diff --git a/modules/presets/index.js b/modules/presets/index.js index bf2452fae..873cb6579 100644 --- a/modules/presets/index.js +++ b/modules/presets/index.js @@ -1,5 +1,6 @@ import _bind from 'lodash-es/bind'; import _forEach from 'lodash-es/forEach'; +import _isEmpty from 'lodash-es/isEmpty'; import _reject from 'lodash-es/reject'; import _uniq from 'lodash-es/uniq'; @@ -79,6 +80,7 @@ export function presetIndex() { all.allowsVertex = function(entity, resolver) { if (entity.type !== 'node') return false; + if (_isEmpty(entity.tags)) return true; return resolver.transient(entity, 'vertexMatch', function() { var vertexPresets = _index.vertex; var match;