Fullscreen

Reactive Fullscreen API. It adds methods to present a specific Element (and its descendants) in full-screen mode, and to exit full-screen mode once it is no longer needed. This makes it possible to present desired content—such as an online game—using the user's entire screen, removing all browser user interface elements and other applications from the screen until full-screen mode is shut off.

Usage

<script>
    import { fullscreen } from "@sveu/actions"

    function fn({ supported, enter, exit, toggle }) {
        console.log(supported, enter, exit, toggle)
    }
</script>

<video
    src="https://vjs.zencdn.net/v/oceans.mp4"
    width="600"
    controls
    use:fullscreen="{fn}">
    <track kind="captions" />
</video>
<script>
    import { fullscreen } from "@sveu/actions"

    function fn({ supported, enter, exit, toggle }) {
        console.log(supported, enter, exit, toggle)
    }
</script>

<video
    src="https://vjs.zencdn.net/v/oceans.mp4"
    width="600"
    controls
    use:fullscreen="{fn}">
    <track kind="captions" />
</video>
svelte

Example

<script>
    import { fullscreen } from "@sveu/actions" 

    import { noop } from "@sveu/shared"

    let toggle = noop

    function fn({ supported, toggle: _toggle }) { 
        toggle = _toggle
        console.log(supported)
    }
</script>
<div class="flex flex-col space-y-5 items-center">

    <video
        src="https://vjs.zencdn.net/v/oceans.mp4"
        width="600"
        controls
        use:fullscreen="{fn}"> <!--   -->
        <track kind="captions" />
    </video>

    <button
        class="border-none rounded-xl bg-purple-700 shadow-none text-white p-8"
        on:click="{toggle}">
        Go Fullscreen
    </button>
</div>
<script>
    import { fullscreen } from "@sveu/actions" 

    import { noop } from "@sveu/shared"

    let toggle = noop

    function fn({ supported, toggle: _toggle }) { 
        toggle = _toggle
        console.log(supported)
    }
</script>
<div class="flex flex-col space-y-5 items-center">

    <video
        src="https://vjs.zencdn.net/v/oceans.mp4"
        width="600"
        controls
        use:fullscreen="{fn}"> <!--   -->
        <track kind="captions" />
    </video>

    <button
        class="border-none rounded-xl bg-purple-700 shadow-none text-white p-8"
        on:click="{toggle}">
        Go Fullscreen
    </button>
</div>
svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Click fold/expand code

API

Arguments

Name Description Type Required
fn A function that receives functions to control the behavior of the fullscreen. (data: FullscreenFnData) => void No


Events

Name Description Type
fullscreen An event will fire once the fullscreen is toggled CustomEvent<Boolean>


TIP

If you use typescript, you need to add ./node_modules/@sveu/actions/events.d.ts to your tsconfig.json file.

{
    ...

    "include": [
        ...
        "./node_modules/@sveu/actions/events.d.ts"
    ]
    ...
}
{
    ...

    "include": [
        ...
        "./node_modules/@sveu/actions/events.d.ts"
    ]
    ...
}
json