feat(site): show the desktop demo in the hero and README

This commit is contained in:
Samuel Onoja committed 2026-10-13 01:07:37 +01:00
1 parent eb84104940
commit b552288dc1
8 files changed
+35 -6

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
const demo = document.querySelector('#desktop-demo');
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)');
let started = false;
// Start muted when the demo comes into view. Native controls remain available
// without JavaScript and after a visitor pauses playback.
const visibility = new IntersectionObserver(([entry]) => {
if (!entry.isIntersecting) {
demo.pause();
} else if (!started && !reducedMotion.matches) {
started = true;
demo.play().catch(() => {});
}
}, { threshold: 0.25 });
visibility.observe(demo);
reducedMotion.addEventListener('change', () => {
if (reducedMotion.matches) demo.pause();
});