aboutsummaryrefslogtreecommitdiff
path: root/src/component/VideoAuto.astro
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-08-10 13:38:14 +0200
committerWilliam Hergès <william@herges.fr>2025-08-10 13:38:14 +0200
commit69f6e7c9f128e4887530b98c6aafbe14acf2b016 (patch)
tree3f0b5b5af17057178ded53dfedf17d4c46c486bf /src/component/VideoAuto.astro
parent5d703baed11f8f1b44df5ed7e03142cbdce839c5 (diff)
feat(video): disable autoplay for smaller screen
Diffstat (limited to 'src/component/VideoAuto.astro')
-rw-r--r--src/component/VideoAuto.astro11
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>