Skip to content

Commit

Permalink
🐛 Fixed bug with MagicTabSelect not animating
Browse files Browse the repository at this point in the history
* Setting prefersReducedMotion to true by default was messing
  with the `MagicTabSelect` component
  • Loading branch information
Etesam913 committed Oct 29, 2023
1 parent 98f0a49 commit 165dd84
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/react-magic-motion/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PREFERSREDUCEDMOTION = "(prefers-reduced-motion: no-preference)";
*/
export function usePlaceholderBoxSize(
isCardExpanded: boolean,
rootNode: RefObject<HTMLElement>
rootNode: RefObject<HTMLElement>,
): { placeholderBoxHeight: number; placeholderBoxWidth: number } {
const [placeholderBoxDimensions, setPlaceholderBoxDimensions] = useState({
width: 0,
Expand Down Expand Up @@ -49,12 +49,12 @@ export function usePlaceholderBoxSize(
* Updates the `prefersReducedMotion` state whenever
* the `prefers-reduced-motion:reduce` option is set
*/
export function usePrefersReducedMotion() {
const [prefersReducedMotion, setPrefersReducedMotion] = useState(true);
export function usePrefersReducedMotion(): boolean {
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);

useEffect(() => {
const mediaQueryList = window.matchMedia(PREFERSREDUCEDMOTION);
if (mediaQueryList) setPrefersReducedMotion(!mediaQueryList.matches);
setPrefersReducedMotion(!mediaQueryList.matches);
const listener = (event: MediaQueryListEvent) => {
setPrefersReducedMotion(!event.matches);
};
Expand Down

0 comments on commit 165dd84

Please sign in to comment.