-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor full screen logic to be reusable (#10098)
- Loading branch information
1 parent
3a6151e
commit 9a6ce6f
Showing
8 changed files
with
88 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
"@gradio/annotatedimage": minor | ||
"@gradio/atoms": minor | ||
"@gradio/chatbot": minor | ||
"@gradio/gallery": minor | ||
"@gradio/image": minor | ||
"gradio": minor | ||
--- | ||
|
||
feat:Refactor full screen logic to be reusable |
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,46 @@ | ||
<script lang="ts"> | ||
import { onMount, createEventDispatcher } from "svelte"; | ||
import { IconButton } from "@gradio/atoms"; | ||
import { Maximize, Minimize } from "@gradio/icons"; | ||
export let container: HTMLElement | undefined = undefined; | ||
const dispatch = createEventDispatcher<{ | ||
fullscreenchange: boolean; | ||
}>(); | ||
let is_full_screen = false; | ||
onMount(() => { | ||
document.addEventListener("fullscreenchange", () => { | ||
is_full_screen = !!document.fullscreenElement; | ||
dispatch("fullscreenchange", is_full_screen); | ||
}); | ||
}); | ||
const toggle_full_screen = async (): Promise<void> => { | ||
if (!container) return; | ||
if (!is_full_screen) { | ||
await container.requestFullscreen(); | ||
} else { | ||
await document.exitFullscreen(); | ||
is_full_screen = !is_full_screen; | ||
} | ||
}; | ||
</script> | ||
|
||
{#if !is_full_screen} | ||
<IconButton | ||
Icon={Maximize} | ||
label="View in full screen" | ||
on:click={toggle_full_screen} | ||
/> | ||
{/if} | ||
|
||
{#if is_full_screen} | ||
<IconButton | ||
Icon={Minimize} | ||
label="Exit full screen" | ||
on:click={toggle_full_screen} | ||
/> | ||
{/if} |
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
Oops, something went wrong.