From 9a274c06756dabb2797997a27393cc7da4eed5f5 Mon Sep 17 00:00:00 2001 From: kborchers Date: Wed, 12 Oct 2011 13:01:19 -0500 Subject: Menu: Check if menu is scrolling to prevent inadvertent mouseover events from being fired on scroll --- ui/jquery.ui.menu.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'ui/jquery.ui.menu.js') diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 6d9db8879..944e47b7c 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -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; } }); -- cgit v1.2.3 From 3c258bfa3ceab51b7e4c847f1196bd64f6c40cee Mon Sep 17 00:00:00 2001 From: Hans Hillen Date: Wed, 19 Oct 2011 11:41:33 +0200 Subject: Rewrite popup/menu interaction to make popup managed by menu (adds trigger option to menu). Makes popup agnostic of menu and allows datepicker to use popup (soon). --- demos/menu/contextmenu.html | 12 ++-- demos/popup/popup-menu.html | 24 +++---- ui/jquery.ui.menu.js | 31 ++++++++- ui/jquery.ui.popup.js | 149 +++++++++++++++++++++++++++++++++----------- 4 files changed, 157 insertions(+), 59 deletions(-) (limited to 'ui/jquery.ui.menu.js') diff --git a/demos/menu/contextmenu.html b/demos/menu/contextmenu.html index e031c2c4c..961cdd450 100644 --- a/demos/menu/contextmenu.html +++ b/demos/menu/contextmenu.html @@ -14,17 +14,17 @@