# d3-transition
**Repository Path**: d3js/d3-transition
## Basic Information
- **Project Name**: d3-transition
- **Description**: No description available
- **Primary Language**: JavaScript
- **License**: BSD-3-Clause
- **Default Branch**: cancel
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2025-06-05
- **Last Updated**: 2025-06-05
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# d3-transition
A transition is a [selection](https://github.com/d3/d3-selection)-like interface to animate changes to DOM elements smoothly over time, instead of applying those changes instantaneously. To start a transition, select some elements, call [*selection*.transition](#selection_transition), and then apply the desired transition methods. For example:
```js
d3.select("body")
.transition()
.style("background-color", "red");
```
While transitions and selections share many similar methods, they operate somewhat differently; see below for details.
D3 has many [built-in interpolators](https://github.com/d3/d3-interpolate) to tween arbitrary values. For example, you can transition from the font `500 12px sans-serif` to `300 42px sans-serif`, and D3 will find the numbers embedded within the string, interpolating both font size and weight automatically. To specify a custom interpolator, use [*transition*.attrTween](#transition_attrTween), [*transition*.styleTween](#transition_styleTween) or [*transition*.tween](#transition_tween).
Only one transition of a given name may be *active* on a given element at a given time. However, multiple transitions with different names may be simultaneously active on the element, and multiple transitions with the same name may be *scheduled* on the element, provided they do not overlap in time. See [*transition*.transition](#transition_transition), for example.
If a newer transition starts on a given element, it automatically interrupts any active transition and cancels any pending transitions. This allows new transitions to supersede old transitions, such as in response to a user event, even if the old transitions were delayed. To manually interrupt transitions, use [*selection*.interrupt](#selection_interrupt). To run multiple transitions simultaneously on a given element or elements, give each transition a [unique name](#selection_transition).
For more on transitions, see [Working with Transitions](http://bost.ocks.org/mike/transition/).
## Installing
If you use NPM, `npm install d3-transition`. Otherwise, download the [latest release](https://github.com/d3/d3-transition/releases/latest). The released bundle supports AMD, CommonJS, and vanilla environments. Create a custom build using [Rollup](https://github.com/rollup/rollup) or your preferred bundler. You can also load directly from [d3js.org](https://d3js.org):
```html
```
In a vanilla environment, a `d3_transition` global is exported. [Try d3-transition in your browser.](https://tonicdev.com/npm/d3-transition)
## API Reference
* [Selecting Elements](#selecting-elements)
* [Modifying Elements](#modifying-elements)
* [Timing](#timing)
* [Control Flow](#control-flow)
### Selecting Elements
# selection.transition([name])
…
# selection.interrupt([name])
…
# d3.transition([name])
Equivalent to:
```js
d3.selection().transition(name)
```
Also, d3.transition can be used to check whether something is an `instanceof` a transition, and to extend or modify the transition prototype.
# transition.select(selector)
…
# transition.selectAll(selector)
…
# transition.filter(filter)
…
# transition.merge(selection)
Returns a new transition merging this transition with the specified *selection* (or *transition*). The returned transition has the same number of groups, the same parents, the same name and the same id as this transition. Any missing (null) elements in this transition are filled with the corresponding element, if present (not null), from the specified *selection*. See [*selection*.merge](https://github.com/d3/d3-selection#selection_merge) for more information.
# transition.transition()
…
# transition.selection()
Returns the [selection](https://github.com/d3/d3-selection#selection) corresponding to this transition.
# d3.active(node[, name])
Returns the active transition on the specified *node* with the specified *name*, if any. If no *name* is specified, the default empty name is used. Returns null if there is no such active transition on the specified node.
### Modifying Elements
…
# transition.attr(name, value)
… Note that unlike [*selection*.attr](https://github.com/d3/d3-selection#selection_attr), *value* is required.
# transition.attrTween(name[, value])
…
# transition.style(name, value[, priority])
… Note that unlike [*selection*.style](https://github.com/d3/d3-selection#selection_style), *value* is required.
# transition.styleTween(name[, value[, priority]]))
…
# transition.text(value)
… Note that unlike [*selection*.text](https://github.com/d3/d3-selection#selection_text), *value* is required.
# transition.remove()
…
# transition.tween(name[, value])
…
### Timing
Transitions may have per-element delays and durations, computed using functions of data (or index) as with other selection methods. For example, you can sort and reorder elements with a staggered delay to make the change in order easier to perceive. For more on this topic, see [Animated Transitions in Statistical Data Graphics](http://vis.berkeley.edu/papers/animated_transitions/) by Heer & Robertson.
# transition.delay([value])
…
# transition.duration([value])
…
# transition.ease([value])
…
### Control Flow
…
# transition.on(typenames[, listener])
…
# transition.each(function)
…
# transition.call(function[, arguments…])
…
# transition.empty()
…
# transition.nodes()
…
# transition.node()
…
# transition.size()
…