aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js49
1 files changed, 47 insertions, 2 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 24a033fc2..9a520f845 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -183,6 +183,12 @@ $.fn.position = function( options ) {
position.left += myOffset[ 0 ];
position.top += myOffset[ 1 ];
+ // if the browser doesn't support fractions, then round for consistent results
+ if ( !$.support.offsetFractions ) {
+ position.left = Math.round( position.left );
+ position.top = Math.round( position.top );
+ }
+
collisionPosition = {
marginLeft: marginLeft,
marginTop: marginTop
@@ -376,7 +382,7 @@ $.ui.position = {
newOverBottom;
if ( overTop < 0 ) {
newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
- if ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) {
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) {
data.elem
.addClass( "ui-flipped-bottom" );
@@ -385,7 +391,7 @@ $.ui.position = {
}
else if ( overBottom > 0 ) {
newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset;
- if ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) {
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) {
data.elem
.addClass( "ui-flipped-top" );
@@ -406,6 +412,45 @@ $.ui.position = {
}
};
+// fraction support test
+(function () {
+ var testElement, testElementParent, testElementStyle, offsetLeft, i
+ body = document.getElementsByTagName( "body" )[ 0 ],
+ div = document.createElement( "div" );
+
+ //Create a "fake body" for testing based on method used in jQuery.support
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
+ visibility: "hidden",
+ width: 0,
+ height: 0,
+ border: 0,
+ margin: 0,
+ background: "none"
+ };
+ if ( body ) {
+ jQuery.extend( testElementStyle, {
+ position: "absolute",
+ left: "-1000px",
+ top: "-1000px"
+ });
+ }
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || document.documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
+
+ div.style.cssText = "position: absolute; left: 10.7432222px;";
+
+ offsetLeft = $( div ).offset().left;
+ $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
+
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
+})();
+
// DEPRECATED
if ( $.uiBackCompat !== false ) {
// offset option