Fix transitioning styles to null (removal).
This commit is contained in:
Родитель
fe6128180e
Коммит
878d1c1c13
|
@ -1856,9 +1856,18 @@ function d3_transition(groups, id) {
|
|||
return groups;
|
||||
}
|
||||
|
||||
function d3_transitionTweenNull() {
|
||||
return d3_transitionTweenNullNull;
|
||||
}
|
||||
|
||||
function d3_transitionTweenNullNull() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function d3_transitionTween(b) {
|
||||
return typeof b === "function"
|
||||
? function(d, i, a) { var v = b.call(this, d, i) + ""; return a != v && d3.interpolate(a, v); }
|
||||
: b == null ? d3_transitionTweenNull
|
||||
: (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); });
|
||||
}
|
||||
|
||||
|
@ -1951,7 +1960,11 @@ d3_transitionPrototype.styleTween = function(name, tween, priority) {
|
|||
return this.tween("style." + name, function(d, i) {
|
||||
var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name));
|
||||
return f && function(t) {
|
||||
this.style.setProperty(name, f(t), priority);
|
||||
if ((t = f(t))) {
|
||||
this.style.setProperty(name, t, priority);
|
||||
} else {
|
||||
this.style.removeProperty(name);
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -8,7 +8,11 @@ d3_transitionPrototype.styleTween = function(name, tween, priority) {
|
|||
return this.tween("style." + name, function(d, i) {
|
||||
var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name));
|
||||
return f && function(t) {
|
||||
this.style.setProperty(name, f(t), priority);
|
||||
if ((t = f(t))) {
|
||||
this.style.setProperty(name, t, priority);
|
||||
} else {
|
||||
this.style.removeProperty(name);
|
||||
}
|
||||
};
|
||||
});
|
||||
};
|
||||
|
|
|
@ -85,9 +85,18 @@ function d3_transition(groups, id) {
|
|||
return groups;
|
||||
}
|
||||
|
||||
function d3_transitionTweenNull() {
|
||||
return d3_transitionTweenNullNull;
|
||||
}
|
||||
|
||||
function d3_transitionTweenNullNull() {
|
||||
return null;
|
||||
}
|
||||
|
||||
function d3_transitionTween(b) {
|
||||
return typeof b === "function"
|
||||
? function(d, i, a) { var v = b.call(this, d, i) + ""; return a != v && d3.interpolate(a, v); }
|
||||
: b == null ? d3_transitionTweenNull
|
||||
: (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); });
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@ module.exports = {
|
|||
|
||||
var s = d3.select("body").append("div")
|
||||
.style("background-color", "white")
|
||||
.style("color", "red");
|
||||
.style("color", "red")
|
||||
.style("display", "none");
|
||||
|
||||
var t = s.transition()
|
||||
.style("display", null)
|
||||
.style("background-color", "green")
|
||||
.style("background-color", "red")
|
||||
.style("color", function() { return "green"; }, "important")
|
||||
|
@ -34,5 +36,8 @@ module.exports = {
|
|||
var style = result.selection.node().style;
|
||||
assert.equal(style.getPropertyPriority("background-color"), "");
|
||||
assert.equal(style.getPropertyPriority("color"), "important");
|
||||
},
|
||||
"removes a style": function(result) {
|
||||
assert.equal(result.selection.style("display"), "");
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче