@@ -183,6 +183,12 @@ $.fn.position = function( options ) {
183
183
position . left += myOffset [ 0 ] ;
184
184
position . top += myOffset [ 1 ] ;
185
185
186
+ // if the browser doesn't support fractions, then round for consistent results
187
+ if ( ! $ . support . offsetFractions ) {
188
+ position . left = Math . round ( position . left ) ;
189
+ position . top = Math . round ( position . top ) ;
190
+ }
191
+
186
192
collisionPosition = {
187
193
marginLeft : marginLeft ,
188
194
marginTop : marginTop
@@ -406,6 +412,45 @@ $.ui.position = {
406
412
}
407
413
} ;
408
414
415
+ // fraction support test
416
+ ( function ( ) {
417
+ var testElement , testElementParent , testElementStyle , offsetLeft , i
418
+ body = document . getElementsByTagName ( "body" ) [ 0 ] ,
419
+ div = document . createElement ( "div" ) ;
420
+
421
+ //Create a "fake body" for testing based on method used in jQuery.support
422
+ testElement = document . createElement ( body ? "div" : "body" ) ;
423
+ testElementStyle = {
424
+ visibility : "hidden" ,
425
+ width : 0 ,
426
+ height : 0 ,
427
+ border : 0 ,
428
+ margin : 0 ,
429
+ background : "none"
430
+ } ;
431
+ if ( body ) {
432
+ jQuery . extend ( testElementStyle , {
433
+ position : "absolute" ,
434
+ left : "-1000px" ,
435
+ top : "-1000px"
436
+ } ) ;
437
+ }
438
+ for ( i in testElementStyle ) {
439
+ testElement . style [ i ] = testElementStyle [ i ] ;
440
+ }
441
+ testElement . appendChild ( div ) ;
442
+ testElementParent = body || document . documentElement ;
443
+ testElementParent . insertBefore ( testElement , testElementParent . firstChild ) ;
444
+
445
+ div . style . cssText = "position: absolute; left: 10.7432222px;" ;
446
+
447
+ offsetLeft = $ ( div ) . offset ( ) . left ;
448
+ $ . support . offsetFractions = offsetLeft > 10 && offsetLeft < 11 ;
449
+
450
+ testElement . innerHTML = "" ;
451
+ testElementParent . removeChild ( testElement ) ;
452
+ } ) ( ) ;
453
+
409
454
// DEPRECATED
410
455
if ( $ . uiBackCompat !== false ) {
411
456
// offset option
0 commit comments