aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 17:14:03 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-12 17:14:03 +0200
commit2154ca552aa588c8bf5306707ffcddabd1b25820 (patch)
tree2f930209fcf54cef94cd854710adab2e377d7d3a /ui/jquery.ui.position.js
parent58d5452a7cc58b160035376d9a4a136a4444c0c6 (diff)
downloadjquery-ui-2154ca552aa588c8bf5306707ffcddabd1b25820.tar.gz
jquery-ui-2154ca552aa588c8bf5306707ffcddabd1b25820.zip
Position: Cache Math.abs and Math.max lookups
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index c87e1d105..c5c02aa1d 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -228,14 +228,16 @@ $.fn.position = function( options ) {
feedback = {
horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
- };
- if ( targetWidth < elemWidth && Math.abs( left + right ) < targetWidth ) {
+ },
+ max = Math.max,
+ abs = Math.abs;
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
feedback.horizontal = "center";
}
- if ( targetHeight < elemHeight && Math.abs( top + bottom ) < targetHeight ) {
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
feedback.vertical = "middle";
}
- if ( Math.max( Math.abs( left ), Math.abs( right ) ) > Math.max( Math.abs( top ), Math.abs( bottom ) ) ) {
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
feedback.important = "horizontal";
} else {
feedback.important = "vertical";