client: respect reduce motion when auto-scrolling
This commit is contained in:
parent
945d3fbe63
commit
9d9f2d98a7
1 changed files with 2 additions and 1 deletions
|
@ -14,10 +14,11 @@ const ScrollToTop = () => {
|
||||||
return () => window.removeEventListener('scroll', handleScroll)
|
return () => window.removeEventListener('scroll', handleScroll)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
const isReducedMotion = typeof window !== 'undefined' ? window.matchMedia('(prefers-reduced-motion: reduce)').matches : false
|
||||||
const onClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
const onClick = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
// blur the button
|
// blur the button
|
||||||
e.currentTarget.blur()
|
e.currentTarget.blur()
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
window.scrollTo({ top: 0, behavior: isReducedMotion ? 'auto' : 'smooth' })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue