mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 05:01:38 +02:00
81feb1cd99
Moves hover-highlighting behavior to its own function Hover-highlighting now correctly highlights all members of the target relation
18 lines
686 B
JavaScript
18 lines
686 B
JavaScript
import _forEach from 'lodash-es/forEach';
|
|
|
|
export function highlightEntity(context, entity, highlighted) {
|
|
|
|
// highlight the member feature in the map while hovering on the list item
|
|
var selectorPrefix = entity.type === 'node' ? 'g.' : 'path.';
|
|
context.surface().selectAll(selectorPrefix+entity.id).classed('highlighted', highlighted);
|
|
if (entity.members) {
|
|
// recursively highlight members so that relations will appear highlighted
|
|
_forEach(entity.members, function(member){
|
|
if (member.id && context.hasEntity(member.id)) {
|
|
highlightEntity(context, context.entity(member.id), highlighted);
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|