UNPKG

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