mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-26 17:01:20 -08:00
refactor(core): CORE-13 type component registries and own control lifetimes
This commit is contained in:
1 parent
9eb7c945ca
commit
697817eceb
68 files changed
+10100
-1925
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import type { ControlFactory, ControlOption } from './types'
|
||||
import { appendElement } from '../component/dom'
|
||||
import { setStyle, tooltip } from '../utils'
|
||||
import { controlEvents } from './resources'
|
||||
|
||||
export default function fullscreen(option: ControlOption): ControlFactory {
|
||||
return art => ({
|
||||
...option,
|
||||
tooltip: art.i18n.get('Fullscreen'),
|
||||
mounted: ($control) => {
|
||||
const { on, proxy } = controlEvents(art, $control)
|
||||
const { icons, i18n } = art
|
||||
|
||||
const $fullscreenOn = appendElement($control, icons.fullscreenOn)
|
||||
const $fullscreenOff = appendElement($control, icons.fullscreenOff)
|
||||
setStyle($fullscreenOff, 'display', 'none')
|
||||
|
||||
proxy($control, 'click', () => {
|
||||
art.fullscreen = !art.fullscreen
|
||||
})
|
||||
|
||||
on('fullscreen', (state) => {
|
||||
if (state) {
|
||||
tooltip($control, i18n.get('Exit Fullscreen'))
|
||||
setStyle($fullscreenOn, 'display', 'none')
|
||||
setStyle($fullscreenOff, 'display', 'inline-flex')
|
||||
}
|
||||
else {
|
||||
tooltip($control, i18n.get('Fullscreen'))
|
||||
setStyle($fullscreenOn, 'display', 'inline-flex')
|
||||
setStyle($fullscreenOff, 'display', 'none')
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user