diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-13 15:12:37 +0200 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-04-13 15:12:37 +0200 |
commit | cb67eb535c0f695941235f402cc4b405f70bc022 (patch) | |
tree | cb4f502aeeee0ee7e637cf9c1eccc51b3343fe99 /ui/jquery.ui.position.js | |
parent | 7dcfae7da2242f807e053cd4bac8d0799c38c86f (diff) | |
download | jquery-ui-cb67eb535c0f695941235f402cc4b405f70bc022.tar.gz jquery-ui-cb67eb535c0f695941235f402cc4b405f70bc022.zip |
Position: Cache the scrollbarWidth calculation result
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r-- | ui/jquery.ui.position.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 9e7407d7b..31da2237b 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -16,10 +16,14 @@ var rhorizontal = /left|center|right/, roffset = /[\+\-]\d+%?/, rposition = /^\w+/, rpercent = /%$/, - _position = $.fn.position; + _position = $.fn.position, + cachedScrollbarWidth; $.position = { scrollbarWidth: function() { + if ( cachedScrollbarWidth !== undefined ) { + return cachedScrollbarWidth; + } var w1, w2, div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), innerDiv = div.children()[0]; @@ -36,7 +40,7 @@ $.position = { div.remove(); - return w1 - w2; + return (cachedScrollbarWidth = w1 - w2); }, getScrollInfo: function( within ) { var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ), |