2023-08-17 16:46:35 +02:00
|
|
|
<script>
|
2023-07-22 20:44:24 +02:00
|
|
|
import { inview } from 'svelte-inview'
|
2023-08-05 20:33:07 +02:00
|
|
|
import previewRice from '$lib/videos/end_4_rice_intro.mp4'
|
|
|
|
import previewRiceThumbnail from '$lib/videos/end_4_thumbnail.png'
|
2023-08-07 19:59:22 +02:00
|
|
|
import AudioIcon from '~icons/mingcute/volume-line'
|
|
|
|
import MuteIcon from '~icons/mingcute/volume-mute-line'
|
2023-08-17 16:45:47 +02:00
|
|
|
import PauseIcon from '~icons/mingcute/pause-circle-line'
|
2023-08-07 19:59:22 +02:00
|
|
|
import clsx from 'clsx'
|
2023-08-17 16:45:47 +02:00
|
|
|
import { onMount } from 'svelte'
|
|
|
|
import { getIsMobile } from '$lib/Helper.mjs'
|
2023-07-22 20:44:24 +02:00
|
|
|
|
|
|
|
/** @type HTMLVideoElement */
|
|
|
|
let videoElement
|
2023-08-07 19:59:22 +02:00
|
|
|
|
2023-08-17 16:40:51 +02:00
|
|
|
let isVisible = false
|
2023-08-07 19:59:22 +02:00
|
|
|
let isShowingControls = false
|
|
|
|
let isMuted = true
|
2023-08-17 16:45:47 +02:00
|
|
|
let isPaused = false
|
|
|
|
|
2023-08-07 19:59:22 +02:00
|
|
|
function toggleMute() {
|
|
|
|
isMuted = !isMuted
|
|
|
|
}
|
|
|
|
function togglePlay() {
|
|
|
|
videoElement.paused ? videoElement.play() : videoElement.pause()
|
2023-08-17 16:45:47 +02:00
|
|
|
isPaused = videoElement.paused
|
|
|
|
}
|
|
|
|
|
|
|
|
function makeFullscreen() {
|
|
|
|
videoElement.requestFullscreen()
|
2023-08-07 19:59:22 +02:00
|
|
|
}
|
2023-08-17 16:45:47 +02:00
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
const isMobile = getIsMobile()
|
|
|
|
|
|
|
|
if (isMobile) {
|
|
|
|
//
|
|
|
|
}
|
|
|
|
})
|
2023-07-22 20:44:24 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<section
|
2023-08-17 16:45:47 +02:00
|
|
|
class="max-w-[1400px] px-1 relative -mb-4 lg:px-8 w-full animate-in [animation-delay:1700ms] fade-in-0 fill-mode-backwards [animation-duration:2000ms] slide-in-from-bottom-10 {$$restProps.class}"
|
2023-07-22 20:44:24 +02:00
|
|
|
>
|
|
|
|
<div
|
2023-08-17 16:40:51 +02:00
|
|
|
class={clsx(
|
2023-08-27 17:02:35 +02:00
|
|
|
'rounded-xl group relative border-sky-400 border-2 transition-all [transition-duration:1460ms] mx-3 shadow-2xl shadow-cyan-400/40',
|
2023-08-17 16:40:51 +02:00
|
|
|
!isVisible && 'opacity-20 scale-90'
|
|
|
|
)}
|
2023-08-07 19:59:22 +02:00
|
|
|
role="banner"
|
2023-08-17 16:40:51 +02:00
|
|
|
use:inview={{ threshold: 0.8 }}
|
|
|
|
on:inview_enter={() => {
|
|
|
|
isVisible = true
|
2023-07-31 11:32:19 +02:00
|
|
|
videoElement.play()
|
2023-07-22 20:44:24 +02:00
|
|
|
}}
|
2023-08-17 16:40:51 +02:00
|
|
|
on:inview_leave={() => {
|
|
|
|
isVisible = false
|
|
|
|
videoElement.pause()
|
|
|
|
}}
|
2023-08-17 16:45:47 +02:00
|
|
|
on:inview_leave={() => (isVisible = false)}
|
2023-08-07 19:59:22 +02:00
|
|
|
on:mouseenter={() => (isShowingControls = true)}
|
|
|
|
on:mouseleave={() => (isShowingControls = false)}
|
2023-07-22 20:44:24 +02:00
|
|
|
>
|
|
|
|
<video
|
|
|
|
bind:this={videoElement}
|
|
|
|
src={previewRice}
|
|
|
|
disablepictureinpicture="true"
|
|
|
|
disableremoteplayback="true"
|
2023-08-27 17:02:35 +02:00
|
|
|
class="rounded-xl"
|
2023-07-22 20:44:24 +02:00
|
|
|
loop
|
2023-08-07 19:59:22 +02:00
|
|
|
muted={isMuted}
|
2023-07-22 20:44:24 +02:00
|
|
|
preload="auto"
|
2023-08-05 20:33:07 +02:00
|
|
|
poster={previewRiceThumbnail}
|
2023-08-07 19:59:22 +02:00
|
|
|
on:click={togglePlay}
|
2023-08-17 16:45:47 +02:00
|
|
|
on:dblclick={makeFullscreen}
|
2023-07-22 20:44:24 +02:00
|
|
|
/>
|
2023-08-07 19:59:22 +02:00
|
|
|
<div
|
|
|
|
class={clsx(
|
|
|
|
'opacity-0 transition-opacity z-20 ',
|
|
|
|
isShowingControls ? 'opacity-100' : 'pointer-events-none'
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<button
|
2023-08-17 16:45:47 +02:00
|
|
|
class="absolute p-2 h-10 bg-black/5 rounded-full w-10 bottom-4 right-4 opacity-70 hover:opacity-100"
|
2023-08-07 19:59:22 +02:00
|
|
|
on:click|stopPropagation={toggleMute}
|
|
|
|
>
|
|
|
|
{#if isMuted}
|
|
|
|
<MuteIcon class="h-full w-full" />
|
|
|
|
{:else}
|
|
|
|
<AudioIcon class="h-full w-full" />
|
|
|
|
{/if}
|
|
|
|
</button>
|
2023-08-17 16:45:47 +02:00
|
|
|
{#if isPaused}
|
|
|
|
<div
|
|
|
|
class="absolute h-14 rounded-full -translate-x-1/2 -translate-y-1/2 w-14 top-1/2 left-1/2 opacity-80 hover:opacity-100 pointer-events-none"
|
|
|
|
>
|
|
|
|
<PauseIcon class="h-full w-full" />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2023-08-07 19:59:22 +02:00
|
|
|
</div>
|
2023-08-27 17:02:35 +02:00
|
|
|
|
|
|
|
<a
|
|
|
|
class="px-3 pt-2 block absolute -bottom-7 left-0 max-w-max text-sm text-slate-100/70 hover:underline"
|
|
|
|
href="https://github.com/end-4/">Setup by @end_4</a
|
|
|
|
>
|
2023-07-22 20:44:24 +02:00
|
|
|
</div>
|
2023-08-27 17:02:35 +02:00
|
|
|
|
2023-08-17 16:45:47 +02:00
|
|
|
<div class="preview-rice-bg overflow-x-hidden" aria="hidden" />
|
2023-07-22 20:44:24 +02:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<style lang="postcss">
|
|
|
|
.preview-rice-bg {
|
2023-08-17 16:45:47 +02:00
|
|
|
@apply absolute inset-0 -top-40 -z-10 w-full opacity-50;
|
2023-07-22 20:44:24 +02:00
|
|
|
/* background-color: red; */
|
2023-08-17 16:45:47 +02:00
|
|
|
background-image: radial-gradient(closest-side, theme(colors.sky.500), transparent);
|
2023-07-22 20:44:24 +02:00
|
|
|
}
|
|
|
|
</style>
|