Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
fix: check that window exists before trying to access it
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBarnes committed Jun 23, 2020
1 parent 549320d commit 9544d9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion example/src/components/programmatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
16 changes: 10 additions & 6 deletions src/context/InternalProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.`
)
}

Expand Down

0 comments on commit 9544d9a

Please sign in to comment.