fx.DragDropGroup Extends goog.fx.AbstractDragDrop
Drag/drop implementation for creating drag sources/drop targets consisting of multiple HTML Elements (items). All items share the same drop target(s) but can be dragged individually.

Inheritance

Constructor

goog.fx.DragDropGroup()

Instance Methods

Public Protected Private
addDragDropItem(item)
Add DragDropItem to drag object.
Arguments:
item :
DragDropItem being added to the drag object.
code »
addItem(elementopt_data)
Add item to drag object.
Arguments:
element :
(Element | null | string)
Dom Node, or string representation of node id, to be used as drag source/drop target.
opt_data :
(Object | null | undefined)
Data associated with the source/target.
code »
removeItem(element)
Remove item from drag object.
Arguments:
element :
(Element | null | string)
Dom Node, or string representation of node id, that was previously added with addItem().
code »
setSelection(list)
Marks the supplied list of items as selected. A drag operation for any of the selected items will affect all of them.
Arguments:
list :
(Array.<(goog.fx.DragDropItem | null)> | null)
List of items to select or null to clear selection. TODO(eae): Not yet implemented.
code »
addDragTarget_(targetitem)
Add possible drop target for current drag operation.
Arguments:
target :
Drag handler.
item :
Item that's being dragged.
code »
addItem(element)
Add item to drag object.
Arguments:
element :
(Element | null | string)
Dom Node, or string representation of node id, to be used as drag source/drop target.
code »
addScrollableContainer(element)
Makes drag and drop aware of a target container that could scroll mid drag.
Arguments:
element :
(Element | null)
The scroll container.
code »
addTarget(target)
Associate drop target with drag element.
Arguments:
target :
Target to add.
code »
afterEndDrag(opt_dropTarget)
Called after a drag operation has finished.
Arguments:
opt_dropTarget :
(goog.fx.DragDropItem | null | undefined)
Target for successful drop.
code »
calculateTargetBox_(box)
Calculate the outer bounds (the region all targets are inside).
Arguments:
box :
(goog.math.Box | null)
Box describing the position and dimension of a drag target.
code »
cloneNode_(sourceEl)
(Element | null)
Creates copy of node being dragged.
Arguments:
sourceEl :
(Element | null)
Element to copy.
Returns: 
(Element | null)
  The clone of sourceEl.
code »
containerScrollHandler_(e)
Event handler for containers scrolling.
Arguments:
e :
The event.
code »
createDragElement(sourceEl)
(Element | null)
Creates an element for the item being dragged.
Arguments:
sourceEl :
(Element | null)
Drag source element.
Returns: 
(Element | null)
  The new drag element.
code »
createDraggerFor(sourceElelevent)
(goog.fx.Dragger | null)
Creates the Dragger for the drag element.
Arguments:
sourceEl :
(Element | null)
Drag source element.
el :
(Element | null)
the element created by createDragElement().
event :
Mouse down event for start of drag.
Returns: 
(goog.fx.Dragger | null)
  The new Dragger.
code »
disposeDrag()
Called once a drag operation has finished. Removes event listeners and elements.
code »
disposeInternal()
No description.
code »
disposeItem(item)
Called when removing an item. Removes event listeners and classes.
Arguments:
item :
Item to dispose.
code »
disposeScrollableContainerListeners_()
Cleans up the scrollable container listeners.
code »
endDrag(event)
Event handler that's used to stop drag. Fires a drop event if over a valid target.
Arguments:
event :
Drag event.
code »
getDragElementPosition(eldragElevent)
Returns the position for the drag element.
Arguments:
el :
(Element | null)
Drag source element.
dragEl :
(Element | null)
The dragged element created by createDragElement().
event :
Mouse down event for start of drag.
Returns:   The position for the drag element.
code »
getDragger()
(goog.fx.Dragger | null)
Returns the dragger object.
Returns: 
(goog.fx.Dragger | null)
  The dragger object used by this drag and drop instance.
code »
getEventPosition(event)
Get the position of a drag event.
Arguments:
event :
Drag event.
Returns:   Position of the event.
code »
getScrollPos()
Gets the scroll distance as a coordinate object, using the window of the current drag element's dom.
Returns:   Object with scroll offsets 'x' and 'y'.
code »
getTargetFromPosition_(position)
(Object | null)
Returns the target for a given cursor position.
Arguments:
position :
Cursor position.
Returns: 
(Object | null)
  Target for position or null if no target was defined for the given position.
