Skip to content

Commit

Permalink
fixes drop comment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed May 29, 2012
1 parent 3707e04 commit a86f963
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 26 deletions.
59 changes: 39 additions & 20 deletions event/drag/drag.js
Expand Up @@ -567,51 +567,67 @@ steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', function( $
}
}
});

/**
* @add jQuery.event.drag
* @add jQuery.event.special
*/
event.setupHelper([
/**
* @attribute dragdown
*
* @parent jQuery.event.drag
*
* `dragdown` is called when a drag movement has started on a mousedown.
* The event handler gets an instance of [jQuery.Drag] passed as the second
* parameter.
* If you listen to this, the mousedown's default event (preventing
* text selection) is not prevented. You are responsible for calling it
* parameter. Listening to `dragdown` allows you to customize
* the behavior of a drag motion, especially when `draginit` should be called.
*
* $(".handles").delegate("dragdown", function(ev, drag){
* // call draginit only when the mouse has moved 20 px
* drag.distance(20);
* })
*
* Typically, when a drag motion is started, `event.preventDefault` is automatically
* called, preventing text selection. However, if you listen to
* `dragdown`, this default behavior is not called. You are responsible for calling it
* if you want it (you probably do).
*
* ## Why might you not want it?
* ### Why might you not want to call `preventDefault`?
*
* You might want it if you want to allow text selection on element
* within the drag element. Typically these are input elements.
*
* $(".handles").delegate("dragdown", function(ev, drag){})
* $(".handles").delegate("dragdown", function(ev, drag){
* if(ev.target.nodeName === "input"){
* drag.cancel();
* } else {
* ev.preventDefault();
* }
* })
*/
'dragdown',
/**
* @attribute draginit
* @parent jQuery.event.drag
*
* `draginit` is triggered when the drag motion starts. Use it to customize the drag behavior
* using the [jQuery.Drag] instance passed as the second parameter:
*
* $(".draggable").on('draginit', function(ev, drag) {
* // Only allow vertical drags
* drag.vertical();
* // Create a draggable copy of the element
* drag.ghost();
* });
* $(".draggable").on('draginit', function(ev, drag) {
* // Only allow vertical drags
* drag.vertical();
* // Create a draggable copy of the element
* drag.ghost();
* });
*/
'draginit',
/**
* @attribute dragover
* @parent jQuery.event.drag
*
* `dragover` is triggered when a drag is over a [jQuery.event.drop drop element].
* The event handler gets an instance of [jQuery.Drag] passed as the second
* parameter.
* parameter and an instance of [jQuery.Drop] passed as the third argument:
*
* $('.draggable').on('dragover', function(ev, drag) {
* $('.draggable').on('dragover', function(ev, drag, drop) {
* // Add the drop-here class indicating that the drag
* // can be dropped here
* drag.element.addClass('drop-here');
Expand All @@ -620,11 +636,12 @@ steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', function( $
'dragover',
/**
* @attribute dragmove
* @parent jQuery.event.drag
*
* `dragmove` is triggered when the drag element moves (similar to a mousemove).
* The event handler gets an instance of [jQuery.Drag] passed as the second
* parameter.
* Use [jQuery.Drag.prototype.location] to determine the current position
* Use [jQuery.Drag::location] to determine the current position
* as a [jQuery.Vector vector].
*
* For example, `dragmove` can be used to create a draggable element to resize
Expand All @@ -638,6 +655,7 @@ steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', function( $
'dragmove',
/**
* @attribute dragout
* @parent jQuery.event.drag
*
* `dragout` is called when the drag leaves a drop point.
* The event handler gets an instance of [jQuery.Drag] passed as the second
Expand All @@ -653,14 +671,15 @@ steal('jquery/event', 'jquery/lang/vector', 'jquery/event/livehack', function( $
'dragout',
/**
* @attribute dragend
* @parent jQuery.event.drag
*
* `dragend` is called when the drag motion is done.
* The event handler gets an instance of [jQuery.Drag] passed as the second
* parameter.
*
* $('.draggable').on('dragend', function(ev, drag)
* // Clean up when the drag motion is done
* });
* $('.draggable').on('dragend', function(ev, drag)
* // Clean up when the drag motion is done
* });
*/
'dragend'], "mousedown", function( e ) {
$.Drag.mousedown.call($.Drag, e, this);
Expand Down
14 changes: 9 additions & 5 deletions event/drag/step/step.html
Expand Up @@ -44,9 +44,11 @@
<div id='handle4' class='handle'>horizontal vertical</div>
</div>
</div>
<script type='text/javascript'
src='../../../../steal/steal.js?jquery/event/drag/step'
id='demo-source'>
<script type='text/javascript' src='../../../../steal/steal.js'></script>
<script type='text/javascript' id='demo-source'>

steal('jquery/event/drag/step', function(){

$("#ondoc")
.delegate('#handle',"draginit", function(ev, drag){
drag.step(40,$("#ondoc"))
Expand All @@ -55,11 +57,13 @@
drag.step(40,$("#ondoc"),"x")
})
.delegate('#handle3',"draginit", function(ev, drag){
drag.step(40,$("#ondoc"),"y")
drag.step({y: 40},$("#ondoc"),"y")
})
.delegate('#handle4',"draginit", function(ev, drag){
drag.step(40,$("#ondoc"),"xy")
});
});

})
</script>


Expand Down
7 changes: 6 additions & 1 deletion event/drag/step/step.js
Expand Up @@ -20,7 +20,12 @@ steal('jquery/event/drag', 'jquery/dom/styles').then(function( $ ) {
*
* @demo jquery/event/drag/step/step.html
*
* @param {number|Object} amount make the drag move X amount in pixels from the top-left of container.
* @param {number|Object} amount make the drag move the amount in pixels from the top-left of container.
*
* If the amount is a `number`, the drag will move step-wise that number pixels in both
* dimensions. If it's an object like `{x: 20, y: 10}` the drag will move in steps 20px from
* left to right and 10px up and down.
*
* @param {jQuery} [container] the container to move in reference to. If not provided, the document is used.
* @param {String} [center] Indicates how to position the drag element in relationship to the container.
*
Expand Down

0 comments on commit a86f963

Please sign in to comment.