Permalink
Browse files

Merge branch 'master' into selectmenu

  • Loading branch information...
2 parents a53916b + cf1470d commit 672218bfecacba0d7ed7b1120de07130756f65fb @kborchers kborchers committed Dec 15, 2011
Showing with 15 additions and 0 deletions.
  1. +15 −0 ui/jquery.ui.menu.js
View
@@ -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" )

1 comment on commit 672218b

Owner

kborchers commented on 672218b Dec 15, 2011

@fnagel OK, try this now. Sorry about that.

Please sign in to comment.