【发布时间】:2016-03-01 14:06:00
【问题描述】:
每个人都知道更新/进入/退出模式:
function update(data) {
// DATA JOIN
// Join new data with old elements, if any.
var text = svg.selectAll("text")
.data(data);
// UPDATE
// Update old elements as needed.
text.attr("class", "update");
// ENTER
// Create new elements as needed.
text.enter().append("text")
.attr("class", "enter")
.attr("x", function(d, i) { return i * 32; })
.attr("dy", ".35em");
// ENTER + UPDATE
// Appending to the enter selection expands the update selection to include
// entering elements; so, operations on the update selection after appending to
// the enter selection will apply to both entering and updating nodes.
text.text(function(d) { return d; });
// EXIT
// Remove old elements as needed.
text.exit().transition().duration(2000).attr('transform',
rotation = 25;
return 'translate(' + d.x + ',' + d.y + ') rotate('+ rotation +' 30 30)';
}).remove();
}
我的问题是:
如果我在退出仍在发生时(在 2000 毫秒转换窗口期间)运行此函数,如何防止在已经经历 exit 转换的元素上调用转换。
换句话说,当进行原始选择时,它包括已经处于exit().transition() 状态的元素。因此,如果这些元素尚未完成其转换和removed(),则会再次调用这些元素的退出转换。
我需要做一个过滤器吗? in transition while exiting 有测试吗?
【问题讨论】:
标签: d3.js transition updates exit