Bounce
Bouncy entrance animation with controlled overshoot matching CSS keyframes.
9:41
signal_cellular_altwifibattery_full
Bounce
Preview Controls
Animation
Bounces with overshoot
This is a CSS-based preview of the animation. The actual React Native component uses physics-based springs for a more natural feel.
Installation
$
Usage
Example.tsx
import { Bounce } from './components/Bounce';export default function App() {return (<Bounce intensity={1.3}><NotificationBadge count={5} /></Bounce>);}
Full Component Code
Bounce.tsx
1import React, { useEffect } from 'react';2import { ViewStyle, StyleProp } from 'react-native';3import Animated, {4 useSharedValue,5 useAnimatedStyle,6 withSequence,7 withTiming,8 withDelay,9 Easing,10} from 'react-native-reanimated';1112interface BounceProps {13 children: React.ReactNode;14 delay?: number;15 duration?: number;16 style?: StyleProp<ViewStyle>;17 intensity?: number;18}1920export const Bounce: React.FC<BounceProps> = ({21 children,22 delay = 0,23 duration = 600,24 style,25 intensity = 1.2,26}) => {27 const scale = useSharedValue(0);28 const opacity = useSharedValue(0);2930 useEffect(() => {31 // Match web CSS: 0% -> scale(0), 50% -> scale(1.2), 70% -> scale(0.9), 100% -> scale(1)32 const phaseDuration = duration / 4;3334 scale.value = withDelay(35 delay,36 withSequence(37 withTiming(intensity, {38 duration: phaseDuration * 2,39 easing: Easing.out(Easing.ease)40 }),41 withTiming(0.9, {42 duration: phaseDuration,43 easing: Easing.inOut(Easing.ease)44 }),45 withTiming(1, {46 duration: phaseDuration,47 easing: Easing.out(Easing.ease)48 })49 )50 );5152 opacity.value = withDelay(53 delay,54 withTiming(1, { duration: duration / 3 })55 );56 }, []);5758 const animatedStyle = useAnimatedStyle(() => ({59 transform: [{ scale: scale.value }],60 opacity: opacity.value,61 }));6263 return (64 <Animated.View style={[style, animatedStyle]}>65 {children}66 </Animated.View>67 );68};6970export default Bounce;
Props
| Name | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | Content to animate |
| intensity | number | 1.2 | How much to overshoot (1.0 = no overshoot) |
| delay | number | 0 | Delay before animation |
| duration | number | 600 | Total animation duration in ms |
