diff options
author | kborchers <kris.borchers@gmail.com> | 2011-12-15 13:32:02 -0600 |
---|---|---|
committer | kborchers <kris.borchers@gmail.com> | 2011-12-15 13:32:02 -0600 |
commit | 672218bfecacba0d7ed7b1120de07130756f65fb (patch) | |
tree | f30a678a81099a4c9bc390efd0e65fa87e14fd17 | |
parent | a53916b45427d1afa3507acbebb6f92a03bbcd84 (diff) | |
parent | cf1470dcefb5952e463854fa58a942c0c717f4ff (diff) | |
download | jquery-ui-672218bfecacba0d7ed7b1120de07130756f65fb.tar.gz jquery-ui-672218bfecacba0d7ed7b1120de07130756f65fb.zip |
Merge branch 'master' into selectmenu
-rw-r--r-- | ui/jquery.ui.menu.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 6e534b1ba..b73018a19 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -294,6 +294,21 @@ $.widget( "ui.menu", { focus: function( event, item ) { this.blur( event ); + if ( this._hasScroll() ) { + var borderTop = parseFloat( $.curCSS( this.activeMenu[0], "borderTopWidth", true ) ) || 0, + paddingTop = parseFloat( $.curCSS( this.activeMenu[0], "paddingTop", true ) ) || 0, + offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop, + scroll = this.activeMenu.scrollTop(), + elementHeight = this.activeMenu.height(), + itemHeight = item.height(); + + if ( offset < 0 ) { + this.activeMenu.scrollTop( scroll + offset ); + } else if ( offset + itemHeight > elementHeight ) { + this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight ); + } + } + this.active = item.first() .children( "a" ) .addClass( "ui-state-focus" ) |