jQuery plugin to fire events when user's cursor aims at particular dropdown menu items. For making responsive mega dropdowns like Amazon's.

Related tags

Menu jQuery-menu-aim
Overview

jQuery-menu-aim

menu-aim is a jQuery plugin for dropdown menus that can differentiate between a user trying hover over a dropdown item vs trying to navigate into a submenu's contents.

Try a demo.

Amazon screenshot

This problem is normally solved using timeouts and delays. menu-aim tries to solve this by detecting the direction of the user's mouse movement. This can make for quicker transitions when navigating up and down the menu. The experience is hopefully similar to amazon.com/'s "Shop by Department" dropdown.

Use like so:

 $("#menu").menuAim({
     activate: $.noop,  // fired on row activation
     deactivate: $.noop  // fired on row deactivation
 });

...to receive events when a menu's row has been purposefully (de)activated.

The following options can be passed to menuAim. All functions execute with the relevant row's HTML element as the execution context ('this'):

 .menuAim({
     // Function to call when a row is purposefully activated. Use this
     // to show a submenu's content for the activated row.
     activate: function() {},

     // Function to call when a row is deactivated.
     deactivate: function() {},

     // Function to call when mouse enters a menu row. Entering a row
     // does not mean the row has been activated, as the user may be
     // mousing over to a submenu.
     enter: function() {},

     // Function to call when mouse exits a menu row.
     exit: function() {},

     // Function to call when mouse exits the entire menu. If this returns
     // true, the current row's deactivation event and callback function
     // will be fired. Otherwise, if this isn't supplied or it returns
     // false, the currently activated row will stay activated when the
     // mouse leaves the menu entirely.
     exitMenu: function() {},

     // Selector for identifying which elements in the menu are rows
     // that can trigger the above events. Defaults to "> li".
     rowSelector: "> li",

     // You may have some menu rows that aren't submenus and therefore
     // shouldn't ever need to "activate." If so, filter submenu rows w/
     // this selector. Defaults to "*" (all elements).
     submenuSelector: "*",

     // Direction the submenu opens relative to the main menu. This
     // controls which direction is "forgiving" as the user moves their
     // cursor from the main menu into the submenu. Can be one of "right",
     // "left", "above", or "below". Defaults to "right".
     submenuDirection: "right"
 });

menu-aim assumes that you are using a menu with submenus that expand to the menu's right. It will fire events when the user's mouse enters a new dropdown item and when that item is being intentionally hovered over.

Want an example to learn from?

Check out example/example.html -- it has a working dropdown for you to play with:

Example screenshot
Play with the above example full of fun monkey pictures by opening example/example.html after downloading the repo.

FAQ

  1. What's the license? MIT.
  2. Does it support horizontal menus or submenus that open to the left? Yup. Check out the submenuDirection option above.
  3. I work at a big company that requires a version number on this third party code before I can use it. Do you have a version number? Sure, current version: 1.1
  4. I'm not nearly bored enough. Got anything else? Read about this plugin's creation.
