[C10] Systemeinstellung „Bewegung reduzieren“: keine Animationen, 3D-Kamera springt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-11-04 14:01:11 +00:00
1 parent 369d8a81b3
commit 8c1dc6cd9e
4 files changed
+37 -4

No files matched your search

+10
View File
@@ -8795,3 +8795,13 @@ body {
flex: 1 1 auto;
min-width: 0;
}
/* [C10] Systemeinstellung „Bewegung reduzieren": keine Übergänge/Animationen der Oberfläche. */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}
+7 -2
View File
@@ -243,6 +243,11 @@ export function getCamera(): ViewCamera | null {
}
/** Kamera setzen. `false` ohne Viewport oder bei unbrauchbarer Kamera (NaN, Nullvektor). */
/** [C10] Systemeinstellung „Bewegung reduzieren": Kamerafahrten springen dann direkt ans Ziel. */
export function prefersReducedMotion(): boolean {
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
}
export function setCamera(cam: ViewCamera, opts: { animate?: boolean } = {}): boolean {
if (!api) return false;
const cur = api.read();
@@ -254,7 +259,7 @@ export function setCamera(cam: ViewCamera, opts: { animate?: boolean } = {}): bo
dist = along >= 1 ? along : len(sub(cur.camera.target, cur.camera.eye)) || 10;
}
const c3 = camera3dFromViewCamera(cam, dist);
return c3 ? api.write(c3, opts.animate === true) : false;
return c3 ? api.write(c3, opts.animate === true && !prefersReducedMotion()) : false;
}
/**
@@ -277,7 +282,7 @@ export function focusedCamera(cam: Camera3d, centerModel: readonly number[], rad
/** Fokus der Live-Kamera auf einen Modellpunkt; `false` ohne Viewport. */
export function focusCamera(centerModel: readonly number[], radius: number, opts: { animate?: boolean } = {}): boolean {
const cur = api?.read();
return api && cur ? api.write(focusedCamera(cur.camera, centerModel, radius), opts.animate !== false) : false;
return api && cur ? api.write(focusedCamera(cur.camera, centerModel, radius), opts.animate !== false && !prefersReducedMotion()) : false;
}
/** PNG des aktuellen 3D-Bildes, oder null (kein Viewport, leeres/nicht lesbares Bild). */
+17
View File
@@ -0,0 +1,17 @@
// [C10] „Bewegung reduzieren": prefersReducedMotion folgt der Systemeinstellung (matchMedia), ohne Fenster false.
import { afterEach, describe, expect, it, vi } from "vitest";
import { prefersReducedMotion } from "./cameraBridge";
describe("prefersReducedMotion", () => {
afterEach(() => vi.unstubAllGlobals());
it("folgt matchMedia", () => {
vi.stubGlobal("window", { matchMedia: (q: string) => ({ matches: q.includes("reduce") }) });
expect(prefersReducedMotion()).toBe(true);
vi.stubGlobal("window", { matchMedia: () => ({ matches: false }) });
expect(prefersReducedMotion()).toBe(false);
});
it("ohne matchMedia: false", () => {
vi.stubGlobal("window", {});
expect(prefersReducedMotion()).toBe(false);
});
});