Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Menu: Replace accidentally removed scroll-handling code in focus

  • Loading branch information...
commit cf1470dcefb5952e463854fa58a942c0c717f4ff 1 parent a8d0e4c
Kris Borchers kborchers authored
Showing with 15 additions and 0 deletions.
  1. +15 −0 ui/jquery.ui.menu.js
15 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" )
Please sign in to comment.
Something went wrong with that request. Please try again.