javascript - d3.js中的 'start'事件是什么?

标签 javascript d3.js

我在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/

相关文章:

javascript - Next.js:在 getInitialProps() 中获取数据:服务器端与客户端

javascript - Javascript 可写描述符是否会阻止实例发生更改?

javascript - 过滤 JSON 文件中的数据

javascript - 更改最外层的 svg 大小但保留该 svg 内所有内容的大小

d3.js - 使用 D3 生成的 SVG 不像看似相同的静态 SVG 内容那样缩放

javascript - 为什么 for-of 不跳过稀疏数组的空槽? [JavaScript]

javascript - 如何在 rxjs@5 中制作异步管道?

javascript - 如何将方 block 移动到目的地?

css - 为什么填充不透明度会改变填充的阴影?

svg - D3 : Append duplicates of a selection