Yahoo! UI Library

dd  3.0.0pr2

Yahoo! UI Library > dd > DragConstrained
Search:
 
Filters

Class DragConstrained - extends Drag

This class extends the dd-drag module to add the constraining methods to it. It supports constraining to a region, node or viewport. It also supports tick based moves and XY axis constraints.

Constructor

DragConstrained ( )

Properties

_regionCache - private Object

Store a cache of the region that we are constraining to

Methods

_align

private Array _align ( xy )
Override of Drag _align to account for region checking and tick checking
Parameters:
xy <Array> The XY to check for ticks and region
Returns: Array
The modified XY coords.

_cacheRegion

private void _cacheRegion ( )
Get's the region and caches it, called from window.resize and when the cache is null
Returns: void

_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)

_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

_checkRegion

private Array _checkRegion ( _xy )
Parameters:
_xy <Array> The XY to check if it's in the current region, if it isn't inside the region, it will reset the xy array to be inside the region.
Returns: Array
The new XY that is inside the region

_checkTicks

private Array _checkTicks ( xy , r )
This method delegates the proper helper method for tick calculations
Parameters:
xy <Array> The XY coords for the Drag
r <Object> The optional region that we are bound to.
Returns: Array
The calced XY coords

getRegion

Object getRegion ( inc )
Get the active region: viewport, node, custom region
Parameters:
inc <Boolean> Include the node's height and width
Returns: Object

inRegion

Boolean inRegion ( xy )
Checks if the XY passed or the dragNode is inside the active region.
Parameters:
xy <Array> Optional XY to check, if not supplied this.get('dragNode').getXY() is used.
Returns: Boolean
True if the XY is inside the region, false otherwise.

Events

constrain2nodeChange

constrain2nodeChange ( event )
Fires when the value for the configuration attribute 'constrain2node' 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

constrain2regionChange

constrain2regionChange ( event )
Fires when the value for the configuration attribute 'constrain2region' 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

constrain2viewChange

constrain2viewChange ( event )
Fires when the value for the configuration attribute 'constrain2view' 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

gutterChange

gutterChange ( event )
Fires when the value for the configuration attribute 'gutter' 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

stickXChange

stickXChange ( event )
Fires when the value for the configuration attribute 'stickX' 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

stickYChange

stickYChange ( event )
Fires when the value for the configuration attribute 'stickY' 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

tickXArrayChange

tickXArrayChange ( event )
Fires when the value for the configuration attribute 'tickXArray' 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

tickXChange

tickXChange ( event )
Fires when the value for the configuration attribute 'tickX' 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

tickYArrayChange

tickYArrayChange ( event )
Fires when the value for the configuration attribute 'tickYArray' 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

tickYChange

tickYChange ( event )
Fires when the value for the configuration attribute 'tickY' 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

Configuration Attributes

constrain2node - Object

Will attempt to constrain the drag node to the bounderies of this node.

constrain2region - Object

An Object Literal containing a valid region (top, right, bottom, left) of page positions to constrain the drag node to.

constrain2view - Object

Will attempt to constrain the drag node to the bounderies of the viewport region.

gutter - String

CSS style string for the gutter of a region (supports negative values): '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)

stickX - Boolean

Stick the drag movement to the X-Axis. Default: false

stickY - Boolean

Stick the drag movement to the Y-Axis

tickX - Number/false

The X tick offset the drag node should snap to on each drag move. False for no ticks. Default: false

tickXArray - Array

An array of page coordinates to use as X ticks for drag movement.

tickY - Number/false

The Y tick offset the drag node should snap to on each drag move. False for no ticks. Default: false

tickYArray - Array

An array of page coordinates to use as Y ticks for drag movement.

Configuration attributes inherited from Base:


Copyright © 2008 Yahoo! Inc. All rights reserved.