perf(spa): drop backdrop blur on cards, fixed wallpaper layer, auto reduced effects on low-end (#24)
All checks were successful
CI / Check / Test (push) Successful in 1h11m34s
All checks were successful
CI / Check / Test (push) Successful in 1h11m34s
Reviewed-on: #24
This commit was merged in pull request #24.
This commit is contained in:
16
spa/src/lib/effects.ts
Normal file
16
spa/src/lib/effects.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
// Low-end devices can't keep up with live `backdrop-filter` while scrolling.
|
||||
// `deviceMemory` is Chromium-only (bucketed: 0.25 … 8 GB); Safari leaves it
|
||||
// undefined, so iPhones keep full effects. Flags <html> for aero-theme.css.
|
||||
|
||||
type NavigatorWithMemory = Navigator & { deviceMemory?: number }
|
||||
|
||||
function isLowEndDevice(): boolean {
|
||||
const nav = navigator as NavigatorWithMemory
|
||||
const lowMemory = nav.deviceMemory !== undefined && nav.deviceMemory <= 4
|
||||
const fewCores = nav.hardwareConcurrency !== undefined && nav.hardwareConcurrency <= 2
|
||||
return lowMemory || fewCores
|
||||
}
|
||||
|
||||
export function applyEffectsLevel(): void {
|
||||
if (isLowEndDevice()) document.documentElement.dataset.effects = "reduced"
|
||||
}
|
||||
Reference in New Issue
Block a user