Droppable: Fix bubbling of greedy droppables

- Remove code that made the false assumption that if dragging an element
  out of the greedy child, it is always over the parent. This is not
  always true, as the child could be right on the parents border, or
  even pushed (partially) outside of the parent.

- This commit includes the fixes of maimairel, the original author of
  #9389 from his fiddle http://jsfiddle.net/fvjF4/

Fixes: #9389
This commit is contained in:
Dominik Ritter 2016-11-16 10:35:47 +01:00 committed by Dominik Ritter
parent d85c68f6cd
commit 5afe345954

View File

@ -420,7 +420,9 @@ $.ui.ddmanager = {
if ( parent.length ) { if ( parent.length ) {
parentInstance = $( parent[ 0 ] ).droppable( "instance" ); parentInstance = $( parent[ 0 ] ).droppable( "instance" );
parentInstance.greedyChild = ( c === "isover" ); parentInstance.greedyChild =
( typeof parentInstance.movedIntoGreedyChildInthisLoop !== "undefined" ) ||
( c === "isover" );
} }
} }
@ -428,18 +430,18 @@ $.ui.ddmanager = {
if ( parentInstance && c === "isover" ) { if ( parentInstance && c === "isover" ) {
parentInstance.isover = false; parentInstance.isover = false;
parentInstance.isout = true; parentInstance.isout = true;
parentInstance.movedIntoGreedyChildInthisLoop = true;
parentInstance._out.call( parentInstance, event ); parentInstance._out.call( parentInstance, event );
} }
this[ c ] = true; this[ c ] = true;
this[ c === "isout" ? "isover" : "isout" ] = false; this[ c === "isout" ? "isover" : "isout" ] = false;
this[ c === "isover" ? "_over" : "_out" ].call( this, event ); this[ c === "isover" ? "_over" : "_out" ].call( this, event );
} );
// We just moved out of a greedy child $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
if ( parentInstance && c === "isout" ) { if ( typeof this.movedIntoGreedyChildInthisLoop !== "undefined" ) {
parentInstance.isout = false; delete this.movedIntoGreedyChildInthisLoop;
parentInstance.isover = true;
parentInstance._over.call( parentInstance, event );
} }
} ); } );