@olddevs/ui 4.2.0 → 4.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @olddevs/ui
2
2
 
3
+ ## 4.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 581ac6f: The `MegaMenu` reference page tells the fuller story of the technique in "Where it comes from": the trap that menus used to close with a delay, how Ben Kamens worked out Amazon's triangle in 2013, the math behind `jQuery-menu-aim`, and how the idea spread.
8
+
3
9
  ## 4.2.0
4
10
 
5
11
  ### Minor Changes
@@ -5,7 +5,7 @@ category: navigation
5
5
  status: stable
6
6
  source: src/components/navigation/MegaMenu.tsx
7
7
  story: src/components/navigation/MegaMenu.stories.tsx
8
- sourceHash: 8e166f4b1ab7
8
+ sourceHash: 731dae1c43c3
9
9
  ---
10
10
 
11
11
  # MegaMenu
@@ -162,20 +162,38 @@ category column of a catalog gets scrolled through.
162
162
  ## Where it comes from
163
163
 
164
164
  The technique comes from Amazon. By 2013 the "Shop by Department" menu on amazon.com already worked like this: a
165
- column of departments on the left, a large panel on the right, and switching with no delay at all, while the pointer
166
- could cut diagonally toward the panel without knocking it away. Ben Kamens worked out how it does that.
167
-
168
- - **6 March 2013**: Ben Kamens, a developer at Khan Academy, publishes the analysis "Breaking down Amazon's mega
169
- dropdown". He shows that Amazon does not slow the opening down with a delay, as most dropdown menus do, but
170
- follows the direction of the pointer: while it stays inside the triangle between the pointer and the corners of the
171
- panel, the submenu does not change. Khan Academy puts the technique into its new "Learn" menu.
172
- - **March 2013**: Kamens publishes the `jQuery-menu-aim` plugin on GitHub: the triangle, a tolerance near the corners
173
- and a 300 ms delay for a pointer that has stopped.
174
- - **7 March 2013**: a retelling of the article appears on Habr, from which the technique spread across the Russian-speaking web.
175
- - **After that**: the technique moves into libraries: the "safe polygon" `safePolygon()` in Floating UI, the "grace
176
- area" of submenus in Radix, the "safe triangle" `useSafelyMouseToSubmenu` in react-aria. Submenus shipped in
177
- react-aria as an alpha on 13 February 2024 (v1.1.0) and became stable on 1 May 2024 (v1.2.0).
178
- - **2026**: `MegaMenu` in `@olddevs/ui`: the react-aria model and Kamens's pause.
165
+ column of departments on the left, a large panel on the right, switching with no delay at all, and yet the pointer
166
+ could cut diagonally toward the panel without knocking it away.
167
+
168
+ **The trap that menus closed with a delay.** If a submenu switches at once, the pointer brushes a neighboring item on
169
+ its way there, the submenu changes, and the link you were heading for is gone: a game you can't win. Bootstrap's
170
+ dropdowns behaved like this, for example. The usual fix is a delay before switching items, known as menu hysteresis,
171
+ as in Khan Academy's own earlier menu. It closes the trap but makes the menu sluggish: every move between items waits
172
+ for a timer.
173
+
174
+ **What Ben Kamens noticed.** The Khan Academy developer saw that Amazon's menu switches instantly and still doesn't
175
+ lose the submenu, and worked out why. The menu watches direction, not time: at each pointer position it builds a
176
+ triangle with corners at the pointer itself and at the top and bottom corners of the submenu. If the next position is
177
+ inside the triangle, the user is heading for the submenu, and items brushed on the way don't take it over. Once the
178
+ pointer leaves the triangle, the submenu switches immediately. Kamens published his analysis on 6 March 2013.
179
+
180
+ **The plugin and the math.** Kamens turned the idea into a jQuery plugin, `jQuery-menu-aim`, and used it in Khan
181
+ Academy's new "Learn" menu. Whether a point lies inside a triangle can be checked with cross products, and Sophie
182
+ Alpert helped him with that bit of linear algebra, but in the plugin Kamens went with something simpler: comparing
183
+ the slopes of lines. A pointer that entered the triangle and stopped still opens the item under it, after 300 ms.
184
+ Kamens was happy to admit he had copied Amazon, and suspected the problem had been solved and forgotten many times
185
+ before.
186
+
187
+ **The response.** The next day, 7 March 2013, a retelling titled "The riddle of Amazon's dropdown" appeared on Habr,
188
+ and the technique spread across the Russian-speaking web: as of October 2026 the article has more than 550 votes and
189
+ two thousand bookmarks. The retelling also notes that the idea isn't new: it had been invented, forgotten and
190
+ rediscovered before.
191
+
192
+ **What came next.** The technique moved into libraries: the "safe polygon" `safePolygon()` in Floating UI, the "grace
193
+ area" of submenus in Radix, the "safe triangle" `useSafelyMouseToSubmenu` in react-aria. Submenus shipped in
194
+ 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`
195
+ (2026) checks the wedge with cross products, following react-aria's model, and takes its pause from Kamens: the same
196
+ 300 ms.
179
197
 
180
198
  Primary sources:
181
199
  [Ben Kamens's article](https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown),
@@ -151,20 +151,35 @@ import { MegaMenu, MegaMenuCategory, MegaMenuGroup, MegaMenuLink } from "@olddev
151
151
  ## Откуда это
152
152
 
153
153
  Приём пришёл из Amazon. К 2013 году меню «Shop by Department» на amazon.com уже работало так: столбец отделов
154
- слева, большая панель справа, и переключение без всякой задержки — при этом наискосок к панели курсор проходил,
155
- не сбивая её. Как это устроено, разобрал Бен Каменс.
156
-
157
- - **6 марта 2013** — Бен Каменс, разработчик Khan Academy, публикует разбор «Breaking down Amazon's mega
158
- dropdown». Он показывает, что Amazon не тормозит открытие задержкой, как большинство выпадающих меню, а следит
159
- за направлением курсора: пока тот внутри треугольника между курсором и углами панели, подменю не меняется.
160
- Khan Academy ставит приём в своё новое меню «Learn».
161
- - **Март 2013** — Каменс выкладывает плагин `jQuery-menu-aim` на GitHub: треугольник, допуск у углов и
162
- задержка 300 мс для курсора, который остановился.
163
- - **7 марта 2013** — пересказ статьи на Хабре, с которого приём разошёлся по рунету.
164
- - **Дальше** — приём уходит в библиотеки: «безопасный многоугольник» `safePolygon()` в Floating UI, «grace
165
- area» подменю в Radix, «безопасный треугольник» `useSafelyMouseToSubmenu` в react-aria. В react-aria подменю
166
- вышли альфой 13 февраля 2024 года (v1.1.0) и стали стабильными 1 мая 2024 года (v1.2.0).
167
- - **2026** — `MegaMenu` в `@olddevs/ui`: модель react-aria и пауза Каменса.
154
+ слева, большая панель справа, переключение без всякой задержки — и при этом курсор проходил к панели наискосок, не
155
+ сбивая её.
156
+
157
+ **Ловушка, которую закрывали задержкой.** Если подменю переключается сразу, курсор по пути к нему задевает соседний
158
+ пункт, подменю сменяется, и до нужной ссылки не дотянуться: как в игре, которую нельзя выиграть. Так вели себя,
159
+ например, выпадающие меню Bootstrap. Обычный ответ — задержка перед сменой пункта, гистерезис меню, как в прежнем
160
+ меню самой Khan Academy. Ловушку она закрывает, но меню становится вязким: каждый переход между пунктами ждёт
161
+ таймера.
162
+
163
+ **Что заметил Бен Каменс.** Разработчик Khan Academy обратил внимание, что меню Amazon переключается мгновенно и
164
+ всё же не теряет подменю, и разобрался почему. Меню следит не за временем, а за направлением: для каждой точки
165
+ курсора строится треугольник с вершинами в самом курсоре и в верхнем и нижнем углах подменю. Следующая точка
166
+ внутри треугольника значит, что человек ведёт курсор к подменю, и пункты, задетые по пути, его не перехватывают.
167
+ Курсор вышел из треугольника — подменю меняется сразу. Свой разбор Каменс опубликовал 6 марта 2013 года.
168
+
169
+ **Плагин и математика.** По этому принципу Каменс написал jQuery-плагин `jQuery-menu-aim` и поставил его в
170
+ новое меню «Learn» на Khan Academy. Попадание точки в треугольник проверяется векторным произведением — с этой
171
+ линейной алгеброй ему помогла Софи Алперт, — но в плагине Каменс выбрал способ попроще: сравнение наклонов прямых.
172
+ Курсор, который вошёл в треугольник и остановился, всё же открывает пункт под собой: через 300 мс. Сам Каменс не
173
+ стеснялся того, что скопировал Amazon, и подозревал, что задачу до них не раз решали и забывали.
174
+
175
+ **Отклик.** На следующий день, 7 марта 2013 года, на Хабре вышел пересказ «Загадка выпадающего списка «Амазона»», и
176
+ приём разошёлся по рунету: на октябрь 2026 года у статьи больше 550 голосов и двух тысяч закладок. Пересказ тоже
177
+ отмечает, что идея не новая — её придумывали, забывали и открывали заново.
178
+
179
+ **Дальше.** Приём ушёл в библиотеки: «безопасный многоугольник» `safePolygon()` в Floating UI, «grace area»
180
+ подменю в Radix, «безопасный треугольник» `useSafelyMouseToSubmenu` в react-aria. В react-aria подменю вышли
181
+ альфой 13 февраля 2024 года (v1.1.0) и стали стабильными 1 мая 2024 года (v1.2.0). `MegaMenu` кита (2026)
182
+ проверяет сектор векторным произведением, по модели react-aria, а паузу берёт у Каменса — те же 300 мс.
168
183
 
169
184
  Первоисточники:
170
185
  [статья Бена Каменса](https://bjk5.com/post/44698559168/breaking-down-amazons-mega-dropdown),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olddevs/ui",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Olddevs UI — design system: tokens, themes and accessible UI primitives",
5
5
  "license": "MIT",
6
6
  "private": false,