Skip to content

Instantly share code, notes, and snippets.

@eddiemonge
Last active December 18, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eddiemonge/5702103 to your computer and use it in GitHub Desktop.
Save eddiemonge/5702103 to your computer and use it in GitHub Desktop.
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index 1c641eb..4d5dd3b 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -35,6 +35,7 @@ $.widget( "ui.menu", {
focus: null,
select: null
},
+ mousePosition: {},
_create: function() {
this.activeMenu = this.element;
@@ -98,10 +99,19 @@ $.widget( "ui.menu", {
// 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.mousePosition.x !== event.pageX || this.mousePosition.y !== event.pageY ) {
+ this.focus( event, target );
+ }
},
mouseleave: "collapseAll",
"mouseleave .ui-menu": "collapseAll",
+ mousemove: function( event ) {
+ this.mousePosition = {
+ x: event.pageX,
+ y: event.pageY
+ };
+ },
focus: function( event, keepActiveItem ) {
// If there's already an active item, keep it active
// If not, activate the first item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment