Last active
December 18, 2015 10:40
-
-
Save yratof/70cf499045f819a0be4e to your computer and use it in GitHub Desktop.
`Menu Aim` – Being forgiving when a user interacts with a large menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dependent on Menu-Aim.js in libs this function allows users to be sloppy | |
// with their navigation. This means they're allowed to hover over other | |
// items unintentionally and not be punished for it. | |
$( function(){ | |
var menu = $( ".nav-menu-primary" ); | |
menu.menuAim( { | |
submenuDirection: "below", | |
tolerance: 1, | |
// When the menu is entered | |
enter: function( a ) { | |
$( '.submenu-previously-visible' ).addClass( "submenu-visible" ); | |
}, | |
// When user moved to a parent item | |
activate: function( a ) { | |
$( a ).addClass( "submenu-visible" ); | |
$( '.submenu-previously-visible' ).removeClass( 'submenu-previously-visible' ); | |
}, | |
// When user moved to another parent item | |
deactivate: function( a ) { | |
$( a ).removeClass( "submenu-visible" ); | |
$( '.submenu-previously-visible' ).removeClass( 'submenu-previously-visible' ); | |
}, | |
// When user leaves the menu entirely | |
exitMenu: function( a ) { | |
$( ".submenu-visible" ).addClass( 'submenu-previously-visible' ).removeClass( "submenu-visible" ); | |
}, | |
} ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment