Skip to content

Commit 9d5d6aa

Browse files
committed
Update README.md
1 parent 45088fa commit 9d5d6aa

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

README.md

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,52 @@ menu-aim is a jQuery plugin for dropdown menus that can differentiate
55
between a user trying hover over a dropdown item vs trying to navigate into
66
a submenu's contents.
77

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

12-
__________________________
13-
| Monkeys >| Gorilla |
14-
| Gorillas >| Content |
15-
| Chimps >| Here |
16-
|___________|____________|
17-
18-
In the above example, "Gorillas" is selected and its submenu content is
19-
being shown on the right. Imagine that the user's cursor is hovering over
20-
"Gorillas." When they move their mouse into the "Gorilla Content" area, they
21-
may briefly hover over "Chimps." This shouldn't close the "Gorilla Content"
22-
area.
12+
![Amazon screenshot](https://raw.github.com/kamens/jQuery-menu-aim/master/amazon.png)
2313

2414
This problem is normally solved using timeouts and delays. menu-aim tries to
2515
solve this by detecting the direction of the user's mouse movement. This can
2616
make for quicker transitions when navigating up and down the menu. The
2717
experience is hopefully similar to amazon.com/'s "Shop by Department"
2818
dropdown.
19+
20+
Use like so:
21+
22+
$("#menu").menuAim({
23+
activate: $.noop, // fired on row activation
24+
deactivate: $.noop, // fired on row deactivation
25+
});
26+
27+
...to receive events when a menu's row has been purposefully (de)activated.
28+
29+
The following options can be passed to menuAim. All functions execute with
30+
the relevant row's HTML element as the execution context ('this'):
31+
32+
.menuAim({
33+
// Function to call when a row is purposefully activated. Use this
34+
// to show a submenu's content for the activated row.
35+
activate: function() {},
36+
37+
// Function to call when a row is deactivated.
38+
deactivate: function() {},
39+
40+
// Function to call when mouse enters a menu row. Entering a row
41+
// does not mean the row has been activated, as the user may be
42+
// mousing over to a submenu.
43+
enter: function() {},
44+
45+
// Function to call when mouse exits a menu row.
46+
exit: function() {},
47+
48+
// Selector for identifying which elements in the menu are rows
49+
// that can trigger the above events. Defaults to "> li".
50+
rowSelector: "> li",
51+
52+
// You may have some menu rows that aren't submenus and therefore
53+
// shouldn't ever need to "activate." If so, filter submenu rows w/
54+
// this selector. Defaults to "*" (all elements).
55+
submenuSelector: "*"
56+
});

0 commit comments

Comments
 (0)