{{-- Title + Illustration --}}
<div x-data="{ shown: false }" x-intersect="shown = true"
- class="h-screen flex items-center"
+ class="h-screen flex items-center z-10"
x-cloak>
- {{-- Background Image --}}
- <div x-show="shown"
- x-transition:enter="ease-out-quint"
- x-transition:enter-start="translate-y-full"
- x-transition:enter-end="translate-y-0"
- class="absolute w-full h-full -z-1 bg-bottom bg-no-repeat"
- style="background-image: url({{ asset('images/splash-bg.jpg') }});
- background-size: 100% auto;
- transition-duration: 2500ms;
- transition-delay: 900ms;">
+ {{-- Background Video --}}
+ <div class="absolute w-full h-screen top-0 left-0 -z-1">
+ <video playsinline
+ muted
+ preload="auto"
+ data-delay="1000" {{-- How long in milliseconds to wait before starting the video --}}
+ id="background_video"
+ class="w-full absolute left-0 bottom-0">
+ <source src="{{ asset('images/splash.mp4') }}" type="video/mp4">
+ </video>
</div>
- <x-link href="/accueil" class="w-full max-h-[90vh] flex flex-col items-center justify-around">
+ <x-link href="/accueil"
+ id="home_link"
+ class="w-full max-h-[90vh] flex flex-col items-center justify-around">
<img x-show="shown"
x-transition.opacity.scale.75.origin.bottom.duration.1000ms
class="max-w-[488px] mb-16"
</div>
@endsection
+
+@push('after_scripts')
+ <script>
+ // Delay start of video
+ const startVideo = async (video) => {
+ try {
+ await video.play();
+ video.setAttribute('autoplay', true);
+ } catch (err) {
+ console.warn(err, 'Error playing video');
+ }
+ }
+
+ //========================================================
+
+ const video = document.querySelector('#background_video');
+
+ // Trigger click on main link when video ends
+ video.addEventListener('ended', () => document.querySelector('#home_link').click());
+
+ // Start video after a certain delay
+ setTimeout(() => startVideo(video), video.dataset?.delay);
+ </script>
+@endpush