public class Drag extends com.google.gwt.core.client.JavaScriptObject implements IsFunction
Usage:
{ @code Drag drag = D3.behavior.drag().on(DragEventType.drag, new MyDragListener()); mySelection.call(drag); }
Modifier and Type | Class and Description |
---|---|
static class |
Drag.DragEvent
Provide access to the properties of a drag event.
|
static class |
Drag.DragEventType
Type of drag event to listen to.
|
Modifier | Constructor and Description |
---|---|
protected |
Drag() |
Modifier and Type | Method and Description |
---|---|
Drag |
on(Drag.DragEventType type,
DatumFunction<Void> listener)
Registers the specified listener to receive events of the specified type
from the drag behavior.
|
Drag |
origin(DatumFunction<Coords> o)
Set the origin accessor to the specified function.
|
Drag |
origin(com.google.gwt.core.client.JavaScriptObject o)
Set the origin accessor to the specified function.
|
public final Drag on(Drag.DragEventType type, DatumFunction<Void> listener)
See Drag.DragEventType
for more information.
type
- listener
- public final Drag origin(com.google.gwt.core.client.JavaScriptObject o)
An origin accessor is used to determine the starting position (the
“origin?) of the element being dragged; this allows the drag behavior to
preserve the offset between the mouse position and the starting element
position during drag. If the origin accessor is null, then the element
position is set to the mouse position on drag; this can cause a
noticeable jump on large elements. If an origin accessor is specified,
the function is called on mousedown. The function is invoked in the same
manner as other operator functions, being passed the current datum d and
index i, with the this context as the clicked-on DOM element. To access
the current event, use the global D3.event()
. The origin accessor
must return an object with x and y properties representing the starting
coordinates of the element being dragged.
Frequently the origin accessor is specified as Object, or
D3.identity()
, which is equivalent to the identity function. This
is suitable when the datum bound to the dragged element is already an
object with x and y attributes representing its current position.
For example: http://bl.ocks.org/1557377
o
- the origin accessor function, returning an object with x and y
attributes.public final Drag origin(DatumFunction<Coords> o)
An origin accessor is used to determine the starting position (the
“origin?) of the element being dragged; this allows the drag behavior to
preserve the offset between the mouse position and the starting element
position during drag. If the origin accessor is null, then the element
position is set to the mouse position on drag; this can cause a
noticeable jump on large elements. If an origin accessor is specified,
the function is called on mousedown. The function is invoked in the same
manner as other operator functions, being passed the current datum d and
index i, with the this context as the clicked-on DOM element. To access
the current event, use the global D3.event()
. The origin accessor
must return an object with x and y properties representing the starting
coordinates of the element being dragged.
Frequently the origin accessor is specified as Object, or
D3.identity()
, which is equivalent to the identity function. This
is suitable when the datum bound to the dragged element is already an
object with x and y attributes representing its current position.
For example: http://bl.ocks.org/1557377
o
- the origin accessor function, returning an object with x and y
attributes.Copyright © 2015 gwt-d3. All rights reserved.