Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You want to listen for the "end" event of the transition.</p> <pre><code>d3.select("#myid").transition().style("opacity","0").each("end", myCallback); </code></pre> <ul> <li><a href="http://mbostock.github.com/d3/ex/stack.html" rel="nofollow noreferrer">This demo</a> uses the "end" event to chain many transitions in order.</li> <li>The <a href="https://github.com/mbostock/d3/blob/master/examples/donut/donut.html" rel="nofollow noreferrer">donut example</a> that ships with D3 also uses this to chain together multiple transitions.</li> <li>Here's <a href="http://phrogz.net/js/d3-playground/#TransitionCallback" rel="nofollow noreferrer">my own demo</a> that changes the style of elements at the start and end of the transition.</li> </ul> <p>From the documentation for <a href="https://github.com/d3/d3-transition/blob/master/README.md#transition_each" rel="nofollow noreferrer"><code>transition.each([type],listener)</code></a>:</p> <blockquote> <p>If <em>type</em> is specified, adds a listener for transition events, supporting both "start" and "end" events. The listener will be invoked for each individual element in the transition, even if the transition has a constant delay and duration. The start event can be used to trigger an instantaneous change as each element starts to transition. The end event can be used to initiate multi-stage transitions by selecting the current element, <code>this</code>, and deriving a new transition. Any transitions created during the end event will inherit the current transition ID, and thus will not override a newer transition that was previously scheduled.</p> </blockquote> <p><em>See <a href="https://groups.google.com/forum/?fromgroups#!topic/d3-js/VnPSh5wkIL4" rel="nofollow noreferrer">this forum thread on the topic</a> for more details.</em></p> <p>Finally, note that if you just want to remove the elements after they have faded out (after the transition has finished), you can use <a href="https://github.com/mbostock/d3/wiki/Transitions#wiki-remove" rel="nofollow noreferrer"><code>transition.remove()</code></a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload