goog.Disposable | |
goog.events.EventTarget | goog.Disposable |
goog.fx.AbstractDragDrop | goog.events.EventTarget |
goog.fx.DragDrop | goog.fx.AbstractDragDrop |
element
: Element | string
Dom Node, or string representation of node
id, to be used as drag source/drop target.
|
opt_data
: Object=
Data associated with the source/target.
|
![]()
Add possible drop target for current drag operation.
Arguments:
|
code » | ||||
![]()
Add item to drag object.
|
code » | ||||
![]()
Makes drag and drop aware of a target container that could scroll mid drag.
Arguments:
|
code » | ||||
![]()
Associate drop target with drag element.
Arguments:
|
code » | ||||
![]()
Called after a drag operation has finished.
Arguments:
|
code » | ||||
![]()
Calculate the outer bounds (the region all targets are inside).
Arguments:
|
code » | ||||
Use goog.fx.Dragger.cloneNode().
Creates copy of node being dragged.
|
code » | ||||
![]()
Event handler for containers scrolling.
Arguments:
|
code » | ||||
Creates an element for the item being dragged.
|
code » | ||||
Generates an element to follow the cursor during dragging, given a drag
source element. The default behavior is simply to clone the source element,
but this may be overridden in subclasses. This method is called by
createDragElement() before the drag class is added.
|
code » | ||||
Creates the Dragger for the drag element.
Arguments:
Returns: !goog.fx.Dragger
The new Dragger.
|
code » | ||||
![]()
Called once a drag operation has finished. Removes event listeners and
elements.
|
code » | ||||
![]()
No description.
|
code » | ||||
![]()
Called when removing an item. Removes event listeners and classes.
Arguments:
|
code » | ||||
![]()
Cleans up the scrollable container listeners.
|
code » | ||||
![]()
Event handler that's used to stop drag. Fires a drop event if over a valid
target.
Arguments:
|
code » | ||||
Returns the position for the drag element.
Arguments:
Returns: !goog.math.Coordinate
The position for the drag element.
|
code » | ||||
Returns the dragger object.
Returns: goog.fx.Dragger
The dragger object used by this drag and drop
instance.
|
code » | ||||
Calculates the position and dimension of a draggable element.
Arguments:
Returns: !goog.math.Box
Box describing the position and dimension
of element.
|
code » | ||||
Get the position of a drag event.
Arguments:
Returns: !goog.math.Coordinate
Position of the event.
|
code » | ||||
Gets the scroll distance as a coordinate object, using
the window of the current drag element's dom.
Returns: !goog.math.Coordinate
Object with scroll offsets 'x' and 'y'.
|
code » | ||||
Returns the target for a given cursor position.
Arguments:
Returns: Object
Target for position or null if no target was defined
for the given position.
|
code » | ||||
![]()
Initialize drag and drop functionality for sources/targets already added.
Sources/targets added after init has been called will initialize themselves
one by one.
|
code » | ||||
![]()
Initializes a single item.
Arguments:
|
code » | ||||
![]()
Sets up listeners for the scrollable containers that keep track of their
scroll positions.
|
code » | ||||
Whether the control has been initialized.
Returns: boolean
True if it's been initialized.
|
code » | ||||
Use goog.math.Box.contains.
Checks whatever a given point is inside a given box.
Arguments:
Returns: boolean
Whether the given point is inside
box .
|
code » | ||||
Creates a dummy target for the given cursor position. The assumption is to
create as big dummy target box as possible, the only constraints are:
- The dummy target box cannot overlap any of real target boxes.
- The dummy target has to contain a point with current mouse coordinates.
NOTE: For performance reasons the box construction algorithm is kept simple
and it is not optimal (see example below). Currently it is O(n) in regard to
the number of real drop target boxes, but its result depends on the order
of those boxes being processed (the order in which they're added to the
targetList_ collection).
The algorithm.
a) Assumptions
- Mouse pointer is in the bounding box of real target boxes.
- None of the boxes have negative coordinate values.
- Mouse pointer is not contained by any of "real target" boxes.
- For targets inside a scrollable container, the box used is the
intersection of the scrollable container's box and the target's box.
This is because the part of the target that extends outside the scrollable
container should not be used in the clipping calculations.
b) Outline
- Initialize the fake target to the bounding box of real targets.
- For each real target box - clip the fake target box so it does not contain
that target box, but does contain the mouse pointer.
-- Project the real target box, mouse pointer and fake target box onto
both axes and calculate the clipping coordinates.
-- Only one coordinate is used to clip the fake target box to keep the
fake target as big as possible.
-- If the projection of the real target box contains the mouse pointer,
clipping for a given axis is not possible.
-- If both clippings are possible, the clipping more distant from the
mouse pointer is selected to keep bigger fake target area.
- Save the created fake target only if it has a big enough area.
c) Example
Input: Algorithm created box: Maximum box: +---------------------+ +---------------------+ +---------------------+ | B1 | B2 | | B1 B2 | | B1 B2 | | | | | +-------------+ | |+-------------------+| |---------x-----------| | | | | || || | | | | | | | || || | | | | | | | || || | | | | | | | || || | | | | | | | || || | | | | +-------------+ | |+-------------------+| | B4 | B3 | | B4 B3 | | B4 B3 | +---------------------+ +---------------------+ +---------------------+
Returns: goog.fx.ActiveDropTarget_
Dummy drop target.
|
code » | ||||
![]()
Starts a drag event for an item if the mouse button stays pressed and the
cursor moves a few pixels. Allows dragging of items without first having to
register them with addItem.
Arguments:
|
code » | ||||
![]()
Event handler for drag events. Determines the active drop target, if any, and
fires dragover and dragout events appropriately.
Arguments:
|
code » | ||||
![]()
Recalculates the geometry of this source's drag targets. Call this
if the position or visibility of a drag target has changed during
a drag, or if targets are added or removed.
TODO(user): this is an expensive operation; more efficient APIs
may be necessary.
|
code » | ||||
![]()
Recalculates the current scroll positions of scrollable containers and
allocates targets. Call this if the position of a container changed or if
targets are added or removed.
|
code » | ||||
![]()
Removes all scrollable containers.
|
code » | ||||
![]()
Removes all items.
|
code » | ||||
![]()
Set class to add to source elements being dragged.
Arguments:
|
code » | ||||
![]()
Sets the SCROLL event target to make drag element follow scrolling.
Arguments:
|
code » | ||||
![]()
Set class to add to source elements.
Arguments:
|
code » | ||||
![]()
Set a function that provides subtargets. A subtargeting function
returns an arbitrary identifier for each subtarget of an element.
DnD code will generate additional drag over / out events when
switching from subtarget to subtarget. This is useful for instance
if you are interested if you are on the top half or the bottom half
of the element.
The provided function will be given the DragDropItem, box, x, y
box is the current window coordinates occupied by element
x, y is the mouse position in window coordinates
Arguments:
|
code » | ||||
![]()
Set class to add to target elements.
Arguments:
|
code » | ||||
![]()
Event handler that's used to start drag.
Arguments:
|
code » | ||||
Event handler for suppressing selectstart events. Selecting should be
disabled while dragging.
Arguments:
Returns: boolean
Whether to perform default behavior.
|
code » |
![]()
Use
#listen instead, when possible. Otherwise, use
goog.events.listen if you are passing Object
(instead of Function) as handler.
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.
Arguments:
|
code » | |||||
![]()
Asserts that the event target instance is initialized properly.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
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.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » | |||||
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.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
Use
#unlisten instead, when possible. Otherwise, use
goog.events.unlisten if you are passing Object
(instead of Function) as handler.
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.
Arguments:
|
code » | |||||
![]()
Sets the parent of this event target to use for capture/bubble
mechanism.
Arguments:
|
code » | |||||
![]()
Sets the target to be used for
event.target when firing
event. Mainly used for testing. For example, see
goog.testing.events.mixinListenable .
Arguments:
|
code » | |||||
![]()
No description.
|
code » | |||||
![]()
No description.
|
code » |
![]()
Invokes a callback function when this object is disposed. Callbacks are
invoked in the order in which they were added.
Arguments:
|
code » | |||
![]()
Disposes of the object. If the object hasn't already been disposed of, calls
#disposeInternal . Classes that extend goog.Disposable should
override #disposeInternal in order to delete references to COM
objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void
Nothing.
|
code » | |||
![]()
Deletes or nulls out any references to COM objects, DOM nodes, or other
disposable objects. Classes that extend
goog.Disposable should
override this method.
Not reentrant. To avoid calling it twice, it must only be called from the
subclass' disposeInternal method. Everywhere else the public
dispose method must be used.
For example:
mypackage.MyClass = function() { mypackage.MyClass.base(this, 'constructor'); // Constructor logic specific to MyClass. ... }; goog.inherits(mypackage.MyClass, goog.Disposable); mypackage.MyClass.prototype.disposeInternal = function() { // Dispose logic specific to MyClass. ... // Call superclass's disposeInternal at the end of the subclass's, like // in C++, to avoid hard-to-catch issues. mypackage.MyClass.base(this, 'disposeInternal'); }; |
code » | |||
Use
#isDisposed instead.
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
![]()
Associates a disposable object with this object so that they will be disposed
together.
Arguments:
|
code » |
![]()
No description.
|
Code » |
![]()
Last active subtarget.
|
Code » | |
![]()
No description.
|
Code » | |
![]()
Class name to add to source elements being dragged. Set by setDragClass.
|
Code » | |
Dummy target, .
|
Code » | |
![]()
Whether the object has been initialized.
|
Code » | |
![]()
Flag indicating if it's a drag source, set by addTarget.
|
Code » | |
![]()
Flag indicating if it's a drop target, set when added as target to another
DragDrop object.
|
Code » | |
![]()
List of items that makes up the drag source or drop target.
|
Code » | |
![]()
The SCROLL event target used to make drag element follow scrolling.
|
Code » | |
![]()
Scrollable containers to account for during drag
|
Code » | |
![]()
Class name to add to source elements. Set by setSourceClass.
|
Code » | |
![]()
Subtargeting function accepting args:
(goog.fx.DragDropItem, goog.math.Box, number, number)
|
Code » | |
![]()
Class name to add to target elements. Set by setTargetClass.
|
Code » | |
![]()
List of associated drop targets.
|
Code » |
The object to use for event.target. Useful when mixing in an
EventTarget to another object.
|
Code » | |
![]()
No description.
|
Code » | |
Maps of event type to an array of listeners.
|
Code » | |
Parent event target, used during event bubbling.
TODO(user): Change this to goog.events.Listenable. This
currently breaks people who expect getParentEventTarget to return
goog.events.EventTarget.
|
Code » |
![]()
No description.
|
Code » |