aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 16:56:54 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 16:56:54 +0200
commit08c8aedf80f2084490b0dcda7315b94a6bc6edcd (patch)
tree8fde5e8d5cbf3102d5c5f6ac80f01664ce0ba9dd /ui/jquery.ui.position.js
parent0c5c2c7055e3b1585267606da98c428942232661 (diff)
downloadjquery-ui-08c8aedf80f2084490b0dcda7315b94a6bc6edcd.tar.gz
jquery-ui-08c8aedf80f2084490b0dcda7315b94a6bc6edcd.zip
Position: Refactor offset calculations
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js20
1 files changed, 8 insertions, 12 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index 9226909d5..a55556417 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -50,6 +50,12 @@ $.position = {
height: within.height() < within[0].scrollHeight ? scrollbarHeight : 0,
width: within.width() < within[0].scrollWidth ? scrollbarWidth : 0
};
+ },
+ getOffsets: function( offsets, width, height ) {
+ return [
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
}
};
@@ -142,12 +148,7 @@ $.fn.position = function( options ) {
basePosition.top += targetHeight / 2;
}
- atOffset = [
- parseInt( offsets.at[ 0 ], 10 ) *
- ( rpercent.test( offsets.at[ 0 ] ) ? targetWidth / 100 : 1 ),
- parseInt( offsets.at[ 1 ], 10 ) *
- ( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 )
- ];
+ atOffset = $.position.getOffsets( offsets.at, targetWidth, targetHeight );
basePosition.left += atOffset[ 0 ];
basePosition.top += atOffset[ 1 ];
@@ -163,12 +164,7 @@ $.fn.position = function( options ) {
collisionHeight = elemHeight + marginTop +
( parseInt( $.css( this, "marginBottom" ), 10 ) || 0 ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
- myOffset = [
- parseInt( offsets.my[ 0 ], 10 ) *
- ( rpercent.test( offsets.my[ 0 ] ) ? elem.outerWidth() / 100 : 1 ),
- parseInt( offsets.my[ 1 ], 10 ) *
- ( rpercent.test( offsets.my[ 1 ] ) ? elem.outerHeight() / 100 : 1 )
- ],
+ myOffset = $.position.getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() ),
collisionPosition,
using;