UNPKG

39.1 kBTypeScriptView Raw
1// Type definitions for D3JS d3-transition module 3.0
2// Project: https://github.com/d3/d3-transition/, https://d3js.org/d3-transition
3// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
4// Alex Ford <https://github.com/gustavderdrache>
5// Boris Yankov <https://github.com/borisyankov>
6// Robert Moura <https://github.com/robertmoura>
7// Nathan Bierema <https://github.com/Methuselah96>
8// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9
10// Last module patch version validated against: 3.0.1
11
12import { ArrayLike, BaseType, Selection, ValueFn } from 'd3-selection';
13
14/**
15 * Extend interface 'Selection' by declaration merging with 'd3-selection'
16 */
17declare module 'd3-selection' {
18 /**
19 * A D3 Selection of elements.
20 *
21 * The first generic "GElement" refers to the type of the selected element(s).
22 * The second generic "Datum" refers to the type of the datum of a selected element(s).
23 * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection.
24 * The fourth generic "PDatum" refers to the type of the datum of the parent element(s).
25 */
26 interface Selection<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> {
27 /**
28 * Interrupts the active transition of the specified name on the selected elements, and cancels any pending transitions with the specified name, if any.
29 * If a name is not specified, null is used.
30 *
31 * IMPORTANT: Interrupting a transition on an element has no effect on any transitions on any descendant elements.
32 * For example, an axis transition consists of multiple independent, synchronized transitions on the descendants of the axis G element
33 * (the tick lines, the tick labels, the domain path, etc.). To interrupt the axis transition, you must therefore interrupt the descendants.
34 *
35 * @param name Name of the transition.
36 */
37 interrupt(name?: string): this;
38 /**
39 * Returns a new transition on the given selection with the specified name. If a name is not specified, null is used.
40 * The new transition is only exclusive with other transitions of the same name.
41 *
42 * @param name Name of the transition.
43 */
44 transition(name?: string): Transition<GElement, Datum, PElement, PDatum>;
45 /**
46 * Returns a new transition on the given selection.
47 *
48 * When using a transition instance, the returned transition has the same id and name as the specified transition.
49 * If a transition with the same id already exists on a selected element, the existing transition is returned for that element.
50 * Otherwise, the timing of the returned transition is inherited from the existing transition of the same id on the nearest ancestor of each selected element.
51 * Thus, this method can be used to synchronize a transition across multiple selections,
52 * or to re-select a transition for specific elements and modify its configuration.
53 *
54 * If the specified transition is not found on a selected node or its ancestors (such as if the transition already ended),
55 * the default timing parameters are used; however, in a future release, this will likely be changed to throw an error.
56 *
57 * @param transition A transition instance.
58 */
59 transition(transition: Transition<BaseType, any, any, any>): Transition<GElement, Datum, PElement, PDatum>;
60 }
61}
62
63/**
64 * Return the active transition on the specified node with the specified name, if any.
65 * If no name is specified, null is used. Returns null if there is no such active transition on the specified node.
66 * This method is useful for creating chained transitions.
67 *
68 * The first generic "GElement" refers to the type of element on which the returned active transition was defined. The second generic "Datum" refers to the type of the
69 * datum, of a selected element on which the transition is defined. The third generic refers to the type of the parent elements in the returned Transition.
70 * The fourth generic refers to the type of the datum defined on the parent elements in the returned Transition.
71 *
72 * @param node Element for which the active transition should be returned.
73 * @param name Name of the transition.
74 */
75// tslint:disable-next-line:no-unnecessary-generics
76export function active<GElement extends BaseType, Datum, PElement extends BaseType, PDatum>(node: GElement, name?: string): Transition<GElement, Datum, PElement, PDatum> | null;
77
78/**
79 * Interrupts the active transition of the specified name on the specified node, and cancels any pending transitions with the specified name, if any.
80 * If a name is not specified, null is used.
81 *
82 * @param node Element for which the transition should be interrupted.
83 * @param name Name of the transition to be interrupted. If a name is not specified, null is used.
84 */
85export function interrupt(node: BaseType, name?: string): void;
86
87/**
88 * A D3 Transition.
89 *
90 * The first generic "GElement" refers to the type of the selected element(s) in the Transition.
91 * The second generic "Datum" refers to the type of the datum of a selected element(s) in the Transition.
92 * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection in the Transition.
93 * The fourth generic "PDatum" refers to the type of the datum of the parent element(s) in the Transition.
94 */
95export interface Transition<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> {
96 // Sub-selection -------------------------
97
98 /**
99 * For each selected element, select the first descendant element that matches the specified selector string, if any,
100 * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition;
101 * however, if a transition with the same id already exists on a selected element,
102 * the existing transition is returned for that element.
103 *
104 * The generic represents the type of the descendant element to be selected.
105 *
106 * @param selector CSS selector string
107 */
108 // tslint:disable-next-line:no-unnecessary-generics
109 select<DescElement extends BaseType>(selector: string): Transition<DescElement, Datum, PElement, PDatum>;
110 /**
111 * For each selected element, select the descendant element returned by the selector function, if any,
112 * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition;
113 * however, if a transition with the same id already exists on a selected element,
114 * the existing transition is returned for that element.
115 *
116 * The generic represents the type of the descendant element to be selected.
117 *
118 * @param selector A selector function, which is evaluated for each selected element, in order, being passed the current datum (d),
119 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
120 * It must return an element, or null if there is no matching element.
121 */
122 select<DescElement extends BaseType>(selector: ValueFn<GElement, Datum, DescElement>): Transition<DescElement, Datum, PElement, PDatum>;
123
124 /**
125 * For each selected element, select all descendant elements that match the specified selector string, if any,
126 * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition;
127 * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element.
128 *
129 * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the
130 * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.
131 *
132 * @param selector CSS selector string
133 */
134 // tslint:disable-next-line:no-unnecessary-generics
135 selectAll<DescElement extends BaseType, OldDatum>(selector: string): Transition<DescElement, OldDatum, GElement, Datum>;
136 /**
137 * For each selected element, select all descendant elements returned by the selector function, if any,
138 * and returns a transition on the resulting selection. The new transition has the same id, name and timing as this transition;
139 * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element.
140 *
141 * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the
142 * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.
143 *
144 * @param selector A selector function which is evaluated for each selected element, in order, being passed the current datum (d),
145 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). It must return an array of elements
146 * (or a pseudo-array, such as a NodeList), or the empty array if there are no matching elements.
147 */
148 // tslint:disable-next-line:no-unnecessary-generics
149 selectAll<DescElement extends BaseType, OldDatum>(selector: ValueFn<GElement, Datum, DescElement[] | ArrayLike<DescElement>>): Transition<DescElement, OldDatum, GElement, Datum>;
150
151 /**
152 * For each selected element, selects the first child element that matches the specified selector string, if any, and returns a transition on the resulting selection.
153 * The selector may be specified either as a selector string or a function.
154 * If a function, it is evaluated for each selected element, in order, being passed the current datum (d),
155 * the current index (i), and the current group (nodes), with this as the current DOM element.
156 * The new transition has the same id, name and timing as this transition;
157 * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element.
158 * This method is equivalent to deriving the selection for this transition via transition.selection,
159 * creating a subselection via selection.selectChild, and then creating a new transition via selection.transition.
160 */
161 // tslint:disable-next-line:no-unnecessary-generics
162 selectChild<DescElement extends BaseType, OldDatum>(selector?: string | ValueFn<GElement, Datum, DescElement>): Transition<DescElement, OldDatum, GElement, Datum>;
163
164 /**
165 * For each selected element, selects all children that match the specified selector string, if any, and returns a transition on the resulting selection.
166 * The selector may be specified either as a selector string or a function.
167 * If a function, it is evaluated for each selected element, in order, being passed the current datum (d),
168 * the current index (i), and the current group (nodes), with this as the current DOM element.
169 * The new transition has the same id, name and timing as this transition;
170 * however, if a transition with the same id already exists on a selected element, the existing transition is returned for that element.
171 * This method is equivalent to deriving the selection for this transition via transition.selection,
172 * creating a subselection via selection.selectChildren, and then creating a new transition via selection.transition.
173 */
174 // tslint:disable-next-line:no-unnecessary-generics
175 selectChildren<DescElement extends BaseType, OldDatum>(selector?: string | ValueFn<GElement, Datum, DescElement>): Transition<DescElement, OldDatum, GElement, Datum>;
176
177 /**
178 * Return the selection corresponding to this transition.
179 */
180 selection(): Selection<GElement, Datum, PElement, PDatum>;
181
182 /**
183 * Returns a new transition on the same selected elements as this transition, scheduled to start when this transition ends.
184 * The new transition inherits a reference time equal to this transition’s time plus its delay and duration.
185 * The new transition also inherits this transition’s name, duration, and easing.
186 * This method can be used to schedule a sequence of chained transitions.
187 *
188 * A delay configured for the new transition will be relative to the previous transition.
189 */
190 transition(): Transition<GElement, Datum, PElement, PDatum>;
191
192 // Modifying -------------------------------
193
194 /**
195 * For each selected element, assigns the attribute tween for the attribute with the specified name to the specified target value.
196 * The starting value of the tween is the attribute’s value when the transition starts.
197 * If the target value is null, the attribute is removed when the transition starts.
198 */
199 attr(name: string, value: null | string | number | boolean): this;
200 /**
201 * For each selected element, assigns the attribute tween for the attribute with the specified name to the specified target value.
202 * The starting value of the tween is the attribute’s value when the transition starts.
203 * The target value is return value of the value function evaluated for the selected element.
204 *
205 * An interpolator is chosen based on the type of the target value, using the following algorithm:
206 * 1.) If value is a number, use interpolateNumber.
207 * 2.) If value is a color or a string coercible to a color, use interpolateRgb.
208 * 3.) Use interpolateString.
209 *
210 * To apply a different interpolator, use transition.attrTween.
211 *
212 * @param name Name of the attribute.
213 * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d),
214 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
215 * A null value will clear the attribute at the start of the transition.
216 */
217 attr(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>): this;
218
219 /**
220 * Return the current interpolator factory for attribute with the specified name, or undefined if no such tween exists.
221 *
222 * @param name Name of attribute.
223 */
224 attrTween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined;
225 /**
226 * Remove the previously-assigned attribute tween of the specified name, if any.
227 *
228 * @param name Name of attribute.
229 * @param factory Use null to remove previously-assigned attribute tween.
230 */
231 attrTween(name: string, factory: null): this;
232 /**
233 * Assign the attribute tween for the attribute with the specified name to the specified interpolator factory.
234 * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element.
235 * The returned interpolator will then be invoked for each frame of the transition, in order,
236 * being passed the eased time t, typically in the range [0, 1]. Lastly, the return value of the interpolator will be used to set the attribute value.
237 * The interpolator must return a string.
238 *
239 * @param name Name of attribute.
240 * @param factory An interpolator factory which is evaluated for each selected element, in order, being passed the current datum (d),
241 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The interpolator factory returns a string interpolator,
242 * which takes as its argument eased time t, typically in the range [0, 1] and returns the interpolated string.
243 */
244 attrTween(name: string, factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>): this;
245
246 /**
247 * For each selected element, the style with the specified name will be cleared at the start of the transition.
248 *
249 * @param name Name of the style.
250 * @param value Use null to clear the style.
251 */
252 style(name: string, value: null): this;
253 /**
254 * For each selected element, assigns the style tween for the style with the specified name to the specified target value with the
255 * specified priority.
256 * The starting value of the tween is the style’s inline value if present, and otherwise its computed value.
257 * The target value is the specified constant value for all elements.
258 *
259 * An interpolator is chosen based on the type of the target value, using the following algorithm:
260 * 1.) If value is a number, use interpolateNumber.
261 * 2.) If value is a color or a string coercible to a color, use interpolateRgb.
262 * 3.) Use interpolateString.
263 *
264 * To apply a different interpolator, use transition.attrTween.
265 *
266 * @param name Name of the style.
267 * @param value Target value for the style.
268 * @param priority An optional priority flag, either null or the string important (without the exclamation point)
269 */
270 style(name: string, value: string | number | boolean, priority?: null | 'important'): this;
271 /**
272 * For each selected element, assigns the style tween for the style with the specified name to the specified target value with the
273 * specified priority.
274 * The starting value of the tween is the style's inline value if present, and otherwise its computed value.
275 * The target value is return value of the value function evaluated for the selected element.
276 *
277 * An interpolator is chosen based on the type of the target value, using the following algorithm:
278 * 1.) If value is a number, use interpolateNumber.
279 * 2.) If value is a color or a string coercible to a color, use interpolateRgb.
280 * 3.) Use interpolateString.
281 *
282 * To apply a different interpolator, use transition.attrTween.
283 *
284 * @param name Name of the style.
285 * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d),
286 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
287 * A null value will clear the style at the start of the transition.
288 * @param priority An optional priority flag, either null or the string important (without the exclamation point)
289 */
290 style(name: string, value: ValueFn<GElement, Datum, string | number | boolean | null>, priority?: null | 'important'): this;
291
292 /**
293 * Return the current interpolator factory for style with the specified name, or undefined if no such tween exists.
294 *
295 * @param name Name of style.
296 */
297 styleTween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined;
298 /**
299 * Remove the previously-assigned style tween of the specified name, if any.
300 *
301 * @param name Name of style.
302 * @param factory Use null to remove previously-assigned style tween.
303 */
304 styleTween(name: string, factory: null): this;
305 /**
306 * Assign the style tween for the style with the specified name to the specified interpolator factory.
307 * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element.
308 * The returned interpolator will then be invoked for each frame of the transition, in order,
309 * being passed the eased time t, typically in the range [0, 1]. Lastly, the return value of the interpolator will be used to set the style value.
310 * The interpolator must return a string.
311 *
312 * @param name Name of style.
313 * @param factory An interpolator factory which is evaluated for each selected element, in order, being passed the current datum (d),
314 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The interpolator factory returns a string interpolator,
315 * which takes as its argument eased time t, typically in the range [0, 1] and returns the interpolated string.
316 * @param priority An optional priority flag, either null or the string important (without the exclamation point)
317 */
318 styleTween(name: string, factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>, priority?: null | 'important'): this;
319
320 /**
321 * For each selected element, sets the text content to the specified target value when the transition starts.
322 * A null value will clear the content.
323 */
324 text(value: null | string | number | boolean): this;
325 /**
326 * For each selected element, sets the text content returned by the value function for each selected element when the transition starts.
327 *
328 * To interpolate text rather than to set it on start, use transition.textTween (for example) or append a replacement element and cross-fade opacity (for example).
329 * Text is not interpolated by default because it is usually undesirable.
330 *
331 * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d),
332 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
333 * A null value will clear the text content at the start of the transition.
334 */
335 text(value: ValueFn<GElement, Datum, string | number | boolean>): this;
336
337 /**
338 * Returns the current interpolator factory for text, or undefined if no such tween exists.
339 */
340 textTween(): ValueFn<GElement, Datum, (this: GElement, t: number) => string> | undefined;
341 /**
342 * Removes the previously-assigned text tween, if any
343 *
344 * @param factory Use null to remove previously-assigned text tween.
345 */
346 textTween(factory: null): this;
347 /**
348 * Assigns the text tween to the specified interpolator factory.
349 * An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element,
350 * in order, being passed the current datum d and index i, with the this context as the current DOM element.
351 * The returned interpolator will then be invoked for each frame of the transition, in order, being passed the eased time t, typically in the range [0, 1].
352 * Lastly, the return value of the interpolator will be used to set the text.
353 * The interpolator must return a string.
354 *
355 * @param factory An interpolator factory is a function that returns an interpolator; when the transition starts, the factory is evaluated for each selected element,
356 * in order, being passed the current datum d and index i, with the this context as the current DOM element.
357 * The returned interpolator will then be invoked for each frame of the transition, in order, being passed the eased time t, typically in the range [0, 1].
358 * Lastly, the return value of the interpolator will be used to set the text.
359 * The interpolator must return a string.
360 */
361 textTween(factory: ValueFn<GElement, Datum, (this: GElement, t: number) => string>): this;
362
363 /**
364 * For each selected element, removes the element when the transition ends, as long as the element has no other active or pending transitions.
365 * If the element has other active or pending transitions, does nothing.
366 */
367 remove(): this;
368
369 /**
370 * Returns the tween with the specified name, or undefined, if no tween was previously assigned to
371 * that name.
372 *
373 * @param name Name of tween.
374 */
375 tween(name: string): ValueFn<GElement, Datum, (this: GElement, t: number) => void> | undefined;
376 /**
377 * Removes the tween with the specified name, if a tween was previously assigned to
378 * that name.
379 *
380 * @param name Name of tween.
381 * @param tweenFn Use null to remove a previously-assigned tween.
382 */
383 tween(name: string, tweenFn: null): this;
384 /**
385 * For each selected element, assigns the tween with the specified name with the specified value function.
386 * The value must be specified as a function that returns a function.
387 * When the transition starts, the value function is evaluated for each selected element.
388 * The returned function is then invoked for each frame of the transition, in order,
389 * being passed the eased time t, typically in the range [0, 1].
390 *
391 * @param name Name of tween.
392 * @param tweenFn A tween function which is evaluated for each selected element, in order, being passed the current datum (d),
393 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The tween function returns a function
394 * which takes as its argument eased time t, typically in the range [0, 1] and performs the tweening activities for each transition frame.
395 */
396 tween(name: string, tweenFn: ValueFn<GElement, Datum, (this: GElement, t: number) => void>): this;
397
398 /**
399 * Returns a new transition merging this transition with the specified other transition,
400 * which must have the same id as this transition. The returned transition has the same number of groups,
401 * the same parents, the same name and the same id as this transition.
402 * Any missing (null) elements in this transition are filled with the corresponding element, if present (not null), from the other transition.
403 *
404 * @param other The transition to be merged.
405 */
406 merge(other: Transition<GElement, Datum, PElement, PDatum>): Transition<GElement, Datum, PElement, PDatum>;
407
408 /**
409 * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection.
410 *
411 * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element,
412 * the existing transition is returned for that element.
413 *
414 * @param filter A CSS selector string.
415 */
416 filter(filter: string): Transition<GElement, Datum, PElement, PDatum>;
417 /**
418 * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection.
419 *
420 * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element,
421 * the existing transition is returned for that element.
422 *
423 * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types
424 * contained in a pre-filter selection are narrowed to a subset as part of the filtering.
425 *
426 * @param filter A CSS selector string.
427 */
428 // tslint:disable-next-line:no-unnecessary-generics
429 filter<FilteredElement extends BaseType>(filter: string): Transition<FilteredElement, Datum, PElement, PDatum>;
430 /**
431 * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection.
432 *
433 * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element,
434 * the existing transition is returned for that element.
435 *
436 * @param filter A filter function which is evaluated for each selected element, in order, being passed the current datum (d),
437 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The filter function returns a boolean indicating,
438 * whether the selected element matches.
439 */
440 filter(filter: ValueFn<GElement, Datum, boolean>): Transition<GElement, Datum, PElement, PDatum>;
441 /**
442 * For each selected element, selects only the elements that match the specified filter, and returns a transition on the resulting selection.
443 *
444 * The new transition has the same id, name and timing as this transition; however, if a transition with the same id already exists on a selected element,
445 * the existing transition is returned for that element.
446 *
447 * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types
448 * contained in a pre-filter selection are narrowed to a subset as part of the filtering.
449 *
450 * @param filter A filter function which is evaluated for each selected element, in order, being passed the current datum (d),
451 * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). The filter function returns a boolean indicating,
452 * whether the selected element matches.
453 */
454 // tslint:disable-next-line:no-unnecessary-generics
455 filter<FilteredElement extends BaseType>(filter: ValueFn<GElement, Datum, boolean>): Transition<FilteredElement, Datum, PElement, PDatum>;
456
457 // Event Handling -------------------
458
459 /**
460 * Return the currently-assigned listener for the specified event typename on the first (non-null) selected element, if any.
461 * If multiple typenames are specified, the first matching listener is returned.
462 *
463 * @param typenames The typenames is one of the following string event types: start (when the transition starts), end (when the transition ends),
464 * interrupt (when the transition is interrupted), cancel(when the transition is cancelled).
465 * Note that these are not native DOM events. The type may be optionally followed by a period (.) and a name;
466 * the optional name allows multiple callbacks to be registered to receive events of the same type, such as "start.foo"" and "start.bar".
467 * To specify multiple typenames, separate typenames with spaces, such as "interrupt end"" or "start.foo start.bar".
468 */
469 on(typenames: string): ValueFn<GElement, Datum, void> | undefined;
470 /**
471 * Remove all listeners for a given name.
472 *
473 * @param typenames Name of the event type for which the listener should be removed. To remove all listeners for a given name use ".foo"
474 * as the typename, where foo is the name; to remove all listeners with no name, specify "." as the typename.
475 * @param listener Use null to remove listeners.
476 */
477 on(typenames: string, listener: null): this;
478 /**
479 * Add a listener to each selected element for the specified event typenames.
480 *
481 * When a specified transition event is dispatched on a selected node, the specified listener will be invoked for each transitioning element.
482 * Listeners always see the latest datum for their element, but the index is a property of the selection and is fixed when the listener is assigned;
483 * to update the index, re-assign the listener.
484 *
485 * @param typenames The typenames is one of the following string event types: start (when the transition starts), end (when the transition ends),
486 * interrupt (when the transition is interrupted), cancel(when the transition is cancelled).
487 * Note that these are not native DOM events. The type may be optionally followed by a period (.) and a name;
488 * the optional name allows multiple callbacks to be registered to receive events of the same type, such as "start.foo"" and "start.bar".
489 * To specify multiple typenames, separate typenames with spaces, such as "interrupt end"" or "start.foo start.bar".
490 * @param listener A listener function which will be evaluated for each selected element, being passed the current datum (d), the current index (i),
491 * and the current group (nodes), with this as the current DOM element (nodes[i]). Listeners always see the latest datum for their element,
492 * but the index is a property of the selection and is fixed when the listener is assigned; to update the index, re-assign the listener.
493 */
494 on(typenames: string, listener: ValueFn<GElement, Datum, void>): this;
495
496 /**
497 * Returns a promise that resolves when every selected element finishes transitioning. If any element’s transition is cancelled or interrupted, the promise rejects.
498 */
499 end(): Promise<void>;
500
501 // Control Flow ----------------------
502
503 /**
504 * Invoke the specified function for each selected element, passing the current datum (d),
505 * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]).
506 * This method can be used to invoke arbitrary code for each selected element, and is useful for creating a context to access parent and child data simultaneously.
507 *
508 * @param func A function which is invoked for each selected element,
509 * being passed the current datum (d), the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]).
510 */
511 each(func: ValueFn<GElement, Datum, void>): this;
512
513 /**
514 * Invoke the specified function exactly once, passing in this transition along with any optional arguments.
515 * Returns this transition.
516 *
517 * @param func A function which is passed this transition as the first argument along with any optional arguments.
518 * @param args List of optional arguments to be passed to the callback function.
519 */
520 call(func: (transition: Transition<GElement, Datum, PElement, PDatum>, ...args: any[]) => any, ...args: any[]): this;
521
522 /**
523 * Return true if this transition contains no (non-null) elements.
524 */
525 empty(): boolean;
526
527 /**
528 * Return the first (non-null) element in this transition. If the transition is empty, returns null.
529 */
530 node(): GElement | null;
531
532 /**
533 * Return an array of all (non-null) elements in this transition.
534 */
535 nodes(): GElement[];
536
537 /**
538 * Returns the total number of elements in this transition.
539 */
540 size(): number;
541
542 // Transition Configuration ----------------------
543
544 /**
545 * Returns the current value of the delay for the first (non-null) element in the transition.
546 * This is generally useful only if you know that the transition contains exactly one element.
547 */
548 delay(): number;
549 /**
550 * For each selected element, sets the transition delay to the specified value in milliseconds.
551 * If a delay is not specified, it defaults to zero.
552 *
553 * @param milliseconds Number of milliseconds for the delay.
554 */
555 delay(milliseconds: number): this;
556 /**
557 * For each selected element, sets the transition delay to the value in milliseconds returned by the
558 * value function.
559 *
560 * @param milliseconds A value function which is evaluated for each selected element, being passed the current datum (d),
561 * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). The return value is a number
562 * specifying the delay in milliseconds.
563 */
564 delay(milliseconds: ValueFn<GElement, Datum, number>): this;
565
566 /**
567 * Returns the current value of the duration for the first (non-null) element in the transition.
568 * This is generally useful only if you know that the transition contains exactly one element.
569 */
570 duration(): number;
571 /**
572 * For each selected element, sets the transition duration to the specified value in milliseconds.
573 * If a duration is not specified, it defaults to 250ms.
574 *
575 * @param duration Number of milliseconds for the duration.
576 */
577 duration(milliseconds: number): this;
578 /**
579 * For each selected element, sets the transition duration to the value in milliseconds returned by the
580 * value function.
581 *
582 * @param milliseconds A value function which is evaluated for each selected element, being passed the current datum (d),
583 * the current index (i), and the current group (nodes), with this of the current DOM element (nodes[i]). The return value is a number
584 * specifying the duration in milliseconds.
585 */
586 duration(milliseconds: ValueFn<GElement, Datum, number>): this;
587
588 /**
589 * Returns the current easing function for the first (non-null) element in the transition.
590 * This is generally useful only if you know that the transition contains exactly one element.
591 */
592 ease(): (normalizedTime: number) => number;
593 /**
594 * Specifies the transition easing function for all selected elements. The value must be specified as a function.
595 * The easing function is invoked for each frame of the animation, being passed the normalized time t in the range [0, 1];
596 * it must then return the eased time tʹ which is typically also in the range [0, 1].
597 * A good easing function should return 0 if t = 0 and 1 if t = 1. If an easing function is not specified,
598 * it defaults to d3.easeCubic.
599 *
600 * @param easingFn An easing function which is passed the normalized time t in the range [0, 1];
601 * it must then return the eased time tʹ which is typically also in the range [0, 1].
602 * A good easing function should return 0 if t = 0 and 1 if t = 1.
603 */
604 ease(easingFn: (normalizedTime: number) => number): this;
605
606 /**
607 * Specifies a factory for the transition easing function.
608 *
609 * @param factory The factory must be a function.
610 * It is invoked for each node of the selection, being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element.
611 * It must return an easing function.
612 */
613 easeVarying(factory: ValueFn<GElement, Datum, (normalizedTime: number) => number>): this;
614}
615
616/**
617 * Represents the union of the Selection and Transition types for any usages that operate on both.
618 * Typically used for functions which take in either a selection or transition and set or update attributes.
619 */
620export type SelectionOrTransition<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> = Selection<GElement, Datum, PElement, PDatum> | Transition<GElement, Datum, PElement, PDatum>;
621
622/**
623 * Returns a new transition with the specified name. If a name is not specified, null is used.
624 * The new transition is only exclusive with other transitions of the same name.
625 *
626 * The generic "OldDatum" refers to the type of a previously-set datum of the selected element in the Transition.
627 *
628 * @param name Name of the transition.
629 */
630// tslint:disable-next-line:no-unnecessary-generics
631export function transition<OldDatum>(name?: string): Transition<BaseType, OldDatum, null, undefined>;
632
633/**
634 * Returns a new transition from an existing transition.
635 *
636 * When using a transition instance, the returned transition has the same id and name as the specified transition.
637 *
638 * The generic "OldDatum" refers to the type of a previously-set datum of the selected element in the Transition.
639 *
640 * @param transition A transition instance.
641 */
642// tslint:disable-next-line:no-unnecessary-generics
643export function transition<OldDatum>(transition: Transition<BaseType, any, BaseType, any>): Transition<BaseType, OldDatum, null, undefined>;