Skip to content

Commit 32dc753

Browse files
authored
[UX/A11y] Disable animations (#4851)
* [UX/A11y] Disable animations * Fix focus on tabs and X buttons for controllers
1 parent 1610282 commit 32dc753

File tree

9 files changed

+64
-7
lines changed

9 files changed

+64
-7
lines changed

public/locales/en/translation.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"actions_font_family_default": "Actions Font Family (Default: {{fontFamily}})",
44
"all_tiles_in_color": "Show all game tiles in color",
55
"content_font_family_default": "Content Font Family (Default: {{fontFamily}})",
6+
"disable_animations": "Disable UI animations",
67
"disable_dialog_backdrop_close": "Disable closing dialogs by clicking outside",
78
"disable_smooth_scrolling": "Disable smooth scrolling (requires restart)",
89
"fonts": "Fonts",

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export interface AppSettings extends GameSettings {
104104
disablePlaytimeSync: boolean
105105
disableSmoothScrolling: boolean
106106
disableLogs: boolean
107+
disableAnimations: boolean
107108
discordRPC: boolean
108109
downloadNoHttps: boolean
109110
downloadProtonToSteam: boolean

src/common/types/electron_store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface StoreStructure {
3737
allTilesInColor: boolean
3838
titlesAlwaysVisible: boolean
3939
disableDialogBackdropClose: boolean
40+
disableAnimations: boolean
4041
language: string
4142
'general-logs': {
4243
currentLogFile: string

src/frontend/App.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,22 @@ body {
6565
grid-area: offline;
6666
}
6767

68+
body:has(.disableAnimations) {
69+
*,
70+
*:before,
71+
*:after {
72+
animation: none !important;
73+
transition: none !important;
74+
transition-duration: 0ms !important;
75+
}
76+
.MuiTouchRipple-root {
77+
display: none !important;
78+
}
79+
.Mui-focusVisible {
80+
background: color(from var(--accent-overlay) srgb r g b / 0.3);
81+
}
82+
}
83+
6884
.HelpButton {
6985
position: fixed;
7086
bottom: 0;

src/frontend/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ import { SettingsModalWrapper } from './screens/Settings/components/SettingsModa
2323
import AnalyticsDialog from './screens/Settings/components/AnalyticsDialog'
2424

2525
function Root() {
26-
const { isRTL, isFullscreen, isFrameless, experimentalFeatures, help } =
27-
useContext(ContextProvider)
26+
const {
27+
isRTL,
28+
isFullscreen,
29+
isFrameless,
30+
experimentalFeatures,
31+
help,
32+
disableAnimations
33+
} = useContext(ContextProvider)
2834

2935
const hasNativeOverlayControls = navigator['windowControlsOverlay']?.visible
3036
const showOverlayControls = isFrameless && !hasNativeOverlayControls
@@ -64,7 +70,8 @@ function Root() {
6470
className={classNames('App', {
6571
isRTL,
6672
frameless: isFrameless,
67-
fullscreen: isFullscreen
73+
fullscreen: isFullscreen,
74+
disableAnimations
6875
})}
6976
// disable dragging for all elements by default
7077
onDragStart={(e) => e.preventDefault()}

src/frontend/screens/Accessibility/index.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ const Accessibility = React.memo(function Accessibility() {
3232
setPrimaryFontFamily,
3333
setSecondaryFontFamily,
3434
disableDialogBackdropClose,
35-
setDisableDialogBackdropClose
35+
setDisableDialogBackdropClose,
36+
disableAnimations,
37+
setDisableAnimations
3638
} = useContext(ContextProvider)
3739

3840
hasHelp(
@@ -235,6 +237,22 @@ const Accessibility = React.memo(function Accessibility() {
235237
/>
236238
</label>
237239
</span>
240+
241+
<span className="setting">
242+
<label className={classNames('toggleWrapper', { isRTL: isRTL })}>
243+
<ToggleSwitch
244+
htmlId="disableAnimations"
245+
value={disableAnimations}
246+
handleChange={() => {
247+
setDisableAnimations(!disableAnimations)
248+
}}
249+
title={t(
250+
'accessibility.disable_animations',
251+
'Disable UI animations'
252+
)}
253+
/>
254+
</label>
255+
</span>
238256
</div>
239257
</div>
240258
)

src/frontend/state/ContextProvider.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ const initialContext: ContextType = {
9999
},
100100
handleExperimentalFeatures: () => null,
101101
disableDialogBackdropClose: false,
102-
setDisableDialogBackdropClose: () => null
102+
setDisableDialogBackdropClose: () => null,
103+
disableAnimations: false,
104+
setDisableAnimations: () => null
103105
}
104106

105107
export default React.createContext(initialContext)

src/frontend/state/GlobalState.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ interface StateProps {
104104
helpItems: { [key: string]: HelpItem }
105105
experimentalFeatures: ExperimentalFeatures
106106
disableDialogBackdropClose: boolean
107+
disableAnimations: boolean
107108
}
108109

109110
// function to load the new key or fallback to the old one
@@ -211,7 +212,8 @@ class GlobalState extends PureComponent<Props> {
211212
disableDialogBackdropClose: configStore.get(
212213
'disableDialogBackdropClose',
213214
false
214-
)
215+
),
216+
disableAnimations: configStore.get('disableAnimations', false)
215217
}
216218

217219
setCurrentCustomCategories = (newCustomCategories: string[]) => {
@@ -275,6 +277,11 @@ class GlobalState extends PureComponent<Props> {
275277
this.setState({ disableDialogBackdropClose: value })
276278
}
277279

280+
setDisableAnimations = (value: boolean) => {
281+
configStore.set('disableAnimations', value)
282+
this.setState({ disableAnimations: value })
283+
}
284+
278285
setSideBarCollapsed = (value: boolean) => {
279286
this.setState({ sidebarCollapsed: value })
280287
}
@@ -1045,7 +1052,9 @@ class GlobalState extends PureComponent<Props> {
10451052
addHelpItem: this.addHelpItem,
10461053
removeHelpItem: this.removeHelpItem
10471054
},
1048-
setDisableDialogBackdropClose: this.setDisableDialogBackdropClose
1055+
setDisableDialogBackdropClose: this.setDisableDialogBackdropClose,
1056+
disableAnimations: this.state.disableAnimations,
1057+
setDisableAnimations: this.setDisableAnimations
10491058
}}
10501059
>
10511060
{this.props.children}

src/frontend/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export interface ContextType {
113113
handleExperimentalFeatures: (newSetting: ExperimentalFeatures) => void
114114
disableDialogBackdropClose: boolean
115115
setDisableDialogBackdropClose: (value: boolean) => void
116+
disableAnimations: boolean
117+
setDisableAnimations: (value: boolean) => void
116118
}
117119

118120
export type DialogModalOptions = {

0 commit comments

Comments
 (0)