diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-20 14:15:57 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-20 14:15:57 +0200 |
commit | 3b73177d0c5e131d4825080efbd203b2449b2f0f (patch) | |
tree | 18baa5a05743f0d50b6b5c00c2c8f34764175c8f | |
parent | cfa6aa328e21514c2eec928272d769f77bc62e56 (diff) | |
download | jquery-ui-3b73177d0c5e131d4825080efbd203b2449b2f0f.tar.gz jquery-ui-3b73177d0c5e131d4825080efbd203b2449b2f0f.zip |
Position: Also create a local reference for Math.round; update other Math references
-rw-r--r-- | ui/jquery.ui.position.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 5a2ede2b8..8f5601c28 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -14,6 +14,7 @@ $.ui = $.ui || {}; var cachedScrollbarWidth, max = Math.max, abs = Math.abs, + round = Math.round, rhorizontal = /left|center|right/, rvertical = /top|center|bottom/, roffset = /[\+\-]\d+%?/, @@ -199,8 +200,8 @@ $.fn.position = function( options ) { // 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 ); + position.left = round( position.left ); + position.top = round( position.top ); } collisionPosition = { @@ -312,7 +313,7 @@ $.ui.position = { position.left -= overRight; // adjust based on position and margin } else { - position.left = Math.max( position.left - collisionPosLeft, position.left ); + position.left = max( position.left - collisionPosLeft, position.left ); } }, top: function( position, data ) { @@ -350,7 +351,7 @@ $.ui.position = { position.top -= overBottom; // adjust based on position and margin } else { - position.top = Math.max( position.top - collisionPosTop, position.top ); + position.top = max( position.top - collisionPosTop, position.top ); } } }, @@ -382,13 +383,13 @@ $.ui.position = { if ( overLeft < 0 ) { newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset; - if ( newOverRight < 0 || newOverRight < Math.abs( overLeft ) ) { + if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) { position.left += myOffset + atOffset + offset; } } else if ( overRight > 0 ) { newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft; - if ( newOverLeft > 0 || Math.abs( newOverLeft ) < overRight ) { + if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) { position.left += myOffset + atOffset + offset; } } @@ -419,13 +420,13 @@ $.ui.position = { newOverBottom; if ( overTop < 0 ) { newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) { + if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) { position.top += myOffset + atOffset + offset; } } else if ( overBottom > 0 ) { newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop; - if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) { + if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) { position.top += myOffset + atOffset + offset; } } |