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

Commit

Permalink
fix: only show prefers-reduced-motion warning if it's actually set 🤦‍♂️
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerBarnes committed Jun 22, 2020
1 parent 7a15185 commit ac5f15e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/context/InternalProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ import getPagesPromises from '../utils/getPagesPromises'
class InternalProvider extends Component {
constructor(props) {
super(props)
const prefersReducedMotion =
typeof window !== `undefined` &&
window.matchMedia('(prefers-reduced-motion: reduce)')
const prefersReducedMotionSetting = window.matchMedia('(prefers-reduced-motion: reduce)')

if (prefersReducedMotion && 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.`)
const prefersReducedMotion =
typeof window !== `undefined` && 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.`,
)
}

this.state = {
Expand Down

0 comments on commit ac5f15e

Please sign in to comment.