code »
init()
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 »
initItem(item)
Initializes a single item.
Arguments:
item :
Item to initialize.
code »
initScrollableContainerListeners_()
Sets up listeners for the scrollable containers that keep track of their scroll positions.
code »
isInitialized()
Whether the control has been initialized.
Returns:   True if it's been initialized.
code »
isInside(xybox)
Use goog.math.Box.contains. Checks whatever a given point is inside a given box.
Arguments:
x :
Cursor position on the x-axis.
y :
Cursor position on the y-axis.
box :
(goog.math.Box | null)
Box to check position against.
Returns:   Whether the given point is inside box.
code »
maybeCreateDummyTargetForPosition_(xy)
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 |
+---------------------+ +---------------------+ +---------------------+
Arguments:
x :
Cursor position on the x-axis.
y :
Cursor position on the y-axis.
Returns:   Dummy drop target.
code »
maybeStartDrag(eventitem)
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:
event :
Mouse down event.
item :
Item that's being dragged.
code »
moveDrag_(event)
Event handler for drag events. Determines the active drop target, if any, and fires dragover and dragout events appropriately.
Arguments:
event :
Drag event.
code »
recalculateDragTargets()
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 »
recalculateScrollableContainers()
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 »
removeAllScrollableContainers()
Removes all scrollable containers.
code »
removeItems()
Removes all items.
code »
setDragClass(className)
Set class to add to source elements being dragged.
Arguments:
className :
Class to be added.
code »
setScrollTarget(scrollTarget)
Sets the SCROLL event target to make drag element follow scrolling.
Arguments:
scrollTarget :
(EventTarget | null)
The element that dispatches SCROLL events.
code »
setSourceClass(className)
Set class to add to source elements.
Arguments:
className :
Class to be added.
code »
setSubtargetFunction(f)
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:
f :
(Function | null)
The new subtarget function.
code »
setTargetClass(className)
Set class to add to target elements.
Arguments:
className :
Class to be added.
code »
startDrag(eventitem)
Event handler that's used to start drag.
Arguments:
event :
Mouse move event.
item :
Item that's being dragged.
code »
suppressSelect_(event)
Event handler for suppressing selectstart events. Selecting should be disabled while dragging.
Arguments:
event :
The selectstart event to suppress.
Returns:   Whether to perform default behavior.
code »
addEventListener(typehandleropt_captureopt_handlerScope)
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.
Arguments:
type :
The type of the event to listen for.
handler :
(Object | null)
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 | undefined)
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope :
(Object | null | undefined)
Object in whose scope to call the listener.
code »
dispatchEvent(e)
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.
Arguments:
e :
(Object | null | string)
Event object.
Returns:   If anyone called preventDefault on the event object (or if any of the handlers returns false this will also return false.
code »
disposeInternal()
Unattach 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, it should be something like this:
MyClass.prototype.disposeInternal = function() {
MyClass.superClass_.disposeInternal.call(this);
// Dispose logic for MyClass
};
code »
getParentEventTarget()
Returns the parent of this event target to use for bubbling.
Returns:   The parent EventTarget or null if there is no parent.
code »
removeEventListener(typehandleropt_captureopt_handlerScope)
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:
type :
The type of the event to listen for.
handler :
(Object | null)
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 | undefined)
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope :
(Object | null | undefined)
Object in whose scope to call the listener.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for bubbling.
Arguments:
parent :
Parent EventTarget (null if none).
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback :
?function (this:T):
The callback function.
opt_scope :
(T | undefined)
An optional scope to call the callback in.
code »
dispose()
undefined
Disposes of the object. If the object hasn&amp;#39;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: 
undefined
  Nothing.
code »
disposeInternal()
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&amp;#39; disposeInternal method. Everywhere else the public dispose method must be used. For example:
mypackage.MyClass = function() {
goog.base(this);
// Constructor logic specific to MyClass.
...
};
goog.inherits(mypackage.MyClass, goog.Disposable);

mypackage.MyClass.prototype.disposeInternal = function() {
// Dispose logic specific to MyClass.
...
// Call superclass&#39;s disposeInternal at the end of the subclass&#39;s, like
// in C++, to avoid hard-to-catch issues.
goog.base(this, &#39;disposeInternal&#39;);
};
code »
getDisposed()
Use #isDisposed instead. No description.
Returns:   Whether the object has been disposed of.
code »
isDisposed()
No description.
Returns:   Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable :
that will be disposed when this object is disposed.
code »

Instance Properties

activeSubtarget_ :
(Object | null)
Last active subtarget.
Code »
dragClass_ :
(null | string)
Class name to add to source elements being dragged. Set by setDragClass.
Code »
dummyTarget_ :
Dummy target, maybeCreateDummyTargetForPosition_.
Code »
initialized_ :
Whether the object has been initialized.
Code »
isSource_ :
Flag indicating if it's a drag source, set by addTarget.
Code »
isTarget_ :
Flag indicating if it's a drop target, set when added as target to another DragDrop object.
Code »
items_ :
(Array.<(goog.fx.DragDropItem | null)> | null)
List of items that makes up the drag source or drop target.
Code »
scrollTarget_ :
(EventTarget | null)
The SCROLL event target used to make drag element follow scrolling.
Code »
scrollableContainers_ :
(Array.<(goog.fx.ScrollableContainer_ | null)> | null)
Scrollable containers to account for during drag
Code »
sourceClass_ :
(null | string)
Class name to add to source elements. Set by setSourceClass.
Code »
subtargetFunction_ :
(Function | null)
Subtargeting function accepting args: (Element, goog.math.Box, number, number)
Code »
targetClass_ :
(null | string)
Class name to add to target elements. Set by setTargetClass.
Code »
targets_ :
(Array.<(goog.fx.AbstractDragDrop | null)> | null)
List of associated drop targets.
Code »
customEvent_ :
Used to tell if an event is a real event in goog.events.listen() so we don't get listen() calling addEventListener() and vice-versa.
Code »
parentEventTarget_ :
Parent event target, used during event bubbling.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
dependentDisposables_ :
(Array.<(goog.disposable.IDisposable | null)> | null)
Disposables that should be disposed when this object is disposed.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
(Array.<Function> | null)
Callbacks to invoke when this object is disposed.
Code »

Package fx

Package Reference