Fix prior commit

Apply same node snap suppression behavior to dragging vertices as to drawing ways
This commit is contained in:
Quincy Morgan
2019-02-15 10:28:43 -05:00
parent 55c10d2183
commit 96a1ec92c7
3 changed files with 15 additions and 9 deletions

View File

@@ -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);

View File

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

View File

@@ -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;