← Files Peptide Reconstitution CalcARCHIVED FILE
web/motion.mjs
858 Bytes · Nov 3, 2026 · 19:06 UTC
export function initMotion() {
const button = document.getElementById('motion-toggle');
const preference = window.matchMedia('(prefers-reduced-motion: reduce)');
let userPaused = false;
const sync = () => {
const paused = userPaused || preference.matches;
document.body.dataset.motion = paused || document.hidden ? 'paused' : 'active';
button.textContent = preference.matches ? 'Motion off' : userPaused ? 'Resume motion' : 'Pause motion';
button.setAttribute('aria-pressed', String(paused));
button.disabled = preference.matches;
button.title = preference.matches ? 'Reduced motion is enabled in your system settings.' : '';
};
button.addEventListener('click', () => { userPaused = !userPaused; sync(); });
preference.addEventListener('change', sync);
document.addEventListener('visibilitychange', sync);
sync();
}
SHA-256: 7a435b17114bf6aa4eac11b26d7fdeeaa776404404cb38ba718d9427026095bb