refactor(core): [CORE-23] complete keyboard controls and focus lifecycle

This commit is contained in:
Harvey Zhao committed 2026-09-11 21:06:33 +08:00
1 parent faaa3e8c2d
commit 8ed0a5228c
190 files changed
+53981 -489

No files matched your search

@@ -0,0 +1,17 @@
import type { ContextmenuHost } from './types'
import { isClosing } from '../lifecycle/instance'
import { getRect, setStyles } from '../utils'
export function positionContextmenu(art: ContextmenuHost, mouseX: number, mouseY: number): void {
const { $player, $contextmenu } = art.template
const { height: cHeight, width: cWidth, left: cLeft, top: cTop } = getRect($player)
const { height: mHeight, width: mWidth } = getRect($contextmenu)
let menuLeft = mouseX - cLeft
let menuTop = mouseY - cTop
if (mouseX + mWidth > cLeft + cWidth)
menuLeft = cWidth - mWidth
if (mouseY + mHeight > cTop + cHeight)
menuTop = cHeight - mHeight
if (!isClosing(art))
setStyles($contextmenu, { top: `${menuTop}px`, left: `${menuLeft}px` })
}