diff options
| author | William Hergès <william@herges.fr> | 2025-08-10 13:38:14 +0200 |
|---|---|---|
| committer | William Hergès <william@herges.fr> | 2025-08-10 13:38:14 +0200 |
| commit | 69f6e7c9f128e4887530b98c6aafbe14acf2b016 (patch) | |
| tree | 3f0b5b5af17057178ded53dfedf17d4c46c486bf | |
| parent | 5d703baed11f8f1b44df5ed7e03142cbdce839c5 (diff) | |
feat(video): disable autoplay for smaller screen
| -rw-r--r-- | src/component/VideoAuto.astro | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/component/VideoAuto.astro b/src/component/VideoAuto.astro index c8b0fe6..38282f6 100644 --- a/src/component/VideoAuto.astro +++ b/src/component/VideoAuto.astro @@ -2,6 +2,15 @@ const { src } = Astro.props; --- -<video muted autoplay loop> +<video muted loop> <source src={src} /> </video> + +<script> + window.addEventListener('load', () => { + document.querySelectorAll('video').forEach(video => { + if (window.screen.width < 1000) return; + video.autoplay = true; + }); + }) +</script> |
