@@ -28,8 +28,18 @@ 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
var opts = { } ;
32
37
38
+ // directive specific options
39
+ var directiveOpts = {
40
+ 'ui-floating' : undefined
41
+ } ;
42
+
33
43
var callbacks = {
34
44
receive : null ,
35
45
remove :null ,
@@ -42,7 +52,7 @@ angular.module('ui.sortable', [])
42
52
helper : null
43
53
} ;
44
54
45
- angular . extend ( opts , uiSortableConfig , scope . $eval ( attrs . uiSortable ) ) ;
55
+ angular . extend ( opts , directiveOpts , uiSortableConfig , scope . $eval ( attrs . uiSortable ) ) ;
46
56
47
57
if ( ! angular . element . fn || ! angular . element . fn . jquery ) {
48
58
$log . error ( 'ui.sortable: jQuery should be included before AngularJS!' ) ;
@@ -65,6 +75,13 @@ angular.module('ui.sortable', [])
65
75
} ) ;
66
76
67
77
callbacks . start = function ( e , ui ) {
78
+ if ( opts [ 'ui-floating' ] === 'auto' ) {
79
+ // since the drag has started, the element will be
80
+ // absolutely positioned, so we check its siblings
81
+ var siblings = ui . item . siblings ( ) ;
82
+ angular . element ( e . target ) . data ( 'ui-sortable' ) . floating = isFloating ( siblings ) ;
83
+ }
84
+
68
85
// Save the starting position of dragged item
69
86
ui . item . sortable = {
70
87
index : ui . item . index ( ) ,
@@ -228,7 +245,18 @@ angular.module('ui.sortable', [])
228
245
// is still bound to the directive's element
229
246
if ( ! ! element . data ( 'ui-sortable' ) ) {
230
247
angular . forEach ( newVal , function ( value , key ) {
231
- if ( callbacks [ key ] ) {
248
+ // if it's a custom option of the directive,
249
+ // handle it approprietly
250
+ if ( key in directiveOpts ) {
251
+ if ( key === 'ui-floating' && ( value === false || value === true ) ) {
252
+ element . data ( 'ui-sortable' ) . floating = value ;
253
+ }
254
+
255
+ opts [ key ] = value ;
256
+ return ;
257
+ }
258
+
259
+ if ( callbacks [ key ] ) {
232
260
if ( key === 'stop' ) {
233
261
// call apply after stop
234
262
value = combineCallbacks (
0 commit comments