# Yahoo! UI Library

### Drag and Drop 2.8.1

Yahoo! UI Library > dragdrop > YAHOO.util.DD
Search:
Filters Show Private Show Protected Show Deprecated

## Class YAHOO.util.DD - extends YAHOO.util.DragDrop

Known Subclasses:
  YAHOO.util.DDProxy YAHOO.widget.SliderThumb

A DragDrop implementation where the linked element follows the mouse cursor during a drag.

### Constructor

YAHOO.util.DD `( id , sGroup , config )`

Parameters:
  `id <String>` the id of the linked element
  `sGroup <String>` the group of related DragDrop items
  `config <object>` an object containing configurable attributes Valid properties for DD: scroll

### Properties

#### scroll - `boolean`

When set to true, the utility automatically tries to scroll the browser window when a drag and drop element is dragged near the viewport boundary. Defaults to true.

#### Properties inherited from YAHOO.util.DragDrop:

`__ygDragDrop, _domRef, available, config, constrainX, constrainY, cursorIsOver, deltaX, deltaY, dragElId, dragOnly, events, groups, handleElId, hasOuterHandles, id, invalidHandleClasses, invalidHandleIds, invalidHandleTypes, isTarget, locked, maintainOffset, maxX, maxY, minX, minY, overlap, padding, primaryButtonOnly, startPageX, startPageY, useShim, xTicks, yTicks`

### Methods

#### alignElWithMouse

`void alignElWithMouse ( el , iPageX , iPageY )`
Sets the element to the location of the mousedown or click event, maintaining the cursor location relative to the location on the element that was clicked. Override this if you want to place the element in a location other than where the cursor is.

Parameters:
  `el <HTMLElement>` the element to move
  `iPageX <int>` the X coordinate of the mousedown or drag event
  `iPageY <int>` the Y coordinate of the mousedown or drag event

#### autoOffset

`void autoOffset ( iPageX , iPageY )`
Sets the pointer offset to the distance between the linked element's top left corner and the location the element was clicked

Parameters:
  `iPageX <int>` the X coordinate of the click
  `iPageY <int>` the Y coordinate of the click

#### autoScroll

`private void autoScroll ( x , y , h , w )`
Auto-scroll the window if the dragged object has been moved beyond the visible window boundary.

Parameters:
  `x <int>` the drag element's x position
  `y <int>` the drag element's y position
  `h <int>` the height of the drag element
  `w <int>` the width of the drag element

#### cachePosition

`void cachePosition ( iPageX , iPageY )`
Saves the most recent position so that we can reset the constraints and tick marks on-demand. We need to know this so that we can calculate the number of pixels the element is offset from its original position.

Parameters:
  `iPageX <object>` the current x position (optional, this just makes it so we don't have to look it up again)
  `iPageY <object>` the current y position (optional, this just makes it so we don't have to look it up again)

#### setDelta

`void setDelta ( iDeltaX , iDeltaY )`
Sets the pointer offset. You can call this directly to force the offset to be in a particular location (e.g., pass in 0,0 to set it to the center of the object, as done in YAHOO.widget.Slider)

Parameters:
  `iDeltaX <int>` the distance from the left
  `iDeltaY <int>` the distance from the top

#### setDragElPos

`void setDragElPos ( iPageX , iPageY )`
Sets the drag element to the location of the mousedown or click event, maintaining the cursor location relative to the location on the element that was clicked. Override this if you want to place the element in a location other than where the cursor is.

Parameters:
  `iPageX <int>` the X coordinate of the mousedown or drag event
  `iPageY <int>` the Y coordinate of the mousedown or drag event

#### Methods inherited from YAHOO.util.DragDrop:

`addInvalidHandleClass, addInvalidHandleId, addInvalidHandleType, addToGroup, applyConfig, b4Drag, b4DragDrop, b4DragOut, b4DragOver, b4EndDrag, b4MouseDown, b4StartDrag, clearConstraints, clearTicks, clickValidator, endDrag, getDragEl, getEl, getTargetCoord, getTick, handleMouseDown, handleOnAvailable, init, initTarget, isLocked, isValidHandleChild, lock, on, onAvailable, onDrag, onDragDrop, onDragEnter, onDragOut, onDragOver, onInvalidDrop, onMouseDown, onMouseUp, removeFromGroup, removeInvalidHandleClass, removeInvalidHandleId, removeInvalidHandleType, resetConstraints, setDragElId, setHandleElId, setInitialPosition, setOuterHandleElId, setPadding, setStartPosition, setXConstraint, setXTicks, setYConstraint, setYTicks, startDrag, toString, unlock, unreg`

### Events

#### b4DragDropEvent

`b4DragDropEvent ( )`
Fires before the dragDropEvent

#### b4DragEvent

`b4DragEvent ( )`
Fires before the dragEvent.

#### b4DragOutEvent

`b4DragOutEvent ( )`
Fires before the dragOutEvent

#### b4DragOverEvent

`b4DragOverEvent ( )`
Fires before the dragOverEvent.

#### b4EndDragEvent

`b4EndDragEvent ( )`
Fires before the endDragEvent. Returning false will cancel.

#### b4MouseDownEvent

`b4MouseDownEvent ( )`
Provides access to the mousedown event, before the mouseDownEvent gets fired. Returning false will cancel the drag.

#### b4StartDragEvent

`b4StartDragEvent ( )`
Fires before the startDragEvent, returning false will cancel the startDrag Event.

#### dragDropEvent

`dragDropEvent ( )`
Fires when the dragged objects is dropped on another.

#### dragEnterEvent

`dragEnterEvent ( )`
Occurs when the dragged object first interacts with another targettable drag and drop object.

#### dragEvent

`dragEvent ( )`
Occurs every mousemove event while dragging.

#### dragOutEvent

`dragOutEvent ( )`
Fires when a dragged object is no longer over an object that had the onDragEnter fire.

#### dragOverEvent

`dragOverEvent ( )`
Fires every mousemove event while over a drag and drop object.

#### endDragEvent

`endDragEvent ( )`
Fires on the mouseup event after a drag has been initiated (startDrag fired).

#### invalidDropEvent

`invalidDropEvent ( )`
Fires when the dragged objects is dropped in a location that contains no drop targets.

#### mouseDownEvent

`mouseDownEvent ( )`
Provides access to the mousedown event. The mousedown does not always result in a drag operation.

#### mouseUpEvent

`mouseUpEvent ( )`
Fired from inside DragDropMgr when the drag operation is finished.

#### startDragEvent

`startDragEvent ( )`
Occurs after a mouse down and the drag threshold has been met. The drag threshold default is either 3 pixels of mouse movement or 1 full second of holding the mousedown.

#### Events inherited from YAHOO.util.DragDrop:

`b4DragDropEvent, b4DragEvent, b4DragOutEvent, b4DragOverEvent, b4EndDragEvent, b4MouseDownEvent, b4StartDragEvent, dragDropEvent, dragEnterEvent, dragEvent, dragOutEvent, dragOverEvent, endDragEvent, invalidDropEvent, mouseDownEvent, mouseUpEvent, startDragEvent,`

Copyright © 2010 Yahoo! Inc. All rights reserved.