Menu aim
Menu aim
On its way from a category to its flyout, the pointer cuts diagonally and brushes against the neighboring categories. If hover opened them at once, the flyout would change under the person's hand, and the links would be out of reach. Menu aim watches where the pointer is heading: while it moves toward the open flyout, a neighboring category does not take over the hover.
- The direction of the pointer's last step is compared with the wedge from its previous position to the two corners of the flyout's near edge: Kamens's triangle from "Where it comes from". A step into the wedge means the pointer is aiming.
- One movement off course is forgiven; two in a row are not, and then the category under the pointer opens.
- If the pointer stops for 300 ms, the category under it opens even if it was aiming. The menu does not get stuck.
- When the pointer reaches the flyout, the deferred switch is canceled.
- Clicking a category opens it at once, bypassing menu aim. The keyboard knows nothing about menu aim.
- Mouse only, and only on a wide screen: touch and pen open a category at once, and a narrow screen has no menu aim at all.
- The first hover, while there is no flyout yet, opens the category with no delay at all: there is nothing to aim at.
The model is the same as for react-aria submenus (Menu with SubmenuTrigger), so that the two menus of the kit
behave alike. There are two differences. The category switch is deferred, not suppressed with pointer-events: none
on the category column, since that would lose the highlight under the pointer and the click on a neighboring category.
And the stop time is 300 ms, as in Kamens's plugin (more on it in "Where it comes from"), not a second, as in react-aria: its submenu is short, while the
category column of a catalog gets scrolled through.
Where it comes from
The technique comes from Amazon. By 2013 the "Shop by Department" menu on amazon.com already worked like this: a column of departments on the left, a large panel on the right, switching with no delay at all, and yet the pointer could cut diagonally toward the panel without knocking it away.
The trap that menus closed with a delay. If a submenu switches at once, the pointer brushes a neighboring item on its way there, the submenu changes, and the link you were heading for is gone: a game you can't win. Bootstrap's dropdowns behaved like this, for example. The usual fix is a delay before switching items, known as menu hysteresis, as in Khan Academy's own earlier menu. It closes the trap but makes the menu sluggish: every move between items waits for a timer.
What Ben Kamens noticed. The Khan Academy developer saw that Amazon's menu switches instantly and still doesn't lose the submenu, and worked out why. The menu watches direction, not time: at each pointer position it builds a triangle with corners at the pointer itself and at the top and bottom corners of the submenu. If the next position is inside the triangle, the user is heading for the submenu, and items brushed on the way don't take it over. Once the pointer leaves the triangle, the submenu switches immediately. Kamens published his analysis on 6 March 2013.

Animation from Ben Kamens's post, as reproduced in the Habr retelling.
The plugin and the math. Kamens turned the idea into a jQuery plugin, jQuery-menu-aim, and used it in Khan
Academy's new "Learn" menu. Whether a point lies inside a triangle can be checked with cross products, and Sophie
Alpert helped him with that bit of linear algebra, but in the plugin Kamens went with something simpler: comparing
the slopes of lines. A pointer that entered the triangle and stopped still opens the item under it, after 300 ms.
Kamens was happy to admit he had copied Amazon, and suspected the problem had been solved and forgotten many times
before.
The response. The next day, 7 March 2013, a retelling titled "The riddle of Amazon's dropdown" appeared on Habr, and the technique spread across the Russian-speaking web: as of October 2026 the article has more than 550 votes and two thousand bookmarks. The retelling also notes that the idea isn't new: it had been invented, forgotten and rediscovered before.
What came next. The technique moved into libraries: the "safe polygon" safePolygon() in Floating UI, the "grace
area" of submenus in Radix, the "safe triangle" useSafelyMouseToSubmenu in react-aria. Submenus shipped in
react-aria as an alpha on 13 February 2024 (v1.1.0) and became stable on 1 May 2024 (v1.2.0). The kit's MegaMenu
(2026) checks the wedge with cross products, following react-aria's model, and takes its pause from Kamens: the same
300 ms.
Primary sources:
Ben Kamens's article,
the jQuery-menu-aim repository,
a retelling on Habr, in Russian.