aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.position.js
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-24 17:23:25 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2012-04-24 17:23:25 +0200
commit252352e12473034dc86917bc9c7c1f764e6f7eb4 (patch)
tree4783929caabe1a25abfd743622b9071221a21b26 /ui/jquery.ui.position.js
parent1a0f2e46593ec9e3fbca51175d342210a9996fba (diff)
downloadjquery-ui-252352e12473034dc86917bc9c7c1f764e6f7eb4.tar.gz
jquery-ui-252352e12473034dc86917bc9c7c1f764e6f7eb4.zip
Position: Fix scrollbar calculcation to correctly take overflow:scroll into account, along with unit tests
Diffstat (limited to 'ui/jquery.ui.position.js')
-rw-r--r--ui/jquery.ui.position.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index b8764f2bb..d4d09bee4 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -58,12 +58,13 @@ $.position = {
getScrollInfo: function( within ) {
var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
- scrollbarWidth = overflowX === "auto" || overflowX === "scroll" ? $.position.scrollbarWidth() : 0,
- scrollbarHeight = overflowY === "auto" || overflowY === "scroll" ? $.position.scrollbarWidth() : 0;
-
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
return {
- height: within.height < within.element[0].scrollHeight ? scrollbarHeight : 0,
- width: within.width < within.element[0].scrollWidth ? scrollbarWidth : 0
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
};
},
getWithinInfo: function( element ) {