Skip to content

Commit bef86e8

Browse files
committed
Prevent eye movement if motion isn't preferred
1 parent 1c209dc commit bef86e8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

components/Eyes/Eyes.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
background: var(--surface);
6464
animation: blink 30s linear infinite var(--blink-delay);
6565
border-radius: inherit;
66+
67+
@media (prefers-reduced-motion: reduce) {
68+
animation: none;
69+
}
6670
}
6771

6872
&::after {

components/Eyes/Eyes.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ const Eyes = () => {
2929
}, [])
3030

3131
useEffect(() => {
32-
document.body.addEventListener('pointermove', handleMouseMove)
33-
document.body.addEventListener('focusin', handleFocusChange)
34-
return () => {
35-
document.body.removeEventListener('pointermove', handleMouseMove)
36-
document.body.removeEventListener('focusin', handleFocusChange)
32+
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
33+
document.body.addEventListener('pointermove', handleMouseMove)
34+
document.body.addEventListener('focusin', handleFocusChange)
35+
return () => {
36+
document.body.removeEventListener('pointermove', handleMouseMove)
37+
document.body.removeEventListener('focusin', handleFocusChange)
38+
}
3739
}
3840
}, [])
3941

0 commit comments

Comments
 (0)