Files
p42.f-w/frontend/src/motion.js
T
guyg1474andClaude Opus 5.5 dd58b3d1f8 P42 Dashboard: erster Stand
FastAPI-Backend und React-Frontend mit Konten, Sendungsverfolgung,
Projekt-Artikeln, Vorrat & Einkauf mit Rezeptabgleich, Reise-Weltkarte,
Kanban-Projekten mit Priorität, Server-Monitoring und den Designs
Matrix und Blackwall. Betrieb per Docker hinter nginx (siehe DEPLOY.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 14:08:11 +02:00

31 lines
894 B
JavaScript

// Schalter für Hintergrund-Animationen (Matrix-Regen, blinkender Cursor), pro Browser gemerkt.
// Bei "Bewegung reduzieren" im System ist die Animation ohnehin aus.
const KEY = 'p42.calm';
const EVENT = 'p42:motion';
const systemReduced = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
export function isCalm() {
if (systemReduced()) return true;
try { return localStorage.getItem(KEY) === '1'; } catch { return false; }
}
export function setCalm(calm) {
try { localStorage.setItem(KEY, calm ? '1' : '0'); } catch { /* ignorieren */ }
apply();
}
export function onMotionChange(fn) {
window.addEventListener(EVENT, fn);
return () => window.removeEventListener(EVENT, fn);
}
export const motionLocked = systemReduced;
function apply() {
document.documentElement.classList.toggle('calm', isCalm());
window.dispatchEvent(new Event(EVENT));
}
apply();