Skip to content

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 #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ui/jquery.ui.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down Expand Up @@ -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);
},

Expand Down
11 changes: 11 additions & 0 deletions ui/jquery.ui.droppable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 );
}
};

Expand Down