Skip to content

Commit

Permalink
fix(motion): respect reduced motion in createMotionComponent() (#33357)
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter authored Nov 27, 2024
1 parent 5ada132 commit 883151b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: respect reduced motion in createMotionComponent()",
"packageName": "@fluentui/react-motion",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ import * as React from 'react';
export type MotionBehaviourType = 'skip' | 'default';

const MotionBehaviourContext = React.createContext<MotionBehaviourType | undefined>(undefined);

export const MotionBehaviourProvider = MotionBehaviourContext.Provider;
export const useMotionBehaviourContext = () => React.useContext(MotionBehaviourContext) ?? 'default';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
import { useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import * as React from 'react';

const REDUCED_MEDIA_QUERY = 'screen and (prefers-reduced-motion: reduce)';

Expand All @@ -12,7 +13,7 @@ export function useIsReducedMotion(): () => boolean {
const queryValue = React.useRef<boolean>(false);
const isEnabled = React.useCallback(() => queryValue.current, []);

React.useEffect(() => {
useIsomorphicLayoutEffect(() => {
if (targetWindow === null || typeof targetWindow.matchMedia !== 'function') {
return;
}
Expand Down

0 comments on commit 883151b

Please sign in to comment.