diff --git a/example/src/components/programmatic.js b/example/src/components/programmatic.js index 3ffee3e..1e570c4 100644 --- a/example/src/components/programmatic.js +++ b/example/src/components/programmatic.js @@ -6,7 +6,7 @@ export const fade = ({ exit: { length }, node, direction }) => { const scrollTop = (document.scrollingElement && document.scrollingElement.scrollTop) || document.body.scrollTop || - window.pageYOffset + (typeof window !== `undefined` && window.pageYOffset) const holdPosition = direction === 'out' diff --git a/src/context/InternalProvider.js b/src/context/InternalProvider.js index a77ae5f..be84b75 100644 --- a/src/context/InternalProvider.js +++ b/src/context/InternalProvider.js @@ -6,14 +6,18 @@ import getPagesPromises from '../utils/getPagesPromises' class InternalProvider extends Component { constructor(props) { super(props) - const prefersReducedMotionSetting = window.matchMedia('(prefers-reduced-motion: reduce)') + const prefersReducedMotionSetting = + typeof window !== `undefined` && + window.matchMedia('(prefers-reduced-motion: reduce)') - const prefersReducedMotion = - typeof window !== `undefined` && prefersReducedMotionSetting - - if (prefersReducedMotionSetting.matches && process.env.NODE_ENV === `development`) { + const prefersReducedMotion = prefersReducedMotionSetting + + if ( + prefersReducedMotionSetting.matches && + process.env.NODE_ENV === `development` + ) { console.warn( - `[gatsby-plugin-transition-link] Warning! prefers-reduced-motion is activated via your OS settings. This means TransitionLink animations will not run.`, + `[gatsby-plugin-transition-link] Warning! prefers-reduced-motion is activated via your OS settings. This means TransitionLink animations will not run.` ) }