goog.fx.Dragger
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
A class that allows mouse or touch-based dragging (moving) of an element
new Dragger( target, opt_handle, opt_limits )
Parameters |
|
---|
Instance Methods
this.addEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.computeInitialPosition() → void
void
Overridable function for computing the initial position of the target before dragging begins.
this.defaultAction( x, y ) → void
void
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.
Parameters |
|
---|
this.dispatchEvent( e ) → boolean
boolean
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.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
Overrides | |
---|---|
Parameters | None. |
this.doDrag( e, x, y, dragFromScroll ) → void
void
Parameters |
|
---|
this.enableRightPositioningForRtl( useRightPositioningForRtl ) → void
void
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.
Parameters |
|
---|
this.endDrag( e, opt_dragCanceled ) → void
void
Event handler that is used to end the drag.
Parameters |
|
---|
this.endDragCancel( e ) → void
void
Event handler that is used to end the drag by cancelling it.
Parameters |
|
---|
this.fireListeners<EVENTOBJ>( type, capture, eventObject ) → boolean
boolean
Fires all registered listeners in this listenable for the given type and capture mode, passing them the given eventObject. This does not perform actual capture/bubble. Only implementors of the interface should be using this.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
| ||||||||||||
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getEnabled() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHandler<T>() → goog.events.EventHandler<(T|null)>
goog.events.EventHandler<(T|null)>
Returns the event handler, intended for subclass use.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHysteresis() → number
number
Gets the distance the user has to drag the element before a drag operation is started.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getListener<SCOPE, EVENTOBJ>( type, listener, capture, opt_listenerScope ) → (goog.events.ListenableKey|null)
(goog.events.ListenableKey|null)
Gets the goog.events.ListenableKey for the event or null if no such listener is in use.
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.getListeners<EVENTOBJ>( type, capture ) → Array<goog.events.ListenableKey>
Array<goog.events.ListenableKey>
Gets all listeners in this listenable for the given type and capture mode.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.getParentEventTarget() → (goog.events.Listenable|null)
(goog.events.Listenable|null)
Returns the parent of this event target to use for capture/bubble mechanism.
NOTE(chrishenry): The name reflects the original implementation of
custom event target (goog.events.EventTarget
). We decided
that changing the name is not worth it.
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.hasListener<EVENTOBJ>( opt_type, opt_capture ) → boolean
boolean
Whether there is any active listeners matching the specified signature. If either the type or capture parameters are unspecified, the function will match on the remaining criteria.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
| ||||||||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isDragging() → boolean
boolean
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.limitX( x ) → number
number
this.limitY( y ) → number
number
this.listen<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener. A listener can only be added once to an object and if it is added again the key for the listener is returned. Note that if the existing listener is a one-off listener (registered via listenOnce), it will no longer be a one-off listener after a call to listen().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.listenOnce<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → goog.events.ListenableKey
goog.events.ListenableKey
Adds an event listener that is removed automatically after the listener fired once.
If an existing listener already exists, listenOnce will do nothing. In particular, if the listener was previously registered via listen(), listenOnce() will not turn the listener into a one-off listener. Similarly, if there is already an existing one-off listener, listenOnce does not modify the listeners (it is still a once listener).
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.removeAllListeners( opt_type ) → number
number
Removes all listeners from this listenable. If type is specified, it will only remove listeners of the particular type. otherwise all registered listeners will be removed.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
this.removeEventListener( type, handler, opt_capture, opt_handlerScope ) → void
void
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.
warning Deprecated | Use |
---|
Defined by | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.setAllowSetCapture( allow ) → void
void
Prevents the dragger from calling setCapture(), even in browsers that support it. If the draggable item has click handlers, setCapture() can break them.
Parameters |
|
---|
this.setCancelIeDragStart( cancelIeDragStart ) → void
void
Enables cancelling of built-in IE drag events.
Parameters |
|
---|
this.setEnabled( enabled ) → void
void
this.setHysteresis( distance ) → void
void
Sets the distance the user has to drag the element before a drag operation is started.
Parameters |
|
---|
this.setLimits( limits ) → void
void
Sets (or reset) the Drag limits after a Dragger is created.
Parameters |
|
---|
this.setParentEventTarget( parent ) → void
void
Sets the parent of this event target to use for capture/bubble mechanism.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setPreventMouseDown( preventMouseDown ) → void
void
Set whether mousedown should be default prevented.
Parameters |
|
---|
this.setScrollTarget( scrollTarget ) → void
void
Sets the SCROLL event target to make drag element follow scrolling.
Parameters |
|
---|
this.setTargetForTesting( target ) → void
void
Sets the target to be used for event.target
when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable
.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setupDragHandlers() → void
void
Sets up event handlers when dragging starts.
this.startDrag( e ) → void
void
Event handler that is used to start the drag
Parameters |
|
---|
this.unlisten<SCOPE, EVENTOBJ>( type, listener, opt_useCapture, opt_listenerScope ) → boolean
boolean
Removes an event listener which was added with listen() or listenOnce().
Overrides | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||||||
Parameters |
| ||||||||||||||||
Returns |
|
this.unlistenByKey( key ) → boolean
boolean
Removes an event listener which was added with listen() by the key returned by listen().
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
| ||||
Returns |
|
Instance Properties
this.clientX → number
number
Current x position of mouse or touch relative to viewport.
this.clientY → number
number
Current y position of mouse or touch relative to viewport.
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.deltaX → number
number
Current x position of drag relative to target's parent.
this.deltaY → number
number
Current y position of drag relative to target's parent.
this.handle → (Element|null)
(Element|null)
Reference to the handler that initiates the drag.
this.limits → (goog.math.Rect|null)
(goog.math.Rect|null)
Object representing the limits of the drag region.
this.pageScroll → (goog.math.Coordinate|null)
(goog.math.Coordinate|null)
The current page scroll value.
this.screenX → number
number
Current x position of mouse or touch relative to screen. Deprecated because it doesn't take into affect zoom level or pixel density.
warning Deprecated | Consider switching to clientX instead. |
---|
this.screenY → number
number
Current y position of mouse or touch relative to screen. Deprecated because it doesn't take into affect zoom level or pixel density.
warning Deprecated | Consider switching to clientY instead. |
---|
this.startX → number
number
The x position where the first mousedown or touchstart occurred.
this.startY → number
number
The y position where the first mousedown or touchstart occurred.
this.target → (Element|null)
(Element|null)
Reference to drag target element.
Static Functions
Dragger.cloneNode( sourceEl ) → Element
Element
Creates copy of node being dragged. This is a utility function to be used wherever it is inappropriate for the original source to follow the mouse cursor itself.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|