31
31
}
32
32
} ( function ( $ ) {
33
33
34
+ transforms = {
35
+ 'webkitTransform' :'-webkit-transform' ,
36
+ 'OTransform' :'-o-transform' ,
37
+ 'msTransform' :'-ms-transform' ,
38
+ 'MozTransform' :'-moz-transform' ,
39
+ 'transform' :'transform'
40
+ } ;
41
+
42
+ function hasTransform ( transform ) {
43
+ var el = document . createElement ( 'p' ) ,
44
+ has3d ;
45
+
46
+ // Add it to the body to get the computed style
47
+ document . body . insertBefore ( el , null ) ;
48
+
49
+ for ( var t in transforms ) {
50
+ if ( transforms . hasOwnProperty ( t ) ) {
51
+ if ( el . style [ t ] !== undefined ) {
52
+ el . style [ t ] = transform ;
53
+ has3d = window . getComputedStyle ( el ) . getPropertyValue ( transforms [ t ] ) ;
54
+ }
55
+ }
56
+ }
57
+
58
+ document . body . removeChild ( el ) ;
59
+
60
+ return ( has3d !== undefined && has3d . length > 0 && has3d !== "none" ) ;
61
+ }
62
+
63
+ var has3d , hasTranslate ;
64
+ $ ( function ( ) {
65
+ has3d = hasTransform ( 'translate3d(1px,1px,1px)' ) ;
66
+ hasTranslate = hasTransform ( 'translate(1px,1px,1px)' ) ;
67
+ } ) ;
68
+
34
69
return $ . widget ( "ui.sortable" , $ . ui . mouse , {
35
- version : "@VERSION " ,
70
+ version : "1.11.3 " ,
36
71
widgetEventPrefix : "sort" ,
37
72
ready : false ,
38
73
options : {
@@ -83,12 +118,17 @@ return $.widget("ui.sortable", $.ui.mouse, {
83
118
} ,
84
119
85
120
_create : function ( ) {
121
+
122
+ var o = this . options ;
86
123
this . containerCache = { } ;
87
124
this . element . addClass ( "ui-sortable" ) ;
88
125
89
126
//Get the items
90
127
this . refresh ( ) ;
91
128
129
+ //Let's determine if the items are being displayed horizontally
130
+ this . floating = this . items . length ? o . axis === "x" || this . _isFloating ( this . items [ 0 ] . item ) : false ;
131
+
92
132
//Let's determine the parent's offset
93
133
this . offset = this . element . offset ( ) ;
94
134
@@ -223,6 +263,9 @@ return $.widget("ui.sortable", $.ui.mouse, {
223
263
relative : this . _getRelativeOffset ( ) //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
224
264
} ) ;
225
265
266
+ //Create the placeholder
267
+ this . _createPlaceholder ( ) ;
268
+
226
269
// Only after we got the offset, we can change the helper's position to absolute
227
270
// TODO: Still need to figure out a way to make relative sorting possible
228
271
this . helper . css ( "position" , "absolute" ) ;
@@ -233,6 +276,10 @@ return $.widget("ui.sortable", $.ui.mouse, {
233
276
this . originalPageX = event . pageX ;
234
277
this . originalPageY = event . pageY ;
235
278
279
+ // Set helper's initial position
280
+ this . helper [ 0 ] . style . left = this . originalPosition . left + "px" ;
281
+ this . helper [ 0 ] . style . top = this . originalPosition . top + "px" ;
282
+
236
283
//Adjust the mouse offset relative to the helper if "cursorAt" is supplied
237
284
( o . cursorAt && this . _adjustOffsetFromHelper ( o . cursorAt ) ) ;
238
285
@@ -244,9 +291,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
244
291
this . currentItem . hide ( ) ;
245
292
}
246
293
247
- //Create the placeholder
248
- this . _createPlaceholder ( ) ;
249
-
250
294
//Set a containment if given in the options
251
295
if ( o . containment ) {
252
296
this . _setContainment ( ) ;
@@ -368,11 +412,37 @@ return $.widget("ui.sortable", $.ui.mouse, {
368
412
this . positionAbs = this . _convertPositionTo ( "absolute" ) ;
369
413
370
414
//Set the helper position
371
- if ( ! this . options . axis || this . options . axis !== "y" ) {
372
- this . helper [ 0 ] . style . left = this . position . left + "px" ;
373
- }
374
- if ( ! this . options . axis || this . options . axis !== "x" ) {
375
- this . helper [ 0 ] . style . top = this . position . top + "px" ;
415
+ if ( has3d || hasTranslate ) {
416
+ var dx = this . position . left - this . originalPosition . left ;
417
+ var dy = this . position . top - this . originalPosition . top ;
418
+ var translate = has3d ? "translate3d(" : "translate(" ;
419
+
420
+ if ( ! this . options . axis || this . options . axis !== "y" ) {
421
+ translate += dx + "px," ;
422
+ } else {
423
+ translate += "0," ;
424
+ }
425
+
426
+ if ( ! this . options . axis || this . options . axis !== "x" ) {
427
+ translate += dy + "px" ;
428
+ } else {
429
+ translate += "0" ;
430
+ }
431
+
432
+ if ( has3d ) {
433
+ translate += ",0)" ;
434
+ }
435
+
436
+ for ( t in transforms ) {
437
+ this . helper [ 0 ] . style [ t ] = translate ;
438
+ }
439
+ } else {
440
+ if ( ! this . options . axis || this . options . axis !== "y" ) {
441
+ this . helper [ 0 ] . style . left = this . position . left + "px" ;
442
+ }
443
+ if ( ! this . options . axis || this . options . axis !== "x" ) {
444
+ this . helper [ 0 ] . style . top = this . position . top + "px" ;
445
+ }
376
446
}
377
447
378
448
//Rearrange
@@ -732,11 +802,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
732
802
733
803
refreshPositions : function ( fast ) {
734
804
735
- // Determine whether items are being displayed horizontally
736
- this . floating = this . items . length ?
737
- this . options . axis === "x" || this . _isFloating ( this . items [ 0 ] . item ) :
738
- false ;
739
-
740
805
//This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
741
806
if ( this . offsetParent && this . helper ) {
742
807
this . offset . parent = this . _getParentOffset ( ) ;
@@ -794,13 +859,12 @@ return $.widget("ui.sortable", $.ui.mouse, {
794
859
. addClass ( className || that . currentItem [ 0 ] . className + " ui-sortable-placeholder" )
795
860
. removeClass ( "ui-sortable-helper" ) ;
796
861
797
- if ( nodeName === "tbody" ) {
798
- that . _createTrPlaceholder (
799
- that . currentItem . find ( "tr" ) . eq ( 0 ) ,
800
- $ ( "<tr>" , that . document [ 0 ] ) . appendTo ( element )
801
- ) ;
802
- } else if ( nodeName === "tr" ) {
803
- that . _createTrPlaceholder ( that . currentItem , element ) ;
862
+ if ( nodeName === "tr" ) {
863
+ that . currentItem . children ( ) . each ( function ( ) {
864
+ $ ( "<td> </td>" , that . document [ 0 ] )
865
+ . attr ( "colspan" , $ ( this ) . attr ( "colspan" ) || 1 )
866
+ . appendTo ( element ) ;
867
+ } ) ;
804
868
} else if ( nodeName === "img" ) {
805
869
element . attr ( "src" , that . currentItem . attr ( "src" ) ) ;
806
870
}
@@ -837,16 +901,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
837
901
838
902
} ,
839
903
840
- _createTrPlaceholder : function ( sourceTr , targetTr ) {
841
- var that = this ;
842
-
843
- sourceTr . children ( ) . each ( function ( ) {
844
- $ ( "<td> </td>" , that . document [ 0 ] )
845
- . attr ( "colspan" , $ ( this ) . attr ( "colspan" ) || 1 )
846
- . appendTo ( targetTr ) ;
847
- } ) ;
848
- } ,
849
-
850
904
_contactContainers : function ( event ) {
851
905
var i , j , dist , itemWithLeastDistance , posProperty , sizeProperty , cur , nearBottom , floating , axis ,
852
906
innermostContainer = null ,
@@ -1198,7 +1252,6 @@ return $.widget("ui.sortable", $.ui.mouse, {
1198
1252
} ,
1199
1253
1200
1254
_clear : function ( event , noPropagation ) {
1201
-
1202
1255
this . reverting = false ;
1203
1256
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
1204
1257
// everything else normalized again
@@ -1213,6 +1266,10 @@ return $.widget("ui.sortable", $.ui.mouse, {
1213
1266
this . _noFinalSort = null ;
1214
1267
1215
1268
if ( this . helper [ 0 ] === this . currentItem [ 0 ] ) {
1269
+ for ( t in transforms ) {
1270
+ this . helper [ 0 ] . style [ t ] = '' ;
1271
+ }
1272
+
1216
1273
for ( i in this . _storedCSS ) {
1217
1274
if ( this . _storedCSS [ i ] === "auto" || this . _storedCSS [ i ] === "static" ) {
1218
1275
this . _storedCSS [ i ] = "" ;
0 commit comments