我试图在转换过程中检查并应用类,但会有延迟。我发现这是不可能的。
我试过的一些代码:
citycircles = instamap.append("g")
.selectAll(".city-circles")
.data(points.features)
.enter()
.append("circle");
citycircles.transition().duration().delay(500)
.classed("cities-selected", function(d,i) {
if (i === nearestcircle) return true;
});
d3.selectAll(".city-circles").transition().duration().delay(500)
.classed("cities-selected", function(d,i) {
if (i === nearestcircle) return true;
});
答案 0 :(得分:3)
以下是关于该主题的the man himself:
No plans on supporting that at the moment; to transition classes, native CSS transitions are typically sufficient.
答案 1 :(得分:1)
您可以使用setTimeout
代替
citycircles = instamap.append("g")
.selectAll(".city-circles")
.data(points.features).enter()
.append("circle");
setTimeout(function() {
citycircles.classed("cities-selected",function(d,i) {
if (i === nearestcircle) {
return true
}
});
d3.selectAll(".city-circles").classed("cities-selected",function(d,i) {
if (i === nearestcircle) {
return true
}
});
}, 500);