public class Zoom extends com.google.gwt.core.client.JavaScriptObject implements IsFunction
Modifier and Type | Class and Description |
---|---|
static class |
Zoom.ZoomEvent
Provide access to the properties of a zoom event.
|
static class |
Zoom.ZoomEventType
Type of scroll event to listen to.
|
Modifier | Constructor and Description |
---|---|
protected |
Zoom() |
Modifier and Type | Method and Description |
---|---|
Array<Double> |
center()
Returns the current focal point, which defaults to null.
|
Zoom |
center(double x,
double y)
If center is specified, sets the focal point [x, y] for
mousewheel zooming and returns this zoom behavior.
|
Zoom |
event(Selection selection)
Immediately dispatches a zoom gesture to registered listeners, as the
three event sequence
Zoom.ZoomEventType.ZOOMSTART ,
Zoom.ZoomEventType.ZOOM and Zoom.ZoomEventType.ZOOMEND . |
Zoom |
event(Transition selection)
Registers the appropriate tweens so that the zoom behavior dispatches
events over the course of the transition: a
Zoom.ZoomEventType.ZOOMSTART event when the transition starts from the
previously-set view, Zoom.ZoomEventType.ZOOM events for each tick of
the transition, and finally a Zoom.ZoomEventType.ZOOMEND event when
the transition ends. |
Zoom |
on(Zoom.ZoomEventType type,
DatumFunction<Void> listener)
Registers the specified listener to receive events of the specified type
from the zoom behavior.
|
double |
scale()
Returns the current zoom scale, which defaults to 1.
|
Zoom |
scale(double scale)
Specifies the current zoom scale.
|
Array<Double> |
scaleExtent()
Return the zoom scale's allowed range as a two-element array, [*minimum*,
maximum].
|
Zoom |
scaleExtent(Array<Double> scale)
Specifies the zoom scale's allowed range as a two-element array,
[*minimum*, maximum].
|
Array<Double> |
size()
Returns the current viewport size which defaults to [960, 500].
|
Zoom |
size(int width,
int height)
If size is specified, sets the viewport size to the specified dimensions
[width, height] and returns this zoom behavior.
|
Array<Double> |
translate()
Returns the current translation vector, which defaults to [0, 0].
|
Zoom |
translate(Array<Double> vector)
Specifies the current zoom translation vector.
|
QuantitativeScale<?> |
x()
Return the current x-scale that is automatically adjusted when zooming,
or null if no scale have been specified.
|
Zoom |
x(QuantitativeScale<?> scale)
Specifies an x-scale whose domain should be automatically adjusted when
zooming.
|
QuantitativeScale<?> |
y()
Return the current y-scale that is automatically adjusted when zooming,
or null if no scale have been specified.
|
Zoom |
y(QuantitativeScale<?> scale)
Specifies an y-scale whose domain should be automatically adjusted when
zooming.
|
public final Zoom on(Zoom.ZoomEventType type, DatumFunction<Void> listener)
See Zoom.ZoomEventType
for more information.
If an event listener was already registered for the same type, the existing listener is removed before the new listener is added. TODO: To register multiple listeners for the same event type, the type may be followed by an optional namespace, such as "zoom.foo" and "zoom.bar". To remove a listener, pass null as the listener.
For mousewheel events, which happen discretely with no explicit start and end reported by the browser, events that occur within 50 milliseconds of each other are grouped into a single zoom gesture. If you want more robust interpretation of these gestures, please petition your browser vendor of choice for better touch event support.
type
- listener
- public final QuantitativeScale<?> x()
public final Zoom x(QuantitativeScale<?> scale)
If the scale's domain or range is modified programmatically, this function should be called again.
scale
- the scalepublic final QuantitativeScale<?> y()
public final Zoom y(QuantitativeScale<?> scale)
If not specified, returns the current y-scale, which defaults to null. If the scale's domain or range is modified programmatically, this function should be called again
the
- scalepublic final Array<Double> scaleExtent()
public final Zoom scaleExtent(Array<Double> scale)
the
- zoom scale's allowed range as a two-element arraypublic final Zoom center(double x, double y)
A null center indicates that mousewheel zooming should zoom in and out around the current mouse location.
public final Array<Double> center()
A null center indicates that mousewheel zooming should zoom in and out around the current mouse location.
public final Zoom size(int width, int height)
A size is needed to support smooth zooming during transitions.
width
- the width of the viewportheight
- the height of the viewportpublic final Array<Double> size()
public final double scale()
public final Zoom scale(double scale)
scale
- the zoom scale factorpublic final Array<Double> translate()
public final Zoom translate(Array<Double> vector)
the
- current zoom translation vectorpublic final Zoom event(Selection selection)
Zoom.ZoomEventType.ZOOMSTART
,
Zoom.ZoomEventType.ZOOM
and Zoom.ZoomEventType.ZOOMEND
.
This can be useful in triggering listeners after setting the
translate(Array)
or scale(double)
programatically.
selection
- the selection to triggers the events to.public final Zoom event(Transition selection)
Zoom.ZoomEventType.ZOOMSTART
event when the transition starts from the
previously-set view, Zoom.ZoomEventType.ZOOM
events for each tick of
the transition, and finally a Zoom.ZoomEventType.ZOOMEND
event when
the transition ends.
Note that the transition will be interrupted if the user starts zooming before the transition ends.
selection
- Copyright © 2017 gwt-d3. All rights reserved.