Class DD.DDM
- extends Base
Provides the base Drag Drop Manger required for making a Node draggable.
Properties
flag set when we activate our first drag, so DDM can start listening for events.
Placeholder for all active shims on the page
Set this to true to set the shims opacity to .5 for debugging it, default: false.
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.
A reference to the currently active draggable object.
A reference to the active Drop Target
The PREFIX to attach to all DD CSS class names
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
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
Should we only check targets that are in the viewport on drags (for performance), default: true
An array of the valid Drop Targets for this interaction.
Properties inherited from Base:
Methods
private
void
_activateTargets
(
)
Clear the cache and activate the shims of all the targets
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.
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.
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
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
private
void
_createFrame
(
)
Create the proxy element if it doesn't already exist and set the DD.DDM._proxy value
private
void
_createPG
(
)
Creates the shim and adds it's listeners to it.
private
void
_deactivateTargets
(
)
This method fires the drop:hit, drag:drophit, drag:dropmiss methods and deactivates the shims..
private
void
_dropMove
(
)
This method is called when the move method is called on the Drag Object.
private
void
_end
(
)
Internal method used by Drag to signal the end of a drag operation
private
void
_endDrag
(
)
Factory method to be overwritten by other DDM's
private
void
_handleTargetOver
(
)
This method execs _handleTargetOver on all valid Drop Targets
private
Boolean
_hasActiveShim
(
)
This method checks the _activeShims Object to see if there is a shim active.
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.
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
private
void
_pg_activate
(
)
Activates the shim
private
void
_pg_deactivate
(
)
Deactivates the shim
private
void
_pg_size
(
)
Sizes the shim on: activatation, window:scroll, window:resize
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
private
void
_regTarget
(
t
)
Add the passed in Target to the targets collection
- Parameters:
-
t
<Object>
The Target to add to the targets collection
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.
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.
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
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.
private
void
_setupListeners
(
)
Add the document listeners.
private
void
_start
(
)
Internal method used by Drag to signal the start of a drag operation
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
private
void
_unregDrag
(
d
)
Remove this drag object from the DDM._drags array.
- Parameters:
-
d
<Drag>
The drag object.
private
void
_unregTarget
(
drop
)
Remove the passed in Target from the targets collection
- Parameters:
-
drop
<Object>
The Target to remove from the targets collection
void
clearCache
(
)
Clears the cache data used for this interaction.
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.
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.
void
getDelegate
(
)
Get a delegate instance from a container node
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
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
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.
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
void
regDelegate
(
)
Register a Delegate with the DDM
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.
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
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
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,
_getAttrCfg,
_getAttrInitVal,
_getAttrs,
_getStateVal,
_isLazyAttr,
_normAttrVals,
_protectAttrs,
_set,
_setAttr,
_setAttrs,
_setAttrVal,
_setStateVal,
addAttr,
addAttrs,
attrAdded,
get,
getAttrs,
modifyAttr,
removeAttr,
reset,
set,
setAttrs
Methods inherited from Base:
_aggregateAttrs,
_defDestroyFn,
_defInitFn,
_destroyHierarchy,
_filterAttrCfs,
_getAttrCfgs,
_getClasses,
_initHierarchy,
_initHierarchyData,
_preInitEventCfg,
destroy,
init,
toString
Events
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
(
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
(
)
Fires from the DDM after the DDM finishes, before the drag end events.
ddm:start
(
)
Fires from the DDM before all drag events fire.
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
(
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
(
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:
Configuration Attributes
The number of pixels to move to start a drag operation, default is 3.
The number of milliseconds a mousedown has to pass to start a drag operation, default is 1000.
The cursor to apply when dragging, if shimmed the shim will get the cursor.
This attribute only works if the dd-drop module is active. It will set the dragMode (point, intersect, strict) of all future Drag instances.
The number of milliseconds to throttle the mousemove event. Default: 150
Configuration attributes inherited from Base: