# Yahoo! UI Library

### dd 3.1.1

Yahoo! UI Library > dd > DD.DDM
Search:
Filters Show Private Show Protected Show Deprecated

## Class DD.DDM - extends Base

Provides the base Drag Drop Manger required for making a Node draggable.

### Constructor

DD.DDM `( )`

### Properties

#### _active - `{Boolean}`

flag set when we activate our first drag, so DDM can start listening for events.

#### _activeShims - `private {Array}`

Placeholder for all active shims on the page

#### _debugShim - `private {Boolean}`

Set this to true to set the shims opacity to .5 for debugging it, default: false.

#### _delegates - `private Array`

Holder for all Y.DD.Delegate instances

#### _drags - `private {Array}`

Holder for all registered drag elements.

#### _noShim - `private {Boolean}`

This flag turns off the use of the mouseover/mouseout shim. It should not be used unless you know what you are doing.

#### _pg - `private {Node}`

The shim placed over the screen to track the mousemove event.

#### activeDrag - `{Drag}`

A reference to the currently active draggable object.

#### activeDrop - `{Object}`

A reference to the active Drop Target

#### CSS_PREFIX - `{String}`

The PREFIX to attach to all DD CSS class names

#### INTERSECT - `private Number`

In intersect mode, a Drop is targeted by "part" of the drag node being over the Target

#### mode - `private Number`

The mode that the drag operations will run in 0 for Point, 1 for Intersect, 2 for Strict

#### otherDrops - `{Object}`

An object literal of Other Drop Targets that we encountered during this interaction (in the case of overlapping Drop Targets)

#### POINT - `private Number`

In point mode, a Drop is targeted by the cursor being over the Target

#### STRICT - `private Number`

In strict mode, a Drop is targeted by the "entire" drag node being over the Target

#### targets - `{Array}`

All of the Targets

#### useHash - `{Boolean}`

Should we only check targets that are in the viewport on drags (for performance), default: true

#### validDrops - `{Array}`

An array of the valid Drop Targets for this interaction.

#### Properties inherited from Attribute:

``

#### Properties inherited from Base:

`name`

### Methods

#### _activateTargets

`private void _activateTargets ( )`
Clear the cache and activate the shims of all the targets

#### _addActiveShim

`private void _addActiveShim ( d )`
Adds a Drop Target to the list of active shims

Parameters:
  `d <Object>` The Drop instance to add to the list.

#### _addValid

`private Self _addValid ( drop )`
Add a Drop Target to the list of Valid Targets. This list get's regenerated on each new drag operation.

Parameters:
  `drop <Object>`

Chainable: This method is chainable.

#### _calcTickArray

`private _calcTickArray ( pos , ticks , off1 , off2 )`
This method is used with the tickXArray and tickYArray config options

Parameters:
  `pos <Number>` The current X or Y position
  `ticks <Number>` The array containing our custom tick positions.
  `off1 <Number>` The min offset that we can't pass (region)
  `off2 <Number>` The max offset that we can't pass (region)

Returns: ``
  The tick position

#### _calcTicks

`private Number _calcTicks ( pos , start , tick , off1 , off2 )`
Helper method to calculate the tick offsets for a given position

Parameters:
  `pos <Number>` The current X or Y position
  `start <Number>` The start X or Y position
  `tick <Number>` The X or Y tick increment
  `off1 <Number>` The min offset that we can't pass (region)
  `off2 <Number>` The max offset that we can't pass (region)

Returns: `Number`
  The new position based on the tick calculation

#### _createFrame

`private void _createFrame ( )`
Create the proxy element if it doesn't already exist and set the DD.DDM._proxy value

#### _createPG

`private void _createPG ( )`
Creates the shim and adds it's listeners to it.

#### _deactivateTargets

`private void _deactivateTargets ( )`
This method fires the drop:hit, drag:drophit, drag:dropmiss methods and deactivates the shims..

#### _dropMove

`private void _dropMove ( )`
This method is called when the move method is called on the Drag Object.

#### _end

`private void _end ( )`
Internal method used by Drag to signal the end of a drag operation

#### _endDrag

`private void _endDrag ( )`
Factory method to be overwritten by other DDM's

#### _handleTargetOver

`private void _handleTargetOver ( )`
This method execs _handleTargetOver on all valid Drop Targets

