reduced motion toggle

This commit is contained in:
7w1 committed 2026-03-07 01:51:50 -06:00
1 parent 54d61fc57d
commit 52f9bac58f
6 files changed
+69 -5

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
sable: minor
---
Added reduced motion setting. Let us know if any elements were missed!
+5 -4
View File
@@ -571,6 +571,7 @@ export function RoomTimeline({
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
const [showHiddenEvents] = useSetting(settingsAtom, 'showHiddenEvents');
const [showDeveloperTools] = useSetting(settingsAtom, 'developerTools');
const [reducedMotion] = useSetting(settingsAtom, 'reducedMotion');
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
@@ -814,7 +815,7 @@ export function RoomTimeline({
if (typeof absoluteIndex === 'number') {
const scrolled = scrollToItem(absoluteIndex, {
behavior: 'smooth',
behavior: reducedMotion ? 'instant' : 'smooth',
align: 'center',
stopInView: true,
});
@@ -828,7 +829,7 @@ export function RoomTimeline({
loadEventTimeline(evtId);
}
},
[room, timeline, scrollToItem, loadEventTimeline]
[room, timeline, scrollToItem, loadEventTimeline, reducedMotion]
);
useLiveTimelineRefresh(
@@ -1067,7 +1068,7 @@ export function RoomTimeline({
if (scrollToBottomCount > 0) {
const scrollEl = scrollRef.current;
if (scrollEl) {
const behavior = scrollToBottomRef.current.smooth ? 'smooth' : 'instant';
const behavior = scrollToBottomRef.current.smooth && !reducedMotion ? 'smooth' : 'instant';
scrollToBottom(scrollEl, behavior);
// On Android WebView, layout may still settle after the initial scroll.
// Fire a second instant scroll after a short delay to guarantee we
@@ -1078,7 +1079,7 @@ export function RoomTimeline({
}
}
}
}, [scrollToBottomCount]);
}, [scrollToBottomCount, reducedMotion]);
// Remove unreadInfo on mark as read
useEffect(() => {
@@ -246,6 +246,7 @@ function ThemeSettings() {
const [systemTheme, setSystemTheme] = useSetting(settingsAtom, 'useSystemTheme');
const [saturation, setSaturation] = useSetting(settingsAtom, 'saturationLevel');
const [underlineLinks, setUnderlineLinks] = useSetting(settingsAtom, 'underlineLinks');
const [reducedMotion, setReducedMotion] = useSetting(settingsAtom, 'reducedMotion');
return (
<Box direction="Column" gap="100">
@@ -305,6 +306,13 @@ function ThemeSettings() {
after={<Switch variant="Primary" value={underlineLinks} onChange={setUnderlineLinks} />}
/>
</SequenceCard>
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
<SettingTile
title="Reduced Motion"
description="Stops animations and sliding UI elements."
after={<Switch variant="Primary" value={reducedMotion} onChange={setReducedMotion} />}
/>
</SequenceCard>
</Box>
);
}
+8 -1
View File
@@ -32,6 +32,7 @@ export function AuthRouteThemeManager({ children }: { children: ReactNode }) {
const activeTheme = useActiveTheme();
const [saturation] = useSetting(settingsAtom, 'saturationLevel');
const [underlineLinks] = useSetting(settingsAtom, 'underlineLinks');
const [reducedMotion] = useSetting(settingsAtom, 'reducedMotion');
useEffect(() => {
document.body.className = '';
@@ -44,6 +45,12 @@ export function AuthRouteThemeManager({ children }: { children: ReactNode }) {
document.body.classList.remove('force-underline-links');
}
if (reducedMotion) {
document.body.classList.add('reduced-motion');
} else {
document.body.classList.remove('reduced-motion');
}
if (saturation === 0) {
document.body.style.filter = 'grayscale(1)';
} else if (saturation && saturation < 100) {
@@ -51,7 +58,7 @@ export function AuthRouteThemeManager({ children }: { children: ReactNode }) {
} else {
document.body.style.filter = '';
}
}, [activeTheme, saturation, underlineLinks]);
}, [activeTheme, saturation, underlineLinks, reducedMotion]);
return <ThemeContextProvider value={activeTheme}>{children}</ThemeContextProvider>;
}
+2
View File
@@ -81,6 +81,7 @@ export interface Settings {
hideReads: boolean;
emojiSuggestThreshold: number;
underlineLinks: boolean;
reducedMotion: boolean;
// furry stuff
renderAnimals: boolean;
@@ -151,6 +152,7 @@ const defaultSettings: Settings = {
hideReads: false,
emojiSuggestThreshold: 2,
underlineLinks: false,
reducedMotion: false,
// furry stuff
renderAnimals: true,
+41
View File
@@ -175,8 +175,49 @@ pre {
font-variant-ligatures: contextual;
}
/* Accessibility Overrides :D */
.force-underline-links a {
text-decoration: underline !important;
text-decoration-thickness: 1px;
text-underline-offset: 2px;
}
body.reduced-motion * {
animation-duration: 0.001ms !important;
transition-duration: 0.001ms !important;
}
body.reduced-motion button:hover,
body.reduced-motion a:hover,
body.reduced-motion [role='button']:hover {
transform: none !important;
scale: 1 !important;
}
body.reduced-motion div[class*='Sidebar_SidebarItem']:hover,
body.reduced-motion div[class*='Sidebar_SidebarItem']:hover button,
body.reduced-motion div[class*='Sidebar_SidebarItem']:hover img {
transform: none !important;
scale: 1 !important;
translate: none !important;
margin: 0 !important;
padding: 0 !important;
}
body.reduced-motion div[class*='Sidebar_SidebarStack']:hover {
width: revert !important;
translate: none !important;
transform: none !important;
}
body.reduced-motion div[class*='layout_MessageBase'] {
animation: none !important;
transition: none !important;
transform: none !important;
}
body.reduced-motion div[class*='RoomTimeline_messageList'],
body.reduced-motion div[class*='RoomTimeline_messageList'] > * {
scroll-behavior: auto !important;
}