Skip to content

Commit

Permalink
Fix an issue where some tagged nodes or existing vertices could not b…
Browse files Browse the repository at this point in the history
…e snapped to (close #5942)
  • Loading branch information
quincylvania committed Feb 25, 2019
1 parent 506bb0f commit ced6528
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion modules/behavior/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function behaviorDraw(context) {
}

function allowsVertex(d) {
return _isEmpty(d.tags) || context.presets().allowsVertex(d, context.graph());
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
}

// related code
Expand Down
2 changes: 1 addition & 1 deletion modules/behavior/draw_way.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function behaviorDrawWay(context, wayID, index, mode, startGraph, baselin


function allowsVertex(d) {
return context.presets().allowsVertex(d, context.graph());
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
}


Expand Down
6 changes: 5 additions & 1 deletion modules/behavior/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export function behaviorHover(context) {
.on('mouseup.hover', null, true);
}

function allowsVertex(d) {
return d.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(d, context.graph());
}

function enter(datum) {
if (datum === _target) return;
_target = datum;
Expand Down Expand Up @@ -150,7 +154,7 @@ export function behaviorHover(context) {
}

var suppressed = (_altDisables && d3_event && d3_event.altKey) ||
(entity.type === 'node' && _ignoreVertex && !context.presets().allowsVertex(entity, context.graph()));
(entity.type === 'node' && _ignoreVertex && !allowsVertex(entity));
_selection.selectAll(selector)
.classed(suppressed ? 'hover-suppressed' : 'hover', true);

Expand Down
2 changes: 1 addition & 1 deletion modules/modes/drag_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function modeDragNode(context) {

function shouldSnapToNode(target) {
return _activeEntity.geometry(context.graph()) !== 'vertex' ||
context.presets().allowsVertex(target, context.graph());
(target.geometry(context.graph()) === 'vertex' || context.presets().allowsVertex(target, context.graph()));
}


Expand Down
27 changes: 8 additions & 19 deletions modules/presets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function presetIndex() {
match = keyMatches[i];
}
}

}

if (address && (!match || match.isFallback())) {
Expand All @@ -83,34 +83,23 @@ export function presetIndex() {
if (_isEmpty(entity.tags)) return true;
return resolver.transient(entity, 'vertexMatch', function() {
var vertexPresets = _index.vertex;
var match;

if (entity.isOnAddressLine(resolver)) {
match = true;
return true;
} else {
var didFindMatches = false;
for (var k in entity.tags) {
var keyMatches = vertexPresets[k];
if (!keyMatches) continue;
didFindMatches = true;
for (var i = 0; i < keyMatches.length; i++) {
var preset = keyMatches[i];
if (preset.searchable !== false) {
if (preset.matchScore(entity) > -1) {
match = preset;
break;
}
var preset = keyMatches[i];
if (preset.searchable !== false && preset.matchScore(entity) > -1) {
return preset;
}
}

if (!match && /^addr:/.test(k) && vertexPresets['addr:*']) {
match = true;
}

if (match) break;

}
return !didFindMatches;
}

return match;
});
};

Expand Down

0 comments on commit ced6528

Please sign in to comment.