#### _hasActiveShim

`private Boolean _hasActiveShim ( )`
This method checks the _activeShims Object to see if there is a shim active.

#### _lookup

`private Array _lookup ( )`
Filters the list of Drops down to those in the viewport.

Returns: `Array`
  The valid Drop Targets that are in the viewport.

#### _move

`private void _move ( ev )`
Internal listener for the mousemove DOM event to pass to the Drag's move method.

Parameters:
  `ev <Event.Facade>` The Dom mousemove Event

#### _pg_activate

`private void _pg_activate ( )`
Activates the shim

#### _pg_deactivate

`private void _pg_deactivate ( )`
Deactivates the shim

#### _pg_size

`private void _pg_size ( )`
Sizes the shim on: activatation, window:scroll, window:resize

#### _regDrag

`private void _regDrag ( d )`
Adds a reference to the drag object to the DDM._drags array, called in the constructor of Drag.

Parameters:
  `d <Drag>` The Drag object

#### _regTarget

`private void _regTarget ( t )`
Add the passed in Target to the targets collection

Parameters:
  `t <Object>` The Target to add to the targets collection

#### _removeActiveShim

`private void _removeActiveShim ( d )`
Removes a Drop Target to the list of active shims

Parameters:
  `d <Object>` The Drop instance to remove from the list.

#### _removeValid

`private Self _removeValid ( drop )`
Removes a Drop Target from the list of Valid Targets. This list get's regenerated on each new drag operation.

Parameters:
  `drop <Object>`

Chainable: This method is chainable.

#### _setDragMode

`private _setDragMode ( String/Number )`
Handler for dragMode attribute setter.

Parameters:
  `String/Number <object>` The Number value or the String for the DragMode to default all future drag instances to.

Returns: ``
  Number The Mode to be set

#### _setFrame

`private void _setFrame ( )`
If resizeProxy is set to true (default) it will resize the proxy element to match the size of the Drag Element. If positionProxy is set to true (default) it will position the proxy element in the same location as the Drag Element.

#### _setupListeners

`private void _setupListeners ( )`
Add the document listeners.

#### _start

`private void _start ( )`
Internal method used by Drag to signal the start of a drag operation

#### _startDrag

`private void _startDrag ( x , y , w , h )`
Factory method to be overwritten by other DDM's

Parameters:
  `x <Number>` The x position of the drag element
  `y <Number>` The y position of the drag element
  `w <Number>` The width of the drag element
  `h <Number>` The height of the drag element

#### _unregDrag

`private void _unregDrag ( d )`
Remove this drag object from the DDM._drags array.

Parameters:
  `d <Drag>` The drag object.

#### _unregTarget

`private void _unregTarget ( drop )`
Remove the passed in Target from the targets collection

Parameters:
  `drop <Object>` The Target to remove from the targets collection

#### clearCache

`void clearCache ( )`
Clears the cache data used for this interaction.

#### cssSizestoObject

`private Object cssSizestoObject ( gutter )`
//TODO Private, rename??...

Parameters:
  `gutter <String>` CSS style string for gutter: '5 0' (sets top and bottom to 5px, left and right to 0px), '1 2 3 4' (top 1px, right 2px, bottom 3px, left 4px)

Returns: `Object`
  The gutter Object Literal.

#### getBestMatch

`Object or Array getBestMatch ( drops , all )`
This method will gather the area for all potential targets and see which has the hightest covered area and return it.

Parameters:
  `drops <Array>` An Array of drops to scan for the best match.
  `all <Boolean>` If present, it returns an Array. First item is best match, second is an Array of the other items in the original Array.

#### getDelegate

`void getDelegate ( )`
Get a delegate instance from a container node

#### getDrag

`Object getDrag ( node )`
Get a valid Drag instance back from a Node or a selector string, false otherwise

Parameters:
  `node <String/Object>` The Node instance or Selector string to check for a valid Drag Object

#### getDrop

`Object getDrop ( node )`
Get a valid Drop instance back from a Node or a selector string, false otherwise

Parameters:
  `node <String/Object>` The Node instance or Selector string to check for a valid Drop Object

#### getNode

`Node getNode ( n )`
Return a node instance from the given node, selector string or Y.Base extended object.

