diff --git a/src/routes/_utils/smoothScroll.js b/src/routes/_utils/smoothScroll.js index 4a520f2..bc1325f 100644 --- a/src/routes/_utils/smoothScroll.js +++ b/src/routes/_utils/smoothScroll.js @@ -1,3 +1,5 @@ +import { store } from '../_store/store' + // via https://github.com/tootsuite/mastodon/blob/f59ed3a4fafab776b4eeb92f805dfe1fecc17ee3/app/javascript/mastodon/scroll.js const easingOutQuint = (x, t, b, c, d) => c * ((t = t / d - 1) * t * t * t * t + 1) + b @@ -62,7 +64,10 @@ function testSupportsSmoothScroll () { export const hasNativeSmoothScroll = process.browser && testSupportsSmoothScroll() export function smoothScroll (node, topOrLeft, horizontal) { - if (hasNativeSmoothScroll) { + if (store.get().reduceMotion) { + // don't do smooth-scroll at all for users who prefer reduced motion + node[horizontal ? 'scrollLeft' : 'scrollTop'] = topOrLeft + } else if (hasNativeSmoothScroll) { return node.scrollTo({ [horizontal ? 'left' : 'top']: topOrLeft, behavior: 'smooth'