diff options
author | Hailey <me@haileyok.com> | 2024-10-10 19:21:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-10 19:21:04 -0700 |
commit | 9176a8ff64e776a0c5a89e5f13db03f212c05722 (patch) | |
tree | 3e795c5936bdc559bb894cc639b358ee620beca0 | |
parent | 32bf38940de5a179ca1b659eaa557f93cadc9458 (diff) | |
download | voidsky-9176a8ff64e776a0c5a89e5f13db03f212c05722.tar.zst |
dont scale in pressable w/ reduced motion (#5697)
-rw-r--r-- | src/lib/custom-animations/PressableScale.tsx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/custom-animations/PressableScale.tsx b/src/lib/custom-animations/PressableScale.tsx index ca080dc8a..4737b9ea3 100644 --- a/src/lib/custom-animations/PressableScale.tsx +++ b/src/lib/custom-animations/PressableScale.tsx @@ -4,6 +4,7 @@ import Animated, { cancelAnimation, runOnJS, useAnimatedStyle, + useReducedMotion, useSharedValue, withTiming, } from 'react-native-reanimated' @@ -26,6 +27,8 @@ export function PressableScale({ targetScale?: number style?: StyleProp<ViewStyle> } & Exclude<PressableProps, 'onPressIn' | 'onPressOut' | 'style'>) { + const reducedMotion = useReducedMotion() + const scale = useSharedValue(1) const animatedStyle = useAnimatedStyle(() => ({ @@ -51,7 +54,7 @@ export function PressableScale({ cancelAnimation(scale) scale.value = withTiming(1, {duration: 100}) }} - style={[animatedStyle, style]} + style={[!reducedMotion && animatedStyle, style]} {...rest}> {children} </AnimatedPressable> |