-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13387 from nextcloud/backport/13311/stable30
- Loading branch information
Showing
8 changed files
with
90 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
import { createSharedComposable } from '@vueuse/core' | ||
import { readonly, ref, onBeforeMount, onBeforeUnmount } from 'vue' | ||
import type { Ref, DeepReadonly } from 'vue' | ||
|
||
/** | ||
* Composable to check whether the page is displayed at fullscreen | ||
* @return {DeepReadonly<Ref<boolean>>} - computed boolean whether the page is displayed at fullscreen | ||
*/ | ||
function useDocumentFullscreenComposable() { | ||
const isFullscreen = ref<boolean>(document.fullscreenElement !== null) | ||
|
||
const changeIsFullscreen = () => { | ||
isFullscreen.value = document.fullscreenElement !== null | ||
} | ||
|
||
document.addEventListener('fullscreenchange', changeIsFullscreen) | ||
document.addEventListener('webkitfullscreenchange', changeIsFullscreen) | ||
|
||
onBeforeUnmount(() => { | ||
document.removeEventListener('fullscreenchange', changeIsFullscreen) | ||
document.removeEventListener('webkitfullscreenchange', changeIsFullscreen) | ||
}) | ||
|
||
return readonly(isFullscreen) | ||
} | ||
|
||
/** | ||
* Enable a fullscreen with Fullscreen API | ||
*/ | ||
export async function enableFullscreen() { | ||
const element = document.getElementById('content-vue') | ||
if (!element) { | ||
return | ||
} | ||
|
||
if (element.requestFullscreen) { | ||
await element.requestFullscreen() | ||
} else if (element.webkitRequestFullscreen) { | ||
await element.webkitRequestFullscreen() | ||
} | ||
} | ||
|
||
/** | ||
* Disable a fullscreen | ||
*/ | ||
export async function disableFullscreen() { | ||
if (document.exitFullscreen) { | ||
await document.exitFullscreen() | ||
} else if (document.webkitExitFullscreen) { | ||
await document.webkitExitFullscreen() | ||
} | ||
} | ||
|
||
/** | ||
* Shared composable to check whether the page is displayed at fullscreen | ||
* @return {DeepReadonly<Ref<boolean>>} - computed boolean whether the page is displayed at fullscreen | ||
*/ | ||
export const useDocumentFullscreen = createSharedComposable(useDocumentFullscreenComposable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.