mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
refactor(core): [CORE-23] complete keyboard controls and focus lifecycle
This commit is contained in:
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` })
|
||||
}
|
||||
Reference in new issue
Block a user