Binding an event during an update() transition

前端 未结 1 1444
误落风尘
误落风尘 2021-01-26 13:01

Is it possible to bind an event to a selection during a transition?

For example, let\'s say this is your update:

        g3.selectAll(\".circles\")
              


        
相关标签:
1条回答
  • 2021-01-26 13:21

    Since transitions are a special kind of selections you cannot use all methods available to a selection on a transition. Instead, use transition.each() to bind your handler to the elements in the transition.

    .transition()
        .each(function () {
            d3.select(this).on('mouseover', function mouseoverlogic() {});
        });
    
    0 讨论(0)
提交回复
热议问题