Fix getSetValue, fix line display

This commit is contained in:
Tom MacWright
2016-09-03 16:39:30 -04:00
parent b493c85399
commit c5b3a16d3a
4 changed files with 32 additions and 27 deletions

View File

@@ -61,25 +61,29 @@ export function Lines(projection) {
.selectAll('g.layergroup')
.data(d3.range(-10, 11));
layergroup.enter()
layergroup = layergroup.enter()
.append('g')
.attr('class', function(d) { return 'layer layergroup layer' + String(d); });
.attr('class', function(d) { return 'layer layergroup layer' + String(d); })
.merge(layergroup);
var linegroup = layergroup
.selectAll('g.linegroup')
.data(['shadow', 'casing', 'stroke']);
linegroup.enter()
linegroup = linegroup.enter()
.append('g')
.attr('class', function(d) { return 'layer linegroup line-' + d; });
.attr('class', function(d) { return 'layer linegroup line-' + d; })
.merge(linegroup);
var lines = linegroup
.selectAll('path')
.filter(filter)
.data(
function() { return pathdata[this.parentNode.parentNode.__data__] || []; },
function() {
return pathdata[this.parentNode.__data__] || [];
},
Entity.key
);
@@ -88,12 +92,11 @@ export function Lines(projection) {
lines.enter()
.append('path')
.attr('class', function(d) { return 'way line ' + this.parentNode.__data__ + ' ' + d.id; })
.call(TagClasses());
lines
.sort(waystack)
.attr('d', getPath)
.call(TagClasses().tags(RelationMemberTags(graph)));
.call(TagClasses())
.merge(lines)
.sort(waystack)
.attr('d', getPath)
.call(TagClasses().tags(RelationMemberTags(graph)));
lines.exit()
.remove();

View File

@@ -212,7 +212,7 @@ export function address(field, context) {
if (isInitialized) {
updateTags(tags);
} else {
dispatch.call('on', this, 'init', function () {
dispatch.on('init', function () {
updateTags(tags);
});
}

View File

@@ -43,8 +43,9 @@ export function RawTagEditor(context) {
var $list = $wrap.selectAll('.tag-list')
.data([0]);
$list.enter().append('ul')
.attr('class', 'tag-list');
$list = $list.enter().append('ul')
.attr('class', 'tag-list')
.merge($list);
var $newTag = $wrap.selectAll('.add-tag')
.data([0]);
@@ -89,6 +90,8 @@ export function RawTagEditor(context) {
// Update
$items = $items.merge($enter);
$items.order();
$items.each(function(tag) {
@@ -112,7 +115,7 @@ export function RawTagEditor(context) {
.attr('title', function(d) { return d.key; })
.on('blur', keyChange)
.on('change', keyChange),
function(d) { return d.key; }
function(d) { console.log(d, this); return d.key; }
);
getSetValue($items.select('input.value')

View File

@@ -1,24 +1,23 @@
// Like selection.property('value', ...), but avoids no-op value sets,
// which can result in layout/repaint thrashing in some situations.
export function getSetValue(target, value) {
export function getSetValue(selection, value) {
function d3_selection_value(value) {
function valueNull() {
delete target.value;
delete this.value;
}
function valueConstant() {
if (target.value !== value) {
target.value = value;
if (this.value !== value) {
this.value = value;
}
}
function valueFunction() {
var x = value.apply(target, arguments);
var x = value.apply(this, arguments);
if (x == null) {
delete target.value;
}
else if (target.value !== x) {
target.value = x;
delete this.value;
} else if (this.value !== x) {
this.value = x;
}
}
@@ -27,8 +26,8 @@ export function getSetValue(target, value) {
? valueFunction : valueConstant);
}
if (!arguments.length) {
return target.property('value');
if (arguments.length === 1) {
return selection.property('value');
}
return target.each(d3_selection_value(value));
return selection.each(d3_selection_value(value));
}