Add respecting OS setting for natural scroll direction
This commit is contained in:
@ -4,6 +4,7 @@ import { v4 } from 'uuid'
|
||||
import { isDesktop } from './isDesktop'
|
||||
import { AnyMachineSnapshot } from 'xstate'
|
||||
import { AsyncFn } from './types'
|
||||
import { readNaturalScrollDirection } from './desktop'
|
||||
|
||||
export const uuidv4 = v4
|
||||
|
||||
@ -262,6 +263,19 @@ export function isReducedMotion(): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* True if Apple Trackpad scroll should move the content. I.e. if this is true,
|
||||
* and the user scrolls down, the viewport moves up relative to the content.
|
||||
*/
|
||||
export let cachedNaturalScrollDirection = platform() === 'macos'
|
||||
|
||||
export async function refreshNaturalScrollDirection() {
|
||||
if (!isDesktop()) return cachedNaturalScrollDirection
|
||||
const isNatural = await readNaturalScrollDirection()
|
||||
cachedNaturalScrollDirection = isNatural
|
||||
return isNatural
|
||||
}
|
||||
|
||||
export function XOR(bool1: boolean, bool2: boolean): boolean {
|
||||
return (bool1 || bool2) && !(bool1 && bool2)
|
||||
}
|
||||
|
Reference in New Issue
Block a user