Skip to content

Commit

Permalink
updated: notes svg to prevent duplicate appending
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-hervey committed Jun 25, 2018
1 parent 1878397 commit 0859d00
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion css/60_photos.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
.layer-notes {
pointer-events: none;
}
.layer-notes .notes * {
.layer-notes * {
color: #eebb00;
}

Expand Down
29 changes: 8 additions & 21 deletions modules/svg/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,32 +61,25 @@ export function svgNotes(projection, context, dispatch) {
var service = getService();
var data = (service ? service.notes(projection) : []);
var transform = svgPointTransform(projection);
var notes = layer.selectAll('.notes').selectAll('.note')
var notes = layer.selectAll('.note')
.data(data, function(d) { return d.key; });

// exit
notes.exit()
.remove();

// enter
var notesEnter = notes.enter()
.append('g')
.attr('class', 'note');

// update
var markers = notes
.merge(notesEnter)
.attr('transform', transform);

markers.selectAll('circle')
.data([0])
.enter()
.append('use')
.attr('class', 'note')
.attr('width', '24px')
.attr('height', '24px')
.attr('x', '-12px')
.attr('y', '-12px')
.attr('xlink:href', '#fas-comment-alt');

notes
.merge(notesEnter)
.attr('transform', transform);
}

function drawNotes(selection) {
Expand All @@ -99,16 +92,10 @@ export function svgNotes(projection, context, dispatch) {
layer.exit()
.remove();

var layerEnter = layer.enter()
layer.enter()
.append('g')
.attr('class', 'layer-notes')
.style('display', enabled ? 'block' : 'none');

layerEnter
.append('g')
.attr('class', 'notes');

layer = layerEnter
.style('display', enabled ? 'block' : 'none')
.merge(layer);

if (enabled) {
Expand Down

0 comments on commit 0859d00

Please sign in to comment.