Comments
  • Can get sub menu below to work....

    Can get sub menu below to work....

    Hi, I'm trying to get the drop down to work that appears below the main menu; however when I move the mouse from the main menu to the sub menu it disappears. I've put it on a test page here...

    http://uk.monsoon.co.uk/view/content/ip-test

    I've tried changing the top position and integrating some of the other pull requests on here but nothing has worked as if yet so any thoughts or suggestions would be appreciated! Code is below and can also be viewed on the source code of the page...Many thanks in advance

    opened by jamierussell-50 12
  • Nested Menu with Menu-aim

    Nested Menu with Menu-aim

    I know there is a topic allready, but it is very old and no one replied. Has anyone of you successfully implemented a multi level navigation with menu aim? The example has only one level, and I have at least there to deal with, its for category browsing with many child and grandchild categories. But Nesting menuAim into itself does not seem to work out of the box.

    opened by m4w 4
  • Menu on the right

    Menu on the right

    Hi Developer,

    I'm facing a problem with this jquery plugin. It is made for menus which are on the left, but my menu in black menu is on the right. What things should I change to solve this problem?

    Thanks in advance,

    Carlos

    opened by carlosjeurissen 4
  • Does a non-jquery version exist?

    Does a non-jquery version exist?

    Thank you for your work on making this pattern possible. I'm currently working on a project where we can't use jQuery. Do you know if anybody has turned this into a plain JS/DOM script yet?

    opened by nilssolanki 2
  • Activating First Submenu

    Activating First Submenu

    Would anyone know how to activate the first submenu from the initial list item?

    For example using the current demo, when "Explore the Monkeys" is selected the "Patas" would open along with the submenu with the picture.

    Thank you.

    opened by AMDesign-1 2
  • Destroy function?

    Destroy function?

    I'm using the plugin on a responsive site, which uses a differently styled menu for the small screen view. I already have javascript in place to manage calling different functions depending on the viewport.

    How can I turn off menu-aim so that I can manage the two different menus? The issue I have is when I render the page at a large viewport size and then resize to a small screen view - the menu-aim behaviors continue to occur, and I basically just want to turn them off.

    opened by evanhuntley 2
  • Re-entering a menu after exit

    Re-entering a menu after exit

    Firstly, thanks for the great work !

    I'm currently having an issue; where once the 'exitMenu' option is called, the previous active item can no-longer be opened - until another row item is opened.

    Is there a way to fix this ? Or am I using exitMenu incorrectly?

    Thanks

    opened by djrees 2
  • submenu cannot be triggered again after clicking close it in the example

    submenu cannot be triggered again after clicking close it in the example

    If a menuitem is hovered, the submenu div will show up as expected, and clicking the area outside the menu, the submenu div will close, however when I hovered the same menuitem again, the submenu div didn't appear anymore unless I move to another menuitem and then move back.

        $(document).click(function() {
            // Simply hide the submenu on any click. Again, this is just a hacked
            // together menu/submenu structure to show the use of jQuery-menu-aim.
            $(".popover").css("display", "none");
        });
    

    Maybe it has to do with the code above. I guess the code doesn't deactivate the menu properly.

    opened by dentrite 2
  • Replace Zurb Foundation's

    Replace Zurb Foundation's

    In https://groups.google.com/group/foundation-framework-/browse_thread/thread/27ecd8c6312d3973 I ask the Foundation team if they want to adopt the Amazon technique.

    In the meanwhile - would you be interested in providing an example that uses this library as a replacement for Foundation's top bar navigation sub menus?

    opened by aslakhellesoy 2
  • enhancement if the submenu is not immediately adjacent to the menu (gap between both)

    enhancement if the submenu is not immediately adjacent to the menu (gap between both)

    If the submenu is not immediately adjacent to the menu, there may be several prev locations outside of the menu, so that prevLoc bounds check will return false, and another submenu may be activated. TO avoid this, we return DELAY as soon as current loc is outside menu. This has to be inserted just before the prevLoc bounds check

                if (!prevLoc) {
                    prevLoc = loc;
                }
    
               // start of new code to be inserted
                if (loc.x < offset.left || loc.x > lowerRight.x ||
                    loc.y < offset.top || loc.y > lowerRight.y) {
                    // If the mouse location is outside of the entire
                    // menu bounds, don't change activation.
                    return DELAY;
                }
               // end of inserted code 
    
                if (prevLoc.x < offset.left || prevLoc.x > lowerRight.x ||
                    prevLoc.y < offset.top || prevLoc.y > lowerRight.y) {
                    // If the previous mouse location was outside of the entire
                    // menu's bounds, immediately activate.
                    return 0;
                }
    
    opened by ffasbend 1
  • Improve performance by changing binding of mousemoveDocument to $menu

    Improve performance by changing binding of mousemoveDocument to $menu

    Was $(document).mousemove(mousemoveDocument); Which means that every mouse-move on the document would of trigger this callback... which would be very un-efficient (especially on medium to large pages with lots of DOM elements..

    So I suggest changing it to: $menu.mousemove(mousemoveDocument); (I tried and it still works!)

    Perhaps add the binding of mousemoveDocument as an option where the user can define a selector..

    opened by adardesign 1
  • Consider rewriting this plugin as a hook/component for react?

    Consider rewriting this plugin as a hook/component for react?

    Much time has passed since this plugin was created, but the problems it solves are just as relevant today.

    It would be great to take the logic/learnings from this plugin and expose it via a react hooks or components to be used in other projects without jquery.

    opened by NateRadebaugh 0
  • Navigating through keyboard

    Navigating through keyboard

    How to add an event for tab navigation.? How can I open the submenu on press of "Enter" or "Space" and how to close on "esc" click?

    opened by vargheseakhil 0
  • submenuSelector not working

    submenuSelector not working

    It seems that the submenuSelector is not working.

    If if you define a submenu selector as following in the example.html it will stop working:

    <!-- example.html: line 204 -->
    
    $menu.menuAim({
       activate: activateSubmenu,
       deactivate: deactivateSubmenu,
       submenuSelector: ".popover"
    });
    

    Or do I use the option submenuSelector in a wrong way?

    opened by supermueller 0
Tippyjs - Tooltip, popover, dropdown, and menu library

Tippy.js The complete tooltip, popover, dropdown, and menu solution for the web Demo and Documentation ➡️ View the latest demo & docs here Migration G

James N 10.5k Dec 28, 2022
A jQuery plugin that creates a paneled-style menu (like the type seen in the mobile versions of Facebook and Google, as well as in many native iPhone applications).

#jPanelMenu ###Version 1.4.1 jPanelMenu is a jQuery plugin for easily creating and managing off-canvas content. Check out the demo (and documentation)

Anthony Colangelo 927 Dec 14, 2022
Quick access menu for the GNOME panel with options that help ease the workflow for newcomers and power users alike.

Tofu Menu (formerly Fedora Menu) Quick access menu for the GNOME panel with options that help ease the workflow for newcomers and power users alike. S

null 19 Sep 26, 2022
A touch slideout navigation menu for your mobile web apps.

Slideout.js A touch slideout navigation menu for your mobile web apps. Features Dependency-free. Simple markup. Native scrolling. Easy customization.

Mango 8k Jan 3, 2023
:zap: A sliding swipe menu that works with touchSwipe library.

Slide and swipe menu A sliding menu that works with touchSwipe library. Online demo Visit plugin site. Appszoom also uses it! So cool! What's the diff

Joan Claret 138 Sep 27, 2022
An experimental inline-to-menu-link animation based on a concept by Matthew Hall.

Inline to Menu Link Animation An experimental inline-to-menu-link animation based on a concept by Matthew Hall. Article on Codrops Demo Installation I

Codrops 35 Dec 12, 2022
jQuery contextMenu plugin & polyfill

jQuery contextMenu plugin & polyfill $.contextMenu is a management facility for - you guessed it - context menus. It was designed for an application w

SWIS 2.2k Dec 29, 2022
MultiLevelPushMenu jQuery Plugin implementation

Multi-level-push-menu by Momcilo Dzunic This jQuery plugin is inspired by Codrops MultiLevelPushMenu but unlike it not relaying on CSS 3D Transforms a

Momcilo Dzunic 808 Dec 21, 2022
stickUp a jQuery Plugin for sticky navigation menus.

stickUp a jQuery plugin A simple plugin that "sticks" an element to the top of the browser window while scrolling past it, always keeping it in view.

null 1.6k Dec 31, 2022
Superfish is a jQuery plugin that adds usability enhancements to existing multi-level drop-down menus.

jQuery Superfish Dropdown Menu Plugin Our favourite aquatic superhero returns from his sojourn across the galaxy infused with astonishing, hitherto un

Joel Birch 917 Dec 9, 2022
Slidebars is a jQuery Framework for Off-Canvas Menus and Sidebars into your website or web app.

Slidebars Slidebars is a jQuery Framework for Off-Canvas Menus and Sidebars into your website or web app. Version 2.0 is a complete rewrite which feat

Adam Smith 1.5k Jan 2, 2023
The best javascript plugin for app look-alike on- and off-canvas menus with sliding submenus for your website and webapp.

mmenu.js The best javascript plugin for app look-alike on- and off-canvas menus with sliding submenus for your website and webapp. It is very customiz

Fred Heusschen 2.6k Dec 27, 2022
The best javascript plugin for app look-alike on- and off-canvas menus with sliding submenus for your website and webapp.

mmenu.js The best javascript plugin for app look-alike on- and off-canvas menus with sliding submenus for your website and webapp. It is very customiz

Fred Heusschen 2.6k Dec 27, 2022
:fire::fire::fire: 强大的动态表单生成器|form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions through JSON.

form-create form-create is a form generation component that can generate dynamic rendering, data collection, verification and submission functions thr

xaboy 4.6k Jan 3, 2023
discord selected menu , discord selection menu , discord selec menu , discord select menu

Selected menu ihtiyacı olan arkadaşlar için paylaştım. Kodlar bana ait değildir githubdan bulduğum bir yerden alıp düzenledim. İşinize yarar örnek ekr

Wapper. 4 Jan 24, 2022
jSide Menu is a well designed, simple and clean side navigation menu with dropdowns.

jQuery jSide Menu jSide Menu is a well designed, simple and clean side navigation menu with dropdowns. Browse: Live Demo & Using Guide Main Features F

CodeHim 24 Feb 14, 2022
Vue-cursor-fx - 🖱 An animated custom cursor effects for interactive elements like navigation - w/ VueJS - SSR Compatible

?? Vue Cursor Fx An animated custom cursor effects for interactive elements like navigation - w/ VueJS - SSR Compatible Installation This package is a

Luca Iaconelli 56 Aug 18, 2022
VanillaSelectBox - A dropdown menu with lots of features that takes a select tag and transforms it into a single or multi-select menu with 1 or 2 levels

vanillaSelectBox v1.0.0 vanillaSelectBox : v1.00 : Adding a package.json file New : Possibility to change the dropdown tree and change the remote sear

philippe MEYER 103 Dec 16, 2022
This restaurant project is a SPA (single-page application) website. The user can navigate between the home, menu and contact page. I used the MealDB API to display some menu items.

Fresh Cuisine This restaurant project is from the Odin Project and it is a SPA (single-page application) website. The user can navigate between the ho

Virag Kormoczy 7 Nov 2, 2022
Replaces native cursor with custom animated cursor.

Animated Cursor A pure JS library to replace native cursor with a custom animated cursor. Check out the Demo Contents ?? Features ?? Quickstart ?? Opt

Stephen Scaff 7 Jul 18, 2022