]> source.dussan.org Git - jquery-ui.git/commitdiff
Droppable: Added dragStart and dragStop to ddmanager and call them from draggable... 352/head
authorkborchers <k_borchers@yahoo.com>
Fri, 27 May 2011 17:01:42 +0000 (12:01 -0500)
committerkborchers <k_borchers@yahoo.com>
Fri, 27 May 2011 17:01:42 +0000 (12:01 -0500)
ui/jquery.ui.draggable.js
ui/jquery.ui.droppable.js

index c16833eb016ae24fa79425aedc4df56dc52a3be2..f8c187a7a1309948e608c9df3d1db07bd647db7b 100644 (file)
@@ -163,6 +163,10 @@ $.widget("ui.draggable", $.ui.mouse, {
 
                this.helper.addClass("ui-draggable-dragging");
                this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+               
+               //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
+               if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
+               
                return true;
        },
 
@@ -229,6 +233,9 @@ $.widget("ui.draggable", $.ui.mouse, {
                        }); //Remove frame helpers
                }
                
+               //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
+               if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
+               
                return $.ui.mouse.prototype._mouseUp.call(this, event);
        },
        
index b8a93cd460bfd5c750e064f649e96e9e27e97b38..58a1c4bc197f5d020220eb8be2ea973aab89a3f9 100644 (file)
@@ -238,6 +238,12 @@ $.ui.ddmanager = {
                return dropped;
 
        },
+       dragStart: function( draggable, event ) {
+               //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
+               draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
+                       if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
+               });
+       },
        drag: function(draggable, event) {
 
                //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
@@ -279,6 +285,11 @@ $.ui.ddmanager = {
                        }
                });
 
+       },
+       dragStop: function( draggable, event ) {
+               draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
+               //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
+               if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
        }
 };