The goog.fx.Dragger Class

goog.fx.Dragger
> goog.events.EventTarget
> goog.Disposable

goog.fx.Dragger(target, opt_handle, opt_limits)

A class that allows mouse or touch-based dragging (moving) of an element

target {Element}
The element that will be dragged.
opt_handle {Element=}
An optional handle to control the drag, if null the target is used.
opt_limits {goog.math.Rect=}
Object containing left, top, width, and height.

The goog.fx.Dragger.EventType Enum

Constants for event names. … more

.addEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched. Supported for legacy but use goog.events.listen(src, type, handler) instead.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.clientX {number}

Current x position of mouse or touch relative to viewport.

.clientY {number}

Current y position of mouse or touch relative to viewport.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.defaultAction(x, y)

Overridable function for handling the default action of the drag behaviour. Normally this is simply moving the element to x,y though in some cases it might be used to resize the layer. This is basically a shortcut to implementing a default ondrag event handler.

x {number}
X-coordinate for target element. In right-to-left, x this is the number of pixels the target should be moved to from the right.
y {number}
Y-coordinate for target element.

.deltaX {number}

Current x position of drag relative to target's parent.

.deltaY {number}

Current y position of drag relative to target's parent.

.dispatchEvent(e)

Inherited from goog.events.EventTarget .

Dispatches an event (or event like object) and calls all listeners listening for events of this type. The type of the event is decided by the type property on the event object. If any of the listeners returns false OR calls preventDefault then this function will return false. If one of the capture listeners calls stopPropagation, then the bubble listeners won't fire.

e {string|Object|goog.events.Event}
Event object.
returns {boolean}
If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.enableRightPositioningForRtl(useRightPositioningForRtl)

Turns on/off true RTL behavior. This should be called immediately after construction. This is a temporary flag to allow clients to transition to the new component at their convenience. At some point true will be the default.

useRightPositioningForRtl {boolean}
True if "right" should be used for positioning, false if "left" should be used for positioning.

.endDrag(e, opt_dragCanceled)

Event handler that is used to end the drag.

e {goog.events.BrowserEvent}
Event object.
opt_dragCanceled {boolean=}
Whether the drag has been canceled.

.endDragCancel(e)

Event handler that is used to end the drag by cancelling it.

e {goog.events.BrowserEvent}
Event object.

.getEnabled()

returns {boolean}
Whether the dragger is enabled.

.getHandler()

Returns the event handler, intended for subclass use.

returns {goog.events.EventHandler}
The event handler.

.getHysteresis()

Gets the distance the user has to drag the element before a drag operation is started.

returns {number}
distance The number of pixels after which a mousedown and move is considered a drag.

.getParentEventTarget()

Inherited from goog.events.EventTarget .

Returns the parent of this event target to use for bubbling.

returns {goog.events.EventTarget}
The parent EventTarget or null if there is no parent.

.handle {Element}

Reference to the handler that initiates the drag.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.isDragging()

returns {boolean}
Whether the dragger is currently in the midst of a drag.

.limitX(x)

Returns the 'real' x after limits are applied (allows for some limits to be undefined).

x {number}
X-coordinate to limit.
returns {number}
The 'real' X-coordinate after limits are applied.

.limitY(y)

Returns the 'real' y after limits are applied (allows for some limits to be undefined).

y {number}
Y-coordinate to limit.
returns {number}
The 'real' Y-coordinate after limits are applied.

.limits {goog.math.Rect}

Object representing the limits of the drag region.

.pageScroll {goog.math.Coordinate}

The current page scroll value.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.removeEventListener(type, handler, opt_capture, opt_handlerScope)

Inherited from goog.events.EventTarget .

Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.

type {string}
The type of the event to listen for.
handler {Function|Object}
The function to handle the event. The handler can also be an object that implements the handleEvent method which takes the event object as argument.
opt_capture {boolean=}
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope {Object=}
Object in whose scope to call the listener.

.setCancelIeDragStart(cancelIeDragStart)

Enables cancelling of built-in IE drag events.

cancelIeDragStart {boolean}
Whether to enable cancelling of IE dragstart event.

.setEnabled(enabled)

Set whether dragger is enabled

enabled {boolean}
Whether dragger is enabled.

.setHysteresis(distance)

Sets the distance the user has to drag the element before a drag operation is started.

distance {number}
The number of pixels after which a mousedown and move is considered a drag.

.setLimits(limits)

Sets (or reset) the Drag limits after a Dragger is created.

limits {goog.math.Rect?}
Object containing left, top, width, height for new Dragger limits. If target is right-to-left and enableRightPositioningForRtl(true) is called, then rect is interpreted as right, top, width, and height.

.setParentEventTarget(parent)

Inherited from goog.events.EventTarget .

Sets the parent of this event target to use for bubbling.

parent {goog.events.EventTarget?}
Parent EventTarget (null if none).

.setScrollTarget(scrollTarget)

Sets the SCROLL event target to make drag element follow scrolling.

scrollTarget {EventTarget}
The event target that dispatches SCROLL events.

.startDrag(e)

Event handler that is used to start the drag

e {goog.events.BrowserEvent}
Event object.

.startX {number}

The x position where the first mousedown or touchstart occurred.

.startY {number}

The y position where the first mousedown or touchstart occurred.

.target {Element}

Reference to drag target element.