@@ -21,6 +21,10 @@ function isOverAxis( x, reference, size ) {
21
21
return ( x > reference ) && ( x < ( reference + size ) ) ;
22
22
}
23
23
24
+ function isFloating ( item ) {
25
+ return ( / l e f t | r i g h t / ) . test ( item . css ( "float" ) ) || ( / i n l i n e | t a b l e - c e l l / ) . test ( item . css ( "display" ) ) ;
26
+ }
27
+
24
28
$ . widget ( "ui.sortable" , $ . ui . mouse , {
25
29
version : "@VERSION" ,
26
30
widgetEventPrefix : "sort" ,
@@ -73,7 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, {
73
77
this . refresh ( ) ;
74
78
75
79
//Let's determine if the items are being displayed horizontally
76
- this . floating = this . items . length ? o . axis === "x" || ( / l e f t | r i g h t / ) . test ( this . items [ 0 ] . item . css ( "float" ) ) || ( / i n l i n e | t a b l e - c e l l / ) . test ( this . items [ 0 ] . item . css ( "display" ) ) : false ;
80
+ this . floating = this . items . length ? o . axis === "x" || isFloating ( this . items [ 0 ] . item ) : false ;
77
81
78
82
//Let's determine the parent's offset
79
83
this . offset = this . element . offset ( ) ;
@@ -799,7 +803,7 @@ $.widget("ui.sortable", $.ui.mouse, {
799
803
} ,
800
804
801
805
_contactContainers : function ( event ) {
802
- var i , j , dist , itemWithLeastDistance , posProperty , sizeProperty , base , cur , nearBottom ,
806
+ var i , j , dist , itemWithLeastDistance , posProperty , sizeProperty , base , cur , nearBottom , floating ,
803
807
innermostContainer = null ,
804
808
innermostIndex = null ;
805
809
@@ -845,8 +849,9 @@ $.widget("ui.sortable", $.ui.mouse, {
845
849
//When entering a new container, we will find the item with the least distance and append our item near it
846
850
dist = 10000 ;
847
851
itemWithLeastDistance = null ;
848
- posProperty = this . containers [ innermostIndex ] . floating ? "left" : "top" ;
849
- sizeProperty = this . containers [ innermostIndex ] . floating ? "width" : "height" ;
852
+ floating = innermostContainer . floating || isFloating ( this . currentItem ) ;
853
+ posProperty = floating ? "left" : "top" ;
854
+ sizeProperty = floating ? "width" : "height" ;
850
855
base = this . positionAbs [ posProperty ] + this . offset . click [ posProperty ] ;
851
856
for ( j = this . items . length - 1 ; j >= 0 ; j -- ) {
852
857
if ( ! $ . contains ( this . containers [ innermostIndex ] . element [ 0 ] , this . items [ j ] . item [ 0 ] ) ) {
@@ -855,6 +860,9 @@ $.widget("ui.sortable", $.ui.mouse, {
855
860
if ( this . items [ j ] . item [ 0 ] === this . currentItem [ 0 ] ) {
856
861
continue ;
857
862
}
863
+ if ( floating && ! isOverAxis ( this . positionAbs . top + this . offset . click . top , this . items [ j ] . top , this . items [ j ] . height ) ) {
864
+ continue ;
865
+ }
858
866
cur = this . items [ j ] . item . offset ( ) [ posProperty ] ;
859
867
nearBottom = false ;
860
868
if ( Math . abs ( cur - base ) > Math . abs ( cur + this . items [ j ] [ sizeProperty ] - base ) ) {
@@ -873,10 +881,14 @@ $.widget("ui.sortable", $.ui.mouse, {
873
881
return ;
874
882
}
875
883
876
- this . currentContainer = this . containers [ innermostIndex ] ;
884
+ if ( this . currentContainer === this . containers [ innermostIndex ] ) {
885
+ return ;
886
+ }
887
+
877
888
itemWithLeastDistance ? this . _rearrange ( event , itemWithLeastDistance , null , true ) : this . _rearrange ( event , null , this . containers [ innermostIndex ] . element , true ) ;
878
889
this . _trigger ( "change" , event , this . _uiHash ( ) ) ;
879
890
this . containers [ innermostIndex ] . _trigger ( "change" , event , this . _uiHash ( this ) ) ;
891
+ this . currentContainer = this . containers [ innermostIndex ] ;
880
892
881
893
//Update the placeholder
882
894
this . options . placeholder . update ( this . currentContainer , this . placeholder ) ;
0 commit comments