Provides drag events as a special events to jQuery.
A jQuery.Drag instance is created on a drag and passed
as a parameter to the drag event callbacks. By calling
methods on the drag event, you can alter the drag's
behavior.
The drag plugin allows you to listen to the following events:
dragdown - the mouse cursor is pressed downdraginit - the drag motion is starteddragmove - the drag is moveddragend - the drag has endeddragover - the drag is over a drop pointdragout - the drag moved out of a drop pointJust by binding or delegating on one of these events, you make the element dragable. You can change the behavior of the drag by calling methods on the drag object passed to the callback.
Here's a quick example:
//makes the drag vertical
$(".drags").live("draginit", function(event, drag){
drag.vertical();
})
//gets the position of the drag and uses that to set the width
//of an element
$(".resize").live("dragmove",function(event, drag){
$(this).width(drag.position.left() - $(this).offset().left )
})
The drag object is passed after the event to drag event callback functions. By calling methods and changing the properties of the drag object, you can alter how the drag behaves.
The drag properties and methods:
cancel - stops the drag motion from happeningghost - copys the draggable and drags the cloned elementhorizontal - limits the scroll to horizontal movementlocation - where the drag should be on the screenmouseElementPosition - where the mouse should be on the dragonly - only have drags, no dropsrepresentative - move another element in place of this elementrevert - animate the drag back to its positionvertical - limit the drag to vertical movementlimit - limit the drag within an element (*limit plugin)scrolls - scroll scrollable areas when dragging near their boundries (*scroll plugin)Now lets see some examples:
new $.Drag() -> jquery.drag
{jquery.drag}