diff --git a/assets/img/BACKGROUND2.52010fb6a490a17ef475.png b/assets/img/scrollable-page-background.png.png similarity index 100% rename from assets/img/BACKGROUND2.52010fb6a490a17ef475.png rename to assets/img/scrollable-page-background.png.png diff --git a/src/App.svelte b/src/App.svelte index 6d0e402..e6ef692 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -164,7 +164,7 @@ position: fixed; inset: 0; z-index: -1; - background-image: url('/assets/img/BACKGROUND2.52010fb6a490a17ef475.png'); + background-image: url('/assets/img/scrollable-page-background.png'); background-size: cover; background-position: center; background-repeat: no-repeat; diff --git a/src/views/Expertise.svelte b/src/views/Expertise.svelte index 229ef79..961c81b 100644 --- a/src/views/Expertise.svelte +++ b/src/views/Expertise.svelte @@ -159,6 +159,11 @@ isReverse = false if (videoRev) videoRev.currentTime = dur requestAnimationFrame(() => computeOffset()) + // Force le décodage de la première frame (nécessaire sur mobile) + videoFwd.play().then(() => { + videoFwd.pause() + videoFwd.currentTime = 0 + }).catch(() => {}) } if (videoFwd?.duration) { init() diff --git a/src/views/Home.svelte b/src/views/Home.svelte index f5f8335..2f48449 100644 --- a/src/views/Home.svelte +++ b/src/views/Home.svelte @@ -7,6 +7,9 @@ const currentLang = $derived(locale.current) + let videoDesktop = $state(null) + let videoMobile = $state(null) + function playWhenReady(video) { if (!video) return @@ -33,8 +36,20 @@ } onMount(() => { - playWhenReady(document.getElementById('home-video')) - playWhenReady(document.getElementById('home-video-mobile')) + const mql = window.matchMedia('(max-width: 1000px)') + + function syncVideo(isMobile) { + const active = isMobile ? videoMobile : videoDesktop + const inactive = isMobile ? videoDesktop : videoMobile + if (inactive) inactive.pause() + playWhenReady(active) + } + + syncVideo(mql.matches) + const onChange = (e) => syncVideo(e.matches) + mql.addEventListener('change', onChange) + + return () => mql.removeEventListener('change', onChange) }) function handleExplore() { @@ -46,24 +61,24 @@