fullScreen.ts
995 Bytes
export const useFullScreen = (domName: any, htmlName: HTMLHtmlElement) => {
const isFullScreen = document.fullscreenElement
const currentDatkTheme = htmlName.getAttribute('data-theme')
if (isFullScreen) {
if (document.exitFullscreen) {
document.exitFullscreen()
}
} else {
if (domName.requestFullscreen) {
domName.requestFullscreen()
domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
} else if (domName.mozRequestFullScreen) {
domName.mozRequestFullScreen()
domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
} else if (domName.webkitRequestFullscreen) {
domName.webkitRequestFullscreen()
domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
} else if (domName.msRequestFullscreen) {
domName.msRequestFullscreen()
domName.style.background = currentDatkTheme === 'light' ? 'white' : '#18181c'
}
}
}