@@ -28,12 +28,22 @@ angular.module('ui.sortable', [])
28
28
return helperOption === 'clone' || ( typeof helperOption === 'function' && ui . item . sortable . isCustomHelperUsed ( ) ) ;
29
29
}
30
30
31
+ // thanks jquery-ui
32
+ function isFloating ( item ) {
33
+ 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' ) ) ;
34
+ }
35
+
31
36
function afterStop ( e , ui ) {
32
37
ui . item . sortable . _destroy ( ) ;
33
38
}
34
39
35
40
var opts = { } ;
36
41
42
+ // directive specific options
43
+ var directiveOpts = {
44
+ 'ui-floating' : undefined
45
+ } ;
46
+
37
47
var callbacks = {
38
48
receive : null ,
39
49
remove :null ,
@@ -46,7 +56,7 @@ angular.module('ui.sortable', [])
46
56
helper : null
47
57
} ;
48
58
49
- angular . extend ( opts , uiSortableConfig , scope . $eval ( attrs . uiSortable ) ) ;
59
+ angular . extend ( opts , directiveOpts , uiSortableConfig , scope . $eval ( attrs . uiSortable ) ) ;
50
60
51
61
if ( ! angular . element . fn || ! angular . element . fn . jquery ) {
52
62
$log . error ( 'ui.sortable: jQuery should be included before AngularJS!' ) ;
@@ -69,6 +79,13 @@ angular.module('ui.sortable', [])
69
79
} ) ;
70
80
71
81
callbacks . start = function ( e , ui ) {
82
+ if ( opts [ 'ui-floating' ] === 'auto' ) {
83
+ // since the drag has started, the element will be
84
+ // absolutely positioned, so we check its siblings
85
+ var siblings = ui . item . siblings ( ) ;
86
+ angular . element ( e . target ) . data ( 'ui-sortable' ) . floating = isFloating ( siblings ) ;
87
+ }
88
+
72
89
// Save the starting position of dragged item
73
90
ui . item . sortable = {
74
91
index : ui . item . index ( ) ,
@@ -240,7 +257,18 @@ angular.module('ui.sortable', [])
240
257
// is still bound to the directive's element
241
258
if ( ! ! element . data ( 'ui-sortable' ) ) {
242
259
angular . forEach ( newVal , function ( value , key ) {
243
- if ( callbacks [ key ] ) {
260
+ // if it's a custom option of the directive,
261
+ // handle it approprietly
262
+ if ( key in directiveOpts ) {
263
+ if ( key === 'ui-floating' && ( value === false || value === true ) ) {
264
+ element . data ( 'ui-sortable' ) . floating = value ;
265
+ }
266
+
267
+ opts [ key ] = value ;
268
+ return ;
269
+ }
270
+
271
+ if ( callbacks [ key ] ) {
244
272
if ( key === 'stop' ) {
245
273
// call apply after stop
246
274
value = combineCallbacks (
0 commit comments