Skip to content

Commit 12f73d6

Browse files
committed
Merge pull request #352 from kborchers/bug_5003_3
Droppable: Added dragStart and dragStop to ddmanager and call them from draggable to recalculate droppable positions after a drag causes a scroll. Fixes #5003 - Scroll on Droppable Demo Breaks Demo
2 parents 8a972f5 + 67bd872 commit 12f73d6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ui/jquery.ui.draggable.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ $.widget("ui.draggable", $.ui.mouse, {
163163

164164
this.helper.addClass("ui-draggable-dragging");
165165
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
166+
167+
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
168+
if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
169+
166170
return true;
167171
},
168172

@@ -229,6 +233,9 @@ $.widget("ui.draggable", $.ui.mouse, {
229233
}); //Remove frame helpers
230234
}
231235

236+
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
237+
if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
238+
232239
return $.ui.mouse.prototype._mouseUp.call(this, event);
233240
},
234241

ui/jquery.ui.droppable.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ $.ui.ddmanager = {
238238
return dropped;
239239

240240
},
241+
dragStart: function( draggable, event ) {
242+
//Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
243+
draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
244+
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
245+
});
246+
},
241247
drag: function(draggable, event) {
242248

243249
//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 = {
279285
}
280286
});
281287

288+
},
289+
dragStop: function( draggable, event ) {
290+
draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
291+
//Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
292+
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
282293
}
283294
};
284295

0 commit comments

Comments
 (0)