Zoom Behavior - zziuni/d3 GitHub Wiki
Wiki ▸ API Reference ▸ Behaviors ▸ Zoom Behavior
This behavior automatically creates event listeners to handle zooming and panning gestures on a container element. Both mouse and touch events are supported.
# d3.behavior.zoom()
Constructs a new zoom behavior.
# zoom.x([x])
Specifies an x-scale whose domain should be automatically adjusted when zooming. If not specified, returns the current x-scale, which defaults to null. If the scale's domain is modified programmatically, it should be reassigned to the zoom behaviour.
# zoom.y([y])
Specifies an y-scale whose domain should be automatically adjusted when zooming. If not specified, returns the current y-scale, which defaults to null. If the scale's domain is modified programmatically, it should be reassigned to the zoom behaviour.
# zoom.scaleExtent([extent])
Specifies the zoom scale's allowed range as a two-element array, [minimum, maximum]. If not specified, returns the current scale extent, which defaults to [0, Infinity].
# zoom.scale([scale])
Specifies the current zoom scale. If not specified, returns the current zoom scale, which defaults to 1.
# zoom.translate([translate])
Specifies the current zoom translation vector. If not specified, returns the current translation vector, which defaults to [0, 0].
# zoom.on(type, listener)
Registers the specified listener to receive events of the specified type from the zoom behavior. Currently, only the "zoom" event is supported. When fired, the d3.event object will contain the following properties:
- "scale": a number; the current scale.
- "translate": a two-element array representing the current translation vector.