Parameters:
  `n <Node/Object/String>` The node to resolve.

#### isOverTarget

`Boolean isOverTarget ( drop )`
Check to see if the Drag element is over the target, method varies on current mode

Parameters:
  `drop <Object>` The drop to check against

#### regDelegate

`void regDelegate ( )`
Register a Delegate with the DDM

#### stopDrag

`Self stopDrag ( )`
Method will forcefully stop a drag operation. For example calling this from inside an ESC keypress handler will stop this drag.
Chainable: This method is chainable.

#### swapNode

`Node swapNode ( n1 , n2 )`
Swap the position of 2 nodes based on their DOM location.

Parameters:
  `n1 <Node>` The first node to swap
  `n2 <Node>` The first node to swap

#### swapPosition

`Node swapPosition ( n1 , n2 )`
Swap the position of 2 nodes based on their CSS positioning.

Parameters:
  `n1 <Node>` The first node to swap
  `n2 <Node>` The first node to swap

#### syncActiveShims

`void syncActiveShims ( force )`
This method will sync the position of the shims on the Drop Targets that are currently active.

Parameters:
  `force <Boolean>` Resize/sync all Targets.

#### Methods inherited from EventTarget:

`_getType, _monitor, _parseType, addTarget, after, before, bubble, detach, detachAll, fire, getEvent, getTargets, on, once, publish, removeTarget, subscribe, unsubscribe, unsubscribeAll`

#### Methods inherited from Attribute:

`_addAttrs, _addLazyAttr, _defAttrChangeFn, _fireAttrChange, _getAttr, _getAttrInitVal, _getAttrs, _getStateVal, _isLazyAttr, _normAttrVals, _protectAttrs, _set, _setAttr, _setAttrs, _setAttrVal, _setStateVal, addAttr, addAttrs, attrAdded, get, getAttrs, modifyAttr, removeAttr, reset, set, setAttrs`

#### Methods inherited from Plugin.Host:

`_destroyPlugins, _initPlugins, _plug, _unplug, hasPlugin, plug, unplug`

#### Methods inherited from Base:

`_aggregateAttrs, _defDestroyFn, _defInitFn, _destroyHierarchy, _filterAttrCfs, _getAttrCfgs, _getClasses, _initHierarchy, _initHierarchyData, _preInitEventCfg, destroy, init, toString`

### Events

#### clickPixelThreshChange

`clickPixelThreshChange ( event )`
Fires when the value for the configuration attribute 'clickPixelThresh' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### clickTimeThreshChange

`clickTimeThreshChange ( event )`
Fires when the value for the configuration attribute 'clickTimeThresh' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### ddm:end

`ddm:end ( )`
Fires from the DDM after the DDM finishes, before the drag end events.

#### ddm:start

`ddm:start ( )`
Fires from the DDM before all drag events fire.

#### dragCursorChange

`dragCursorChange ( event )`
Fires when the value for the configuration attribute 'dragCursor' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### dragModeChange

`dragModeChange ( event )`
Fires when the value for the configuration attribute 'dragMode' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### throttleTimeChange

`throttleTimeChange ( event )`
Fires when the value for the configuration attribute 'throttleTime' is changed. You can listen for the event using the on method if you wish to be notified before the attribute's value has changed, or using the after method if you wish to be notified after the attribute's value has changed.

Parameters:
  `event <Event.Facade>` An Event Facade object with the following attribute specific properties added:
  prevVal
    The value of the attribute, prior to it being set
  newVal
    The value the attribute is to be set to
  attrName
    The name of the attribute being set
  subAttrName
    If setting a property within the attribute's value, the name of the sub-attribute property being set

#### Events inherited from Base:

`destroy, destroyedChange, init, initializedChange,`

### Configuration Attributes

#### clickPixelThresh `- Number`

The number of pixels to move to start a drag operation, default is 3.

#### clickTimeThresh `- Number`

The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.

#### dragCursor `- String`

The cursor to apply when dragging, if shimmed the shim will get the cursor.

#### dragMode `- String`

This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of all future Drag instances.

#### throttleTime `- Number`

The number of milliseconds to throttle the mousemove event. Default: 150

#### Configuration attributes inherited from Base:

`destroyed initialized`

Copyright © 2010 Yahoo! Inc. All rights reserved.