UNPKG

33.4 kBTypeScriptView Raw
1// Type definitions for d3JS d3-zoom module 2.0
2// Project: https://github.com/d3/d3-zoom/, https://d3js.org/d3-zoom
3// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
4// Alex Ford <https://github.com/gustavderdrache>
5// Boris Yankov <https://github.com/borisyankov>
6// denisname <https://github.com/denisname>
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 { Selection, TransitionLike, ValueFn } from 'd3-selection';
14import { ZoomView } from 'd3-interpolate';
15
16// --------------------------------------------------------------------------
17// Shared Type Definitions and Interfaces
18// --------------------------------------------------------------------------
19
20/**
21 * ZoomedElementBaseType serves as an alias for the 'minimal' data type which can be selected
22 * without 'd3-zoom' (and related code in 'd3-selection') trying to use properties internally which would otherwise not
23 * be supported.
24 */
25export type ZoomedElementBaseType = Element;
26
27/**
28 * Minimal interface for a continuous scale.
29 * This interface is used as a minimum contract for scale objects
30 * that can be passed into zoomTransform methods rescaleX and rescaleY
31 */
32export interface ZoomScale {
33 domain(): number[] | Date[];
34 domain(domain: Array<Date | number>): this;
35 range(): number[];
36 range(range: number[]): this;
37 copy(): ZoomScale;
38 invert(value: number): number | Date;
39}
40
41// --------------------------------------------------------------------------
42// Zoom Behavior
43// --------------------------------------------------------------------------
44
45/**
46 * A D3 Zoom Behavior
47 *
48 * The first generic refers to the type of reference element to which the zoom behavior is attached.
49 * The second generic refers to the type of the datum of the reference element.
50 */
51export interface ZoomBehavior<ZoomRefElement extends ZoomedElementBaseType, Datum> extends Function {
52 /**
53 * Applies this zoom behavior to the specified selection, binding the necessary event listeners to
54 * allow panning and zooming, and initializing the zoom transform on each selected element to the identity transform if not already defined. This function is typically not invoked directly,
55 * and is instead invoked via selection.call.
56 *
57 * For details see: {@link https://github.com/d3/d3-zoom#_zoom}
58 *
59 * @param selection A D3 selection of elements.
60 * @param args Optional arguments to be passed in.
61 */
62 (selection: Selection<ZoomRefElement, Datum, any, any>, ...args: any[]): void;
63 /**
64 * If selection is a selection, sets the current zoom transform of the selected elements to the specified transform, instantaneously emitting start, zoom and end events.
65 * If selection is a transition, defines a “zoom” tween to the specified transform using d3.interpolateZoom, emitting a start event when the transition starts,
66 * zoom events for each tick of the transition, and then an end event when the transition ends (or is interrupted).
67 * The transition will attempt to minimize the visual movement around the specified point; if the point is not specified, it defaults to the center of the viewport extent.
68 *
69 * This function is typically not invoked directly, and is instead invoked via selection.call or transition.call.
70 *
71 * @param selection A selection or a transition.
72 * @param transform A zoom transform or a function that returns a zoom transform.
73 * If a function, it is invoked for each selected element, being passed the current event (event) and datum d, with the this context as the current DOM element.
74 * @param point A two-element array [x, y] or a function that returns such an array.
75 * If a function, it is invoked for each selected element, being passed the current event (event) and datum d, with the this context as the current DOM element.
76 */
77 transform(
78 selection: Selection<ZoomRefElement, Datum, any, any> | TransitionLike<ZoomRefElement, Datum>,
79 transform: ZoomTransform | ((this: ZoomRefElement, event: any, d: Datum) => ZoomTransform),
80 point?: [number, number] | ((this: ZoomRefElement, event: any, d: Datum) => [number, number])
81 ): void;
82
83 /**
84 * If selection is a selection, translates the current zoom transform of the selected elements by x and y, such that the new tx1 = tx0 + kx and ty1 = ty0 + ky.
85 * If selection is a transition, defines azoomtween translating the current transform.
86 * This method is a convenience method for zoom.transform.
87 *
88 * @param selection A selection or a transition.
89 * @param x A number or a function that returns a number.
90 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
91 * @param y A number or a function that returns a number.
92 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
93 */
94 translateBy(
95 selection: Selection<ZoomRefElement, Datum, any, any> | TransitionLike<ZoomRefElement, Datum>,
96 x: number | ValueFn<ZoomRefElement, Datum, number>,
97 y: number | ValueFn<ZoomRefElement, Datum, number>
98 ): void;
99
100 /**
101 * If selection is a selection, translates the current zoom transform of the selected elements such that the given positionx,yappears at given point p.
102 * The new tx = px - kx and ty = py - ky. If p is not specified, it defaults to the center of the viewport extent.
103 * If selection is a transition, defines azoomtween translating the current transform. This method is a convenience method for zoom.transform.
104 *
105 * Translates the current zoom transform of the selected elements such that the specified positionx,yappears at the center of the viewport extent.
106 * The new tx = cx - kx and ty = cy - ky, wherecx,cyis the center.
107 *
108 * x is provided as a constant for all elements.
109 * y is provided as a constant for all elements.
110 *
111 * @param selection A selection or a transition.
112 * @param x A number or a function that returns a number.
113 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
114 * @param y A number or a function that returns a number.
115 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
116 * @param p A two-element array [px,py] or a function
117 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
118 */
119 translateTo(
120 selection: Selection<ZoomRefElement, Datum, any, any> | TransitionLike<ZoomRefElement, Datum>,
121 x: number | ValueFn<ZoomRefElement, Datum, number>,
122 y: number | ValueFn<ZoomRefElement, Datum, number>,
123 p?: [number, number] | ValueFn<ZoomRefElement, Datum, [number, number]>
124 ): void;
125
126 /**
127 * If selection is a selection, scales the current zoom transform of the selected elements by k, such that the new k₁ = kk.
128 * The reference point p does move.
129 * If p is not specified, it defaults to the center of the viewport extent.
130 * If selection is a transition, defines azoomtween translating the current transform.
131 * This method is a convenience method for zoom.transform.
132 *
133 * @param selection A selection or a transition.
134 * @param k Scale factor. A number or a function that returns a number.
135 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
136 * @param p A two-element array [px,py] or a function.
137 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
138 */
139 scaleBy(
140 selection: Selection<ZoomRefElement, Datum, any, any> | TransitionLike<ZoomRefElement, Datum>,
141 k: number | ValueFn<ZoomRefElement, Datum, number>,
142 p?: [number, number] | ValueFn<ZoomRefElement, Datum, [number, number]>
143 ): void;
144
145 /**
146 * If selection is a selection, scales the current zoom transform of the selected elements to k, such that the new k₁ = k.
147 * The reference point p does move.
148 * If p is not specified, it defaults to the center of the viewport extent.
149 * If selection is a transition, defines azoomtween translating the current transform.
150 * This method is a convenience method for zoom.transform.
151 *
152 * @param selection: A selection or a transition.
153 * @param k Scale factor. A number or a function that returns a number.
154 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
155 * @param p A two-element array [px,py] or a function.
156 * If a function, it is invoked for each selected element, being passed the current datum d and index i, with the this context as the current DOM element.
157 */
158 scaleTo(
159 selection: Selection<ZoomRefElement, Datum, any, any> | TransitionLike<ZoomRefElement, Datum>,
160 k: number | ValueFn<ZoomRefElement, Datum, number>,
161 p?: [number, number]
162 ): void;
163
164 /**
165 * Returns the current constraint function.
166 * The default implementation attempts to ensure that the viewport extent does not go outside the translate extent.
167 */
168 constrain(): (transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform;
169 /**
170 * Sets the transform constraint function to the specified function and returns the zoom behavior.
171 *
172 * @param constraint A constraint function which returns a transform given the current transform, viewport extent and translate extent.
173 * The default implementation attempts to ensure that the viewport extent does not go outside the translate extent.
174 */
175 constrain(constraint: ((transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform)): this;
176
177 /**
178 * Returns the current filter function.
179 */
180 filter(): (this: ZoomRefElement, event: any, datum: Datum) => boolean;
181 /**
182 * Sets the filter to the specified filter function and returns the zoom behavior.
183 * The filter function is invoked in the zoom initiating event handlers of each element to which the zoom behavior was applied.
184 *
185 * If the filter returns falsey, the initiating event is ignored and no zoom gesture is started.
186 * Thus, the filter determines which input events are ignored. The default filter ignores mousedown events on secondary buttons,
187 * since those buttons are typically intended for other purposes, such as the context menu.
188 *
189 * @param filter A filter function which is invoked in the zoom initiating event handlers of each element to which the zoom behavior was applied,
190 * in order, being passed the current event (event) and datum d, with the this context as the current DOM element.
191 * The function returns a boolean value.
192 */
193 filter(filter: (this: ZoomRefElement, event: any, datum: Datum) => boolean): this;
194
195 /**
196 * Returns the current touch support detector, which defaults to a function returning true,
197 * if the "ontouchstart" event is supported on the current element.
198 */
199 touchable(): ValueFn<ZoomRefElement, Datum, boolean>;
200 /**
201 * Sets the touch support detector to the specified boolean value and returns the zoom behavior.
202 *
203 * Touch event listeners are only registered if the detector returns truthy for the corresponding element when the zoom behavior is applied.
204 * The default detector works well for most browsers that are capable of touch input, but not all; Chrome’s mobile device emulator, for example,
205 * fails detection.
206 *
207 * @param touchable A boolean value. true when touch event listeners should be applied to the corresponding element, otherwise false.
208 */
209 touchable(touchable: boolean): this;
210 /**
211 * Sets the touch support detector to the specified function and returns the zoom behavior.
212 *
213 * Touch event listeners are only registered if the detector returns truthy for the corresponding element when the zoom behavior is applied.
214 * The default detector works well for most browsers that are capable of touch input, but not all; Chrome’s mobile device emulator, for example,
215 * fails detection.
216 *
217 * @param touchable A touch support detector function, which returns true when touch event listeners should be applied to the corresponding element.
218 * The function is evaluated for each selected element to which the zoom behavior was applied, in order, being passed the current datum (d),
219 * the current index (i), and the current group (nodes), with this as the current DOM element. The function returns a boolean value.
220 */
221 touchable(touchable: ValueFn<ZoomRefElement, Datum, boolean>): this;
222
223 /**
224 * Returns the current wheelDelta function.
225 */
226 wheelDelta(): ValueFn<ZoomRefElement, Datum, number>;
227 /**
228 * Sets the wheel delta function to the specified function and returns the zoom behavior. The wheel delta function which is invoked in the wheel event handler
229 * of each element to which the zoom behavior was applied.
230 * The value Δ returned by the wheel delta function determines the amount of scaling applied in response to a WheelEvent.
231 * The scale factor transform.k is multiplied by 2Δ; for example, a Δ of +1 doubles the scale factor, Δ of -1 halves the scale factor.
232 *
233 * @param delta Wheel delta function which is invoked in the wheel event handler of each element to which the zoom behavior was applied,
234 * in order, being passed the wheel event that triggered the handler,
235 * with this as the current DOM element. The function returns a numeric value.
236 */
237 wheelDelta(delta: ((event: WheelEvent) => number) | number): this;
238
239 /**
240 * Return the current extent accessor, which defaults to [[0, 0], [width, height]] where width is the client width of the element and height is its client height;
241 * for SVG elements, the nearest ancestor SVG elements width and height is used. In this case,
242 * the owner SVG element must have defined width and height attributes rather than (for example) relying on CSS properties or the viewBox attribute;
243 * SVG provides no programmatic method for retrieving the initial viewport size. Alternatively, consider using element.getBoundingClientRect.
244 * (In Firefox, element.clientWidth and element.clientHeight is zero for SVG elements!)
245 */
246 extent(): (this: ZoomRefElement, datum: Datum) => [[number, number], [number, number]];
247 /**
248 * Set the viewport extent to the specified array of points [[x0, y0], [x1, y1]],
249 * where [x0, y0] is the top-left corner of the viewport and [x1, y1] is the bottom-right corner of the viewport,
250 * and return this zoom behavior.
251 *
252 * The viewport extent affects several functions: the center of the viewport remains fixed during changes by zoom.scaleBy and zoom.scaleTo;
253 * the viewport center and dimensions affect the path chosen by d3.interpolateZoom; and the viewport extent is needed to enforce the optional translate extent.
254 *
255 * @param extent An extent specified as an array of two coordinates.
256 */
257 extent(extent: [[number, number], [number, number]]): this;
258 /**
259 * Set the viewport extent to the array of points [[x0, y0], [x1, y1]] returned by the
260 * extent accessor function, and return this zoom behavior.
261 * The extent accessor function is evaluated for each element.
262 *
263 * [x0, y0] is the top-left corner of the viewport and [x1, y1] is the bottom-right corner of the viewport.
264 *
265 * The viewport extent affects several functions: the center of the viewport remains fixed during changes by zoom.scaleBy and zoom.scaleTo;
266 * the viewport center and dimensions affect the path chosen by d3.interpolateZoom; and the viewport extent is needed to enforce the optional translate extent.
267 *
268 * The default is [[0, 0], [width, height]] where width is the client width of the element and height is its client height;
269 * for SVG elements, the nearest ancestor SVG element’s width and height is used.
270 * In this case, the owner SVG element must have defined width and height attributes rather than (for example) relying on CSS properties or the viewBox attribute;
271 * SVG provides no programmatic method for retrieving the initial viewport size. Alternatively, consider using element.getBoundingClientRect.
272 * (In Firefox, element.clientWidth and element.clientHeight is zero for SVG elements!)
273 *
274 * @extent An extent accessor function which is evaluated for each selected element, being passed the current datum d, with the this context as the current DOM element.
275 * The function returns the extent array.
276 */
277 extent(extent: (this: ZoomRefElement, datum: Datum) => [[number, number], [number, number]]): this;
278
279 /**
280 * Return the current scale extent.
281 */
282 scaleExtent(): [number, number];
283 /**
284 * Set the scale extent to the specified array of numbers [k0, k1] where k0 is the minimum allowed scale factor and k1 is the maximum allowed scale factor,
285 * and return this zoom behavior.
286 *
287 * The scale extent restricts zooming in and out. It is enforced on interaction and when using zoom.scaleBy, zoom.scaleTo and zoom.translateBy;
288 * however, it is not enforced when using zoom.transform to set the transform explicitly.
289 *
290 * The default scale extent is [0, infinity].
291 *
292 * If the user tries to zoom by wheeling when already at the corresponding limit of the scale extent, the wheel events will be ignored and not initiate a zoom gesture.
293 * This allows the user to scroll down past a zoomable area after zooming in, or to scroll up after zooming out.
294 * If you would prefer to always prevent scrolling on wheel input regardless of the scale extent, register a wheel event listener to prevent the browser default behavior
295 *
296 * @param extent A scale extent array of two numbers representing the scale boundaries.
297 */
298 scaleExtent(extent: [number, number]): this;
299
300 /**
301 * Return the current translate extent.
302 */
303 translateExtent(): [[number, number], [number, number]];
304 /**
305 * Set the translate extent to the specified array of points [[x0, y0], [x1, y1]], where [x0, y0] is the top-left corner of the world and [x1, y1]
306 * is the bottom-right corner of the world, and return this zoom behavior.
307 *
308 * The translate extent restricts panning, and may cause translation on zoom out. It is enforced on interaction and when using zoom.scaleBy, zoom.scaleTo and zoom.translateBy;
309 * however, it is not enforced when using zoom.transform to set the transform explicitly.
310 *
311 * The default scale extent is [[-infinity, infinity], [-infinity, infinity]].
312 *
313 * @param extent A translate extent array, i.e. an array of two arrays, each representing a point.
314 */
315 translateExtent(extent: [[number, number], [number, number]]): this;
316
317 /**
318 * Return the current click distance threshold, which defaults to zero.
319 */
320 clickDistance(): number;
321 /**
322 * Set the maximum distance that the mouse can move between mousedown and mouseup that will trigger
323 * a subsequent click event. If at any point between mousedown and mouseup the mouse is greater than or equal to
324 * distance from its position on mousedown, the click event following mouseup will be suppressed.
325 *
326 * @param distance The distance threshold between mousedown and mouseup measured in client coordinates (event.clientX and event.clientY).
327 * The default is zero.
328 */
329 clickDistance(distance: number): this;
330
331 /**
332 * Return the current tap distance threshold, which defaults to 10.
333 */
334 tapDistance(): number;
335 /**
336 * Sets the maximum distance that a double-tap gesture can move between first touchstart and second touchend that will trigger a subsequent double-click event.
337 *
338 * @param distance The distance threshold between mousedown and mouseup measured in client coordinates (event.clientX and event.clientY).
339 * The default is 10.
340 */
341 tapDistance(distance: number): this;
342
343 /**
344 * Get the duration for zoom transitions on double-click and double-tap in milliseconds.
345 */
346 duration(): number;
347 /**
348 * Set the duration for zoom transitions on double-click and double-tap to the specified number of milliseconds and returns the zoom behavior.
349 *
350 * To disable double-click and double-tap transitions, you can remove the zoom behavior’s dblclick event listener after applying the zoom behavior to the selection.
351 *
352 * @param duration in milliseconds.
353 */
354 duration(duration: number): this;
355
356 /**
357 * Returns the current interpolation factory, which defaults to d3.interpolateZoom to implement smooth zooming.
358 */
359 interpolate<InterpolationFactory extends (a: ZoomView, b: ZoomView) => ((t: number) => ZoomView)>(): InterpolationFactory;
360
361 /**
362 * Sets the interpolation factory for zoom transitions to the specified function.
363 * Use the default d3.interpolateZoom to implement smooth zooming.
364 * To apply direct interpolation between two views, try d3.interpolate instead.
365 *
366 * Each view is defined as an array of three numbers: cx, cy and width. The first two coordinates cx, cy represent the center of the viewport;
367 * the last coordinate width represents the size of the viewport.
368 *
369 * @param interpolatorFactory An interpolator factory to be used to generate interpolators between zooms for transitions.
370 */
371 interpolate(interpolatorFactory: (a: ZoomView, b: ZoomView) => ((t: number) => ZoomView)): this;
372
373 /**
374 * Return the first currently-assigned listener matching the specified typenames, if any.
375 *
376 * @param typenames The typenames is a string containing one or more typename separated by whitespace.
377 * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar";
378 * the name allows multiple listeners to be registered for the same type. The type must be one of the following:
379 * start (after zooming begins [such as mousedown]), zoom (after a change to the zoom transform [such as mousemove], or
380 * end (after an active pointer becomes inactive [such as on mouseup].)
381 */
382 on(typenames: string): ((this: ZoomRefElement, event: any, d: Datum) => void) | undefined;
383 /**
384 * Remove the current event listeners for the specified typenames, if any, return the drag behavior.
385 *
386 * @param typenames The typenames is a string containing one or more typename separated by whitespace.
387 * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar";
388 * the name allows multiple listeners to be registered for the same type. The type must be one of the following:
389 * start (after zooming begins [such as mousedown]), zoom (after a change to the zoom transform [such as mousemove], or
390 * end (after an active pointer becomes inactive [such as on mouseup].)
391 * @param listener Use null to remove the listener.
392 */
393 on(typenames: string, listener: null): this;
394 /**
395 * Set the event listener for the specified typenames and return the zoom behavior.
396 * If an event listener was already registered for the same type and name,
397 * the existing listener is removed before the new listener is added.
398 * When a specified event is dispatched, each listener will be invoked with the same context and arguments as selection.on listeners.
399 *
400 * @param typenames The typenames is a string containing one or more typename separated by whitespace.
401 * Each typename is a type, optionally followed by a period (.) and a name, such as "drag.foo"" and "drag.bar";
402 * the name allows multiple listeners to be registered for the same type. The type must be one of the following:
403 * start (after zooming begins [such as mousedown]), zoom (after a change to the zoom transform [such as mousemove], or
404 * end (after an active pointer becomes inactive [such as on mouseup].)
405 * @param listener An event listener function which is evaluated for each selected element,
406 * in order, being passed the current event (event) and datum d, with the this context as the current DOM element.
407 */
408 on(typenames: string, listener: (this: ZoomRefElement, event: any, d: Datum) => void): this;
409}
410
411/**
412 * Creates a new zoom behavior. The returned behavior, zoom, is both an object and a function,
413 * and is typically applied to selected elements via selection.call.
414 *
415 * The first generic refers to the type of reference element to which the zoom behavior is attached.
416 * The second generic refers to the type of the datum of the reference element.
417 */
418export function zoom<ZoomRefElement extends ZoomedElementBaseType, Datum>(): ZoomBehavior<ZoomRefElement, Datum>;
419
420// --------------------------------------------------------------------------
421// Zoom Event
422// --------------------------------------------------------------------------
423
424/**
425 * A D3 Zoom Event
426 *
427 * The first generic refers to the type of reference element to which the zoom behavior is attached.
428 * The second generic refers to the type of the datum of the reference element.
429 */
430export interface D3ZoomEvent<ZoomRefElement extends ZoomedElementBaseType, Datum> {
431 /**
432 * The ZoomBehavior associated with the event
433 */
434 target: ZoomBehavior<ZoomRefElement, Datum>;
435 /**
436 * The event type for the zoom event
437 */
438 type: 'start' | 'zoom' | 'end' | string; // Leave failsafe string type for cases like 'zoom.foo'
439 /**
440 * The current zoom transform
441 */
442 transform: ZoomTransform;
443 /**
444 * The underlying input event, such as mousemove or touchmove.
445 */
446 sourceEvent: any;
447}
448
449// --------------------------------------------------------------------------
450// Zoom Transforms
451// --------------------------------------------------------------------------
452
453/**
454 * A zoom transform
455 *
456 * The zoom behavior stores the zoom state on the element to which the zoom behavior was applied, not on the zoom behavior itself.
457 * This is because the zoom behavior can be applied to many elements simultaneously, and each element can be zoomed independently.
458 * The zoom state can change either on user interaction or programmatically via zoom.transform.
459 *
460 * To retrieve the zoom state, use event.transform on the current zoom event within a zoom event listener (see zoom.on), or use d3.zoomTransform for a given node.
461 * The latter is particularly useful for modifying the zoom state programmatically,
462 * say to implement buttons for zooming in and out.
463 *
464 * For details see {@link https://github.com/d3/d3-zoom#zoom-transforms}
465 */
466export interface ZoomTransform {
467 /**
468 * The translation amount tx along the x-axis.
469 * This property should be considered read-only; instead of mutating a transform,
470 * use transform.scale and transform.translate to derive a new transform.
471 * Also see zoom.scaleBy, zoom.scaleTo and zoom.translateBy for convenience methods on the zoom behavior.
472 */
473 readonly x: number;
474
475 /**
476 * The translation amount ty along the y-axis
477 * This property should be considered read-only; instead of mutating a transform,
478 * use transform.scale and transform.translate to derive a new transform.
479 * Also see zoom.scaleBy, zoom.scaleTo and zoom.translateBy for convenience methods on the zoom behavior.
480 */
481 readonly y: number;
482
483 /**
484 * The scale factor k.
485 * This property should be considered read-only; instead of mutating a transform,
486 * use transform.scale and transform.translate to derive a new transform.
487 * Also see zoom.scaleBy, zoom.scaleTo and zoom.translateBy for convenience methods on the zoom behavior.
488 */
489 readonly k: number;
490
491 /**
492 * Return the transformation of the specified point which is a two-element array of numbers [x, y].
493 * The returned point is equal to [xk + tx, yk + ty].
494 *
495 * @param point Point coordinates [x, y]
496 */
497 apply(point: [number, number]): [number, number];
498
499 /**
500 * Return the transformation of the specified x-coordinate, xk + tx.
501 *
502 * @param x Value of x-coordinate.
503 */
504 applyX(x: number): number;
505
506 /**
507 * Return the transformation of the specified y-coordinate, yk + ty.
508 *
509 * @param y Value of y-coordinate.
510 */
511 applyY(y: number): number;
512
513 /**
514 * Return the inverse transformation of the specified point which is a two-element array of numbers [x, y].
515 * The returned point is equal to [(x - tx) / k, (y - ty) / k].
516 *
517 * @param point Point coordinates [x, y]
518 */
519 invert(point: [number, number]): [number, number];
520
521 /**
522 * Return the inverse transformation of the specified x-coordinate, (x - tx) / k.
523 *
524 * @param x Value of x-coordinate.
525 */
526 invertX(x: number): number;
527
528 /**
529 * Return the inverse transformation of the specified y-coordinate, (y - ty) / k.
530 *
531 * @param y Value of y-coordinate.
532 */
533 invertY(y: number): number;
534
535 /**
536 * Returns a copy of the continuous scale x whose domain is transformed.
537 * This is implemented by first applying the inverse x-transform on the scale’s range,
538 * and then applying the inverse scale to compute the corresponding domain
539 *
540 * The scale x must use d3.interpolateNumber; do not use continuous.rangeRound as this
541 * reduces the accuracy of continuous.invert and can lead to an inaccurate rescaled domain.
542 * This method does not modify the input scale x; x thus represents the untransformed scale,
543 * while the returned scale represents its transformed view.
544 *
545 * @param xScale A continuous scale for x-dimension.
546 */
547 rescaleX<S extends ZoomScale>(xScale: S): S;
548
549 /**
550 * Returns a copy of the continuous scale y whose domain is transformed.
551 * This is implemented by first applying the inverse y-transform on the scale’s range,
552 * and then applying the inverse scale to compute the corresponding domain
553 *
554 * The scale y must use d3.interpolateNumber; do not use continuous.rangeRound as this
555 * reduces the accuracy of continuous.invert and can lead to an inaccurate rescaled domain.
556 * This method does not modify the input scale x; x thus represents the untransformed scale,
557 * while the returned scale represents its transformed view.
558 *
559 * @param yScale A continuous scale for y-dimension.
560 */
561 rescaleY<S extends ZoomScale>(yScale: S): S;
562
563 /**
564 * Return a transform whose scale k1 is equal to k0 × k, where k0 is this transform’s scale.
565 *
566 * @param k A scale factor.
567 */
568 scale(k: number): ZoomTransform;
569
570 /**
571 * Return a string representing the SVG transform corresponding to this transform.
572 */
573 toString(): string;
574
575 /**
576 * Returns a transform whose translation tx1 and ty1 is equal to tx0 + tkx and ty0 + tky,
577 * where tx0 and ty0 is this transform’s translation and tk is this transform’s scale.
578 *
579 * @param x Amount of translation in x-direction.
580 * @param y Amount of translation in y-direction.
581 */
582 translate(x: number, y: number): ZoomTransform;
583}
584
585/**
586 * Returns the current transform for the specified node. Note that node should typically be a DOM element, and not a selection.
587 * (A selection may consist of multiple nodes, in different states, and this function only returns a single transform.) If you have a selection, call selection.node first.
588 * In the context of an event listener, the node is typically the element that received the input event (which should be equal to event.transform), "this".
589 * Internally, an element’s transform is stored as element.__zoom; however, you should use this method rather than accessing it directly.
590 * If the given node has no defined transform, returns the identity transformation.
591 * The returned transform represents a two-dimensional transformation matrix
592 *
593 * For details see {@link https://github.com/d3/d3-zoom#zoom-transforms}
594 *
595 * @param node An element for which to retrieve its current zoom transform.
596 */
597export function zoomTransform(node: ZoomedElementBaseType): ZoomTransform;
598
599/**
600 * The identity transform, where k = 1, tx = ty = 0.
601 */
602export const zoomIdentity: ZoomTransform;
603
\No newline at end of file