Disable autoplay by default if prefers-reduced-motion (#3671)
parent
0847e2752b
commit
24da3a8f4e
|
@ -1,5 +1,6 @@
|
||||||
import {Platform} from 'react-native'
|
import {Platform} from 'react-native'
|
||||||
import {getLocales} from 'expo-localization'
|
import {getLocales} from 'expo-localization'
|
||||||
|
|
||||||
import {dedupArray} from 'lib/functions'
|
import {dedupArray} from 'lib/functions'
|
||||||
|
|
||||||
export const isIOS = Platform.OS === 'ios'
|
export const isIOS = Platform.OS === 'ios'
|
||||||
|
@ -18,3 +19,8 @@ export const deviceLocales = dedupArray(
|
||||||
.map?.(locale => locale.languageCode)
|
.map?.(locale => locale.languageCode)
|
||||||
.filter(code => typeof code === 'string'),
|
.filter(code => typeof code === 'string'),
|
||||||
) as string[]
|
) as string[]
|
||||||
|
|
||||||
|
export const prefersReducedMotion =
|
||||||
|
isWeb &&
|
||||||
|
// @ts-ignore we know window exists -prf
|
||||||
|
!global.window.matchMedia('(prefers-reduced-motion: no-preference)')?.matches
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {z} from 'zod'
|
import {z} from 'zod'
|
||||||
|
|
||||||
import {deviceLocales} from '#/platform/detection'
|
import {deviceLocales, prefersReducedMotion} from '#/platform/detection'
|
||||||
|
|
||||||
const externalEmbedOptions = ['show', 'hide'] as const
|
const externalEmbedOptions = ['show', 'hide'] as const
|
||||||
|
|
||||||
|
@ -98,5 +98,5 @@ export const defaults: Schema = {
|
||||||
lastSelectedHomeFeed: undefined,
|
lastSelectedHomeFeed: undefined,
|
||||||
pdsAddressHistory: [],
|
pdsAddressHistory: [],
|
||||||
disableHaptics: false,
|
disableHaptics: false,
|
||||||
disableAutoplay: false,
|
disableAutoplay: prefersReducedMotion,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue