feat: video player animations

This commit is contained in:
Tomáš Mládek 2022-12-08 15:44:28 +01:00
parent 8b97f20167
commit 8774fbc306

View file

@ -1,11 +1,27 @@
<script lang="ts"> <script lang="ts">
import { createEventDispatcher } from "svelte"; import { createEventDispatcher, onMount } from "svelte";
const dispatch = createEventDispatcher(); const dispatch = createEventDispatcher();
export let url: string; export let url: string;
let visible = false;
onMount(() => {
visible = true;
});
function exit() {
if (visible == false) {
dispatch("exit");
}
}
</script> </script>
<div class="videoPlayer" on:click={() => dispatch("exit")}> <div
class="videoPlayer"
on:click={() => (visible = false)}
class:visible
on:transitionend={() => exit()}
>
<!-- svelte-ignore a11y-media-has-caption --> <!-- svelte-ignore a11y-media-has-caption -->
<video controls autoplay src={url} /> <video controls autoplay src={url} />
</div> </div>
@ -26,5 +42,11 @@
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
transition: opacity 0.5s;
opacity: 0;
&.visible {
opacity: 1;
}
} }
</style> </style>