All examples By author By category About

Andrew-Reid

Force Transitions to End State and Trigger End Event (v3)

Based on a request to modify this block to work with d3v3. The original block is based on this Stack Overflow answer and is intended to create a method to flush transitions on a selection.

The bl.ock adds a method to d3.selection() that allows a user to force the transition to its end state:

Circles start are drawn intially as black. On the beginning of the transition, after the delay (the transition is initalized prior to the delay start) the nodes turn green and begin to transition across the screen. When the transition ends, the nodes turn blue.

Clicking on the nodes forces the transition to its end point while triggering the end event (nodes turn blue). I've added a second transition on click to show those nodes that have been clicked, this transition reduces node radii.