mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-25 16:11: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
@@ -3,9 +3,11 @@ import { appendElement } from '../component/dom'
|
||||
import { entryScope, subscribeEntry } from '../component/resources'
|
||||
import { isClosing } from '../lifecycle/instance'
|
||||
import { addClass, hasClass, removeClass, setStyle } from '../utils'
|
||||
import { lockKeyboard } from './lock-keyboard'
|
||||
|
||||
export interface LockHost extends SubscriptionHost<{ lock: [boolean] }> {
|
||||
template: { $player: HTMLElement }
|
||||
template: { $player: HTMLElement, $bottom: HTMLElement }
|
||||
i18n: { get: (key: string) => string }
|
||||
icons: { lock: string | Element, unlock: string | Element }
|
||||
isLock: boolean
|
||||
emit: (name: 'lock', state: boolean) => unknown
|
||||
@@ -57,7 +59,17 @@ export default function lock(art: LockHost): { name: string, state: boolean } {
|
||||
const $unlock = appendElement($el, icons.unlock)
|
||||
if (scope.closed || isClosing(art))
|
||||
return
|
||||
setStyle($lock, 'display', 'none')
|
||||
const updateKeyboard = lockKeyboard(art, $el, scope, getState)
|
||||
if (scope.closed || isClosing(art))
|
||||
return
|
||||
if (getState()) {
|
||||
setStyle($lock, 'display', 'inline-flex')
|
||||
if (!scope.closed && !isClosing(art))
|
||||
setStyle($unlock, 'display', 'none')
|
||||
}
|
||||
else {
|
||||
setStyle($lock, 'display', 'none')
|
||||
}
|
||||
|
||||
subscribeEntry<{ lock: [boolean] }, 'lock'>(art, $el, 'lock', (state) => {
|
||||
if (isClosing(art))
|
||||
@@ -65,6 +77,8 @@ export default function lock(art: LockHost): { name: string, state: boolean } {
|
||||
setStyle($lock, 'display', state ? 'inline-flex' : 'none')
|
||||
if (!scope.closed && !isClosing(art))
|
||||
setStyle($unlock, 'display', state ? 'none' : 'inline-flex')
|
||||
if (!scope.closed && !isClosing(art))
|
||||
updateKeyboard(state)
|
||||
})
|
||||
},
|
||||
click() {
|
||||
|
||||
Reference in new issue
Block a user