Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/components/bottomSheet/BottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Animated, {
useWorkletCallback,
type WithSpringConfig,
type WithTimingConfig,
ReduceMotion,
} from 'react-native-reanimated';
// import BottomSheetDebugView from '../bottomSheetDebugView';
import {
Expand Down Expand Up @@ -94,8 +95,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
//#region extract props
const {
// animations configurations
animationConfigs: _providedAnimationConfigs,

animationConfigs,
// configurations
index: _providedIndex = 0,
snapPoints: _providedSnapPoints,
Expand Down Expand Up @@ -179,6 +179,18 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
}
//#endregion

//#region animations configurations
const _providedAnimationConfigs = useMemo(() => {
if (!animationConfigs) {
return undefined;
}

animationConfigs.reduceMotion = ReduceMotion.Never;

return animationConfigs;
}, [animationConfigs]);
//#endregion

//#region layout variables
/**
* This variable is consider an internal variable,
Expand Down Expand Up @@ -709,6 +721,10 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
*/
runOnJS(handleOnAnimate)(animatedNextPositionIndex.value);

if (configs !== undefined) {
configs.reduceMotion = ReduceMotion.Never;
}

/**
* start animation
*/
Expand Down
4 changes: 3 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dimensions, Platform } from 'react-native';
import type Animated from 'react-native-reanimated';
import { Easing } from 'react-native-reanimated';
import { Easing, ReduceMotion } from 'react-native-reanimated';

const { height: WINDOW_HEIGHT, width: WINDOW_WIDTH } = Dimensions.get('window');
const { height: SCREEN_HEIGHT, width: SCREEN_WIDTH } = Dimensions.get('screen');
Expand Down Expand Up @@ -78,11 +78,13 @@ const ANIMATION_CONFIGS_IOS = {
overshootClamping: true,
restDisplacementThreshold: 10,
restSpeedThreshold: 10,
reduceMotion: ReduceMotion.Never,
};

const ANIMATION_CONFIGS_ANDROID = {
duration: ANIMATION_DURATION,
easing: ANIMATION_EASING,
reduceMotion: ReduceMotion.Never,
};

const ANIMATION_CONFIGS =
Expand Down
6 changes: 0 additions & 6 deletions src/utilities/animate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
type AnimationCallback,
ReduceMotion,
type WithSpringConfig,
type WithTimingConfig,
withSpring,
Expand All @@ -27,11 +26,6 @@ export const animate = ({
configs = ANIMATION_CONFIGS;
}

// Users might have an accessibility setting to reduce motion turned on.
// This prevents the animation from running when presenting the sheet, which results in
// the bottom sheet not even appearing so we need to override it to ensure the animation runs.
configs.reduceMotion = ReduceMotion.Never;

// detect animation type
const type =
'duration' in configs || 'easing' in configs
Expand Down
Loading