@@ -730,30 +730,31 @@ $.widget("ui.sortable", $.ui.mouse, {
730
730
if ( this . containers . length === 1 ) {
731
731
this . containers [ innermostIndex ] . _trigger ( "over" , event , this . _uiHash ( this ) ) ;
732
732
this . containers [ innermostIndex ] . containerCache . over = 1 ;
733
- } else if ( this . currentContainer != this . containers [ innermostIndex ] ) {
734
-
735
- //When entering a new container, we will find the item with the least distance and append our item near it
736
- var dist = 10000 ; var itemWithLeastDistance = null ; var base = this . positionAbs [ this . containers [ innermostIndex ] . floating ? 'left' : 'top' ] ;
737
- for ( var j = this . items . length - 1 ; j >= 0 ; j -- ) {
738
- if ( ! $ . ui . contains ( this . containers [ innermostIndex ] . element [ 0 ] , this . items [ j ] . item [ 0 ] ) ) continue ;
739
- var cur = this . items [ j ] [ this . containers [ innermostIndex ] . floating ? 'left' : 'top' ] ;
740
- if ( Math . abs ( cur - base ) < dist ) {
741
- dist = Math . abs ( cur - base ) ; itemWithLeastDistance = this . items [ j ] ;
742
- }
743
- }
744
-
745
- if ( ! itemWithLeastDistance && ! this . options . dropOnEmpty ) //Check if dropOnEmpty is enabled
746
- return ;
747
-
748
- this . currentContainer = this . containers [ innermostIndex ] ;
749
- itemWithLeastDistance ? this . _rearrange ( event , itemWithLeastDistance , null , true ) : this . _rearrange ( event , null , this . containers [ innermostIndex ] . element , true ) ;
750
- this . _trigger ( "change" , event , this . _uiHash ( ) ) ;
751
- this . containers [ innermostIndex ] . _trigger ( "change" , event , this . _uiHash ( this ) ) ;
752
-
753
- //Update the placeholder
754
- this . options . placeholder . update ( this . currentContainer , this . placeholder ) ;
755
-
756
- this . containers [ innermostIndex ] . _trigger ( "over" , event , this . _uiHash ( this ) ) ;
733
+ } else if ( this . currentContainer != this . containers [ innermostIndex ] ) {
734
+
735
+ //When entering a new container, we will find the item with the least distance and append our item near it
736
+ var dist = 10000 ; var itemWithLeastDistance = null ; var base = this . positionAbs [ this . containers [ innermostIndex ] . floating ? 'left' : 'top' ] ;
737
+ for ( var j = this . items . length - 1 ; j >= 0 ; j -- ) {
738
+ if ( ! $ . ui . contains ( this . containers [ innermostIndex ] . element [ 0 ] , this . items [ j ] . item [ 0 ] ) ) continue ;
739
+ var cur = this . containers [ innermostIndex ] . floating ? this . items [ j ] . item . offset ( ) . left : this . items [ j ] . item . offset ( ) . top ;
740
+ if ( Math . abs ( cur - base ) < dist ) {
741
+ dist = Math . abs ( cur - base ) ; itemWithLeastDistance = this . items [ j ] ;
742
+ this . direction = ( cur - base > 0 ) ? 'down' : 'up' ;
743
+ }
744
+ }
745
+
746
+ if ( ! itemWithLeastDistance && ! this . options . dropOnEmpty ) //Check if dropOnEmpty is enabled
747
+ return ;
748
+
749
+ this . currentContainer = this . containers [ innermostIndex ] ;
750
+ itemWithLeastDistance ? this . _rearrange ( event , itemWithLeastDistance , null , true ) : this . _rearrange ( event , null , this . containers [ innermostIndex ] . element , true ) ;
751
+ this . _trigger ( "change" , event , this . _uiHash ( ) ) ;
752
+ this . containers [ innermostIndex ] . _trigger ( "change" , event , this . _uiHash ( this ) ) ;
753
+
754
+ //Update the placeholder
755
+ this . options . placeholder . update ( this . currentContainer , this . placeholder ) ;
756
+
757
+ this . containers [ innermostIndex ] . _trigger ( "over" , event , this . _uiHash ( this ) ) ;
757
758
this . containers [ innermostIndex ] . containerCache . over = 1 ;
758
759
}
759
760
0 commit comments