add isReducedMotion util (#333)
This commit is contained in:
@ -5,6 +5,7 @@ import { EngineCommand } from '../lang/std/engineConnection'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { ActionButton } from '../components/ActionButton'
|
import { ActionButton } from '../components/ActionButton'
|
||||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
import { isReducedMotion } from 'lang/util'
|
||||||
|
|
||||||
type SketchModeCmd = Extract<
|
type SketchModeCmd = Extract<
|
||||||
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
|
Extract<EngineCommand, { type: 'modeling_cmd_req' }>['cmd'],
|
||||||
@ -22,7 +23,7 @@ export const DebugPanel = ({ className, ...props }: CollapsiblePanelProps) => {
|
|||||||
y_axis: { x: 0, y: 1, z: 0 },
|
y_axis: { x: 0, y: 1, z: 0 },
|
||||||
distance_to_plane: 100,
|
distance_to_plane: 100,
|
||||||
ortho: true,
|
ortho: true,
|
||||||
animated: true, // TODO #273 get prefers reduced motion from CSS
|
animated: !isReducedMotion(),
|
||||||
})
|
})
|
||||||
if (!sketchModeCmd) return null
|
if (!sketchModeCmd) return null
|
||||||
return (
|
return (
|
||||||
|
@ -26,3 +26,12 @@ export function updateCursors(
|
|||||||
setCursor(newSelections)
|
setCursor(newSelections)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isReducedMotion(): boolean {
|
||||||
|
return (
|
||||||
|
typeof window !== 'undefined' &&
|
||||||
|
window.matchMedia &&
|
||||||
|
// TODO/Note I (Kurt) think '(prefers-reduced-motion: reduce)' and '(prefers-reduced-motion)' are equivalent, but not 100% sure
|
||||||
|
window.matchMedia('(prefers-reduced-motion)').matches
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user