Fixes story viewing for reduced motion users

This commit is contained in:
Josh Perez 2022-09-21 20:56:05 -04:00 committed by GitHub
parent 0be580e8e5
commit 89b5768775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,7 @@ import React, {
useState,
} from 'react';
import classNames from 'classnames';
import { useSpring, animated, to } from '@react-spring/web';
import { Globals, useSpring, animated, to } from '@react-spring/web';
import type { BodyRangeType, LocalizerType } from '../types/Util';
import type { ContextMenuOptionType } from './ContextMenu';
import type { ConversationType } from '../state/ducks/conversations';
@ -234,6 +234,23 @@ export const StoryViewer = ({
};
}, []);
// Currently there's no way to globally skip animations but only allow select
// ones. This component temporarily overrides the skipAnimation global and
// then sets it back when it unmounts.
// https://github.com/pmndrs/react-spring/issues/1982
useEffect(() => {
const { skipAnimation } = Globals;
Globals.assign({
skipAnimation: false,
});
return () => {
Globals.assign({
skipAnimation,
});
};
}, []);
const [styles, spring] = useSpring(
() => ({
from: { width: 0 },