]> source.dussan.org Git - jquery-ui.git/commitdiff
Menu: Check if menu is scrolling to prevent inadvertent mouseover events from being...
authorkborchers <k_borchers@yahoo.com>
Wed, 12 Oct 2011 18:01:19 +0000 (13:01 -0500)
committerkborchers <k_borchers@yahoo.com>
Wed, 12 Oct 2011 21:13:34 +0000 (16:13 -0500)
ui/jquery.ui.menu.js

index 6d9db8879d75c059b1751a6d112f19cb323bae6a..944e47b7cd8b18b703c7a614cabee2d31908f449 100644 (file)
@@ -28,6 +28,7 @@ $.widget( "ui.menu", {
        },
        _create: function() {
                this.activeMenu = this.element;
+               this.isScrolling = false;
                this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
                if ( this.element.find( ".ui-icon" ).length ) {
                        this.element.addClass( "ui-menu-icons" );
@@ -57,10 +58,13 @@ $.widget( "ui.menu", {
                        },
                        "mouseover .ui-menu-item": function( event ) {
                                event.stopImmediatePropagation();
-                               var target = $( event.currentTarget );
-                               // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
-                               target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
-                               this.focus( event, target );
+                               if ( !this.isScrolling ) {
+                                       var target = $( event.currentTarget );
+                                       // Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border
+                                       target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+                                       this.focus( event, target );
+                               }
+                               this.isScrolling = false;
                        },
                        "mouseleave": "collapseAll",
                        "mouseleave .ui-menu": "collapseAll",
@@ -74,6 +78,10 @@ $.widget( "ui.menu", {
                                                this.collapseAll( event );
                                        }
                                }, 0);
+                       },
+                       scroll: function( event ) {
+                               // Keep track of scrolling to prevent mouseover from firing inadvertently when scrolling the menu
+                               this.isScrolling = true;
                        }
                });