diff options
author | Hailey <me@haileyok.com> | 2024-09-27 15:26:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-27 15:26:28 -0700 |
commit | 587c0c625752964d8ce64faf1d329dce3c834a5c (patch) | |
tree | 8a345e754db3536b8d0abf875b67f0c6e200d47d /src/lib/custom-animations/PressableScale.tsx | |
parent | 4b5d6e6efb09a714d82e2093dec39c85400a2de6 (diff) | |
download | voidsky-587c0c625752964d8ce64faf1d329dce3c834a5c.tar.zst |
Rework native autocomplete (#5521)
Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'src/lib/custom-animations/PressableScale.tsx')
-rw-r--r-- | src/lib/custom-animations/PressableScale.tsx | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/custom-animations/PressableScale.tsx b/src/lib/custom-animations/PressableScale.tsx index d6eabf8b2..ca080dc8a 100644 --- a/src/lib/custom-animations/PressableScale.tsx +++ b/src/lib/custom-animations/PressableScale.tsx @@ -13,17 +13,19 @@ import {isNative} from '#/platform/detection' const DEFAULT_TARGET_SCALE = isNative || isTouchDevice ? 0.98 : 1 +const AnimatedPressable = Animated.createAnimatedComponent(Pressable) + export function PressableScale({ targetScale = DEFAULT_TARGET_SCALE, children, - contentContainerStyle, + style, onPressIn, onPressOut, ...rest }: { targetScale?: number - contentContainerStyle?: StyleProp<ViewStyle> -} & Exclude<PressableProps, 'onPressIn' | 'onPressOut'>) { + style?: StyleProp<ViewStyle> +} & Exclude<PressableProps, 'onPressIn' | 'onPressOut' | 'style'>) { const scale = useSharedValue(1) const animatedStyle = useAnimatedStyle(() => ({ @@ -31,7 +33,7 @@ export function PressableScale({ })) return ( - <Pressable + <AnimatedPressable accessibilityRole="button" onPressIn={e => { 'worklet' @@ -49,10 +51,9 @@ export function PressableScale({ cancelAnimation(scale) scale.value = withTiming(1, {duration: 100}) }} + style={[animatedStyle, style]} {...rest}> - <Animated.View style={[animatedStyle, contentContainerStyle]}> - {children as React.ReactNode} - </Animated.View> - </Pressable> + {children} + </AnimatedPressable> ) } |