diff options
author | kborchers <kris.borchers@gmail.com> | 2011-12-15 13:28:33 -0600 |
---|---|---|
committer | kborchers <kris.borchers@gmail.com> | 2011-12-15 13:28:33 -0600 |
commit | cf1470dcefb5952e463854fa58a942c0c717f4ff (patch) | |
tree | 59669ce13ed1d0a89e7bf33e2a1a648d4416a86c /ui/jquery.ui.menu.js | |
parent | a8d0e4c8043b42257c51a1d65cd07d1042538062 (diff) | |
download | jquery-ui-cf1470dcefb5952e463854fa58a942c0c717f4ff.tar.gz jquery-ui-cf1470dcefb5952e463854fa58a942c0c717f4ff.zip |
Menu: Replace accidentally removed scroll-handling code in focus
Diffstat (limited to 'ui/jquery.ui.menu.js')
-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" ) |