дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 18:17:15 +02:00
Moving the pointer diagonally from a menu item toward its open submenu crossed sibling items, whose hover timers switched or closed the submenu. While a submenu is open, a sibling hover is deferred when the pointer is inside the triangle from its previous position to the submenu's near corners, including flipped submenus. Stopping on a sibling still switches after 300 ms, moving away keeps the normal delays, and entering the submenu cancels pending switches. This lives in `MenuList`, so every menu and nested level gets it. Fixes #2128
21 рядки
939 B
TypeScript
21 рядки
939 B
TypeScript
export interface MenuPointer {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
|
|
type SubmenuRect = Pick<DOMRect, "left" | "right" | "top" | "bottom">;
|
|
|
|
/** Whether this move stays in the triangle leading to the submenu's near edge. */
|
|
export function isSubmenuAim(previous: MenuPointer | null, current: MenuPointer, rect: SubmenuRect): boolean {
|
|
if (!previous || rect.right <= rect.left || rect.bottom <= rect.top) return false;
|
|
const edge = previous.x < rect.left ? rect.left : rect.right;
|
|
const distance = edge - previous.x;
|
|
if (!distance || (previous.x >= rect.left && previous.x <= rect.right)) return false;
|
|
const progress = (current.x - previous.x) / distance;
|
|
if (progress <= 0 || progress > 1) return false;
|
|
const tolerance = 8;
|
|
const top = previous.y + (rect.top - tolerance - previous.y) * progress;
|
|
const bottom = previous.y + (rect.bottom + tolerance - previous.y) * progress;
|
|
return current.y >= top && current.y <= bottom;
|
|
}
|