Skip to content

Commit 69674f0

Browse files
committed
Enable exiting animation for modal container when prefers-reduced-motion is on
1 parent 7081915 commit 69674f0

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/components/Modal/ReanimatedModal/Container/index.web.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, {useEffect, useMemo, useRef} from 'react';
2-
import Animated, {Keyframe, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
2+
import Animated, {Keyframe, ReduceMotion, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
33
import type ReanimatedModalProps from '@components/Modal/ReanimatedModal/types';
44
import type {ContainerProps} from '@components/Modal/ReanimatedModal/types';
55
import {easing, getModalInAnimationStyle, getModalOutAnimation} from '@components/Modal/ReanimatedModal/utils';
@@ -37,13 +37,15 @@ function Container({
3737
// instead of an entering transition since keyframe animations break keyboard on mWeb Chrome (#62799)
3838
const animatedStyles = useAnimatedStyle(() => getModalInAnimationStyle(animationIn)(initProgress.get()), [initProgress]);
3939

40-
const Exiting = useMemo(() => {
41-
const AnimationOut = new Keyframe(getModalOutAnimation(animationOut));
42-
43-
// eslint-disable-next-line react-compiler/react-compiler
44-
return AnimationOut.duration(animationOutTiming).withCallback(() => onCloseCallbackRef.current());
45-
}, [animationOutTiming, animationOut]);
46-
40+
const Exiting = useMemo(
41+
() =>
42+
new Keyframe(getModalOutAnimation(animationOut))
43+
.duration(animationOutTiming)
44+
// eslint-disable-next-line react-compiler/react-compiler
45+
.withCallback(() => onCloseCallbackRef.current())
46+
.reduceMotion(ReduceMotion.Never),
47+
[animationOutTiming, animationOut],
48+
);
4749
return (
4850
<Animated.View
4951
style={[style, styles.modalContainer, type !== CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED && styles.modalAnimatedContainer, animatedStyles, {zIndex: 1}]}

0 commit comments

Comments
 (0)