EmptyState: Don't apply animation when prefers-reduced-motion is set (#87638)

* don't apply animation when prefers-reduced-motion is set

* bail quicker

* early return
This commit is contained in:
Ashley Harrison 2024-05-13 10:48:41 +01:00 committed by GitHub
parent b214f9cc3a
commit 2cdb7d923f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,11 @@ export const GrotNotFound = ({ width = 'auto', height }: Props) => {
useEffect(() => {
const handleMouseMove = (event: MouseEvent) => {
// don't apply animation if reduced motion preference is set
if (window.matchMedia('(prefers-reduced-motion: reduce').matches) {
return;
}
const grotArm = svgRef.current?.querySelector('#grot-not-found-arm');
const grotMagnifier = svgRef.current?.querySelector('#grot-not-found-magnifier');