Skip to content

Commit 9ebc30e

Browse files
authored
Merge pull request #6659 from nextcloud-libraries/refactor/is-fullscreen
refactor(useIsFullscreen): migrate to Typescript
2 parents b046aa5 + 132b1ed commit 9ebc30e

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

src/composables/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
export * from './useIsFullscreen/index.js'
7-
export * from './useIsMobile/index.js'
86
export * from './useFormatDateTime.ts'
97
export * from './useHotKey/index.ts'
108
export * from './useIsDarkTheme/index.ts'
9+
export * from './useIsFullscreen/index.ts'
10+
export * from './useIsMobile/index.js'

src/composables/useIsFullscreen/index.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
import type { Ref } from 'vue'
6+
import { readonly, ref } from 'vue'
7+
8+
const isFullscreen = ref(checkIfIsFullscreen())
9+
10+
window.addEventListener('resize', () => {
11+
isFullscreen.value = checkIfIsFullscreen()
12+
})
13+
14+
/**
15+
* If the window height is equal to the screen height,
16+
* we are in full screen mode.
17+
*/
18+
function checkIfIsFullscreen(): boolean {
19+
return window.outerHeight === window.screen.height
20+
}
21+
22+
/**
23+
* Use global `isFullscreen` state, based on the screen height check.
24+
*/
25+
export function useIsFullscreen(): Readonly<Ref<boolean>> {
26+
return readonly(isFullscreen)
27+
}

0 commit comments

Comments
 (0)