我在Bostock的most recent block中注意到他发生了“开始”事件:
d3.select("body").selectAll("div")
.data(d3.range(n))
.enter().append("div")
.transition()
.delay(function(d, i) { return i + Math.random() * n / 4; })
.ease(d3.easeLinear)
.on("start", function repeat() {
d3.active(this)
.styleTween("background-color", function() { return whiteblue; })
.transition()
.delay(1000)
.styleTween("background-color", function() { return blueorange; })
.transition()
.delay(1000)
.styleTween("background-color", function() { return orangewhite; })
.transition()
.delay(n)
.on("start", repeat);
});
有人知道这是什么吗?
它等于有负载,还是在过渡开始的延迟时间后触发?
最佳答案
该块用d3
v4编写。看来v3 transition.each已重命名为transition.on(这更有意义)。也就是说start
一直是过渡的事件类型:
If type is specified, adds a listener for transition events, supporting "start", "end" and "interrupt" events. The listener will be invoked for each individual element in the transition.
The start event is invoked during the first asynchronous callback (tick) of the transition, before any tweens are invoked. For transitions with zero delay, this is typically about 17ms after the transition is scheduled. State events are useful for triggering instantaneous changes to each element, such as changing attributes that cannot be interpolated.
要回答您的特定问题(上面我的粗体),或者是针对延迟时间过后开始过渡的问题?
关于javascript - d3.js中的 'start'事件是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35354171/