Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Official Expo team skill for building native UI in Expo apps, fine-tuned for Opus models and usable with Claude Code or Cursor.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/animations.md
1# Animations23Use Reanimated v4. Avoid React Native's built-in Animated API.45## Entering and Exiting Animations67Use Animated.View with entering and exiting animations. Layout animations can animate state changes.89```tsx10import Animated, {11FadeIn,12FadeOut,13LinearTransition,14} from "react-native-reanimated";1516function App() {17return (18<Animated.View19entering={FadeIn}20exiting={FadeOut}21layout={LinearTransition}22/>23);24}25```2627## On-Scroll Animations2829Create high-performance scroll animations using Reanimated's hooks:3031```tsx32import Animated, {33useAnimatedRef,34useScrollViewOffset,35useAnimatedStyle,36interpolate,37} from "react-native-reanimated";3839function Page() {40const ref = useAnimatedRef();41const scroll = useScrollViewOffset(ref);4243const style = useAnimatedStyle(() => ({44opacity: interpolate(scroll.value, [0, 30], [0, 1], "clamp"),45}));4647return (48<Animated.ScrollView ref={ref}>49<Animated.View style={style} />50</Animated.ScrollView>51);52}53```5455## Common Animation Presets5657### Entering Animations5859- `FadeIn`, `FadeInUp`, `FadeInDown`, `FadeInLeft`, `FadeInRight`60- `SlideInUp`, `SlideInDown`, `SlideInLeft`, `SlideInRight`61- `ZoomIn`, `ZoomInUp`, `ZoomInDown`62- `BounceIn`, `BounceInUp`, `BounceInDown`6364### Exiting Animations6566- `FadeOut`, `FadeOutUp`, `FadeOutDown`, `FadeOutLeft`, `FadeOutRight`67- `SlideOutUp`, `SlideOutDown`, `SlideOutLeft`, `SlideOutRight`68- `ZoomOut`, `ZoomOutUp`, `ZoomOutDown`69- `BounceOut`, `BounceOutUp`, `BounceOutDown`7071### Layout Animations7273- `LinearTransition` — Smooth linear interpolation74- `SequencedTransition` — Sequenced property changes75- `FadingTransition` — Fade between states7677## Customizing Animations7879```tsx80<Animated.View81entering={FadeInDown.duration(500).delay(200)}82exiting={FadeOut.duration(300)}83/>84```8586### Modifiers8788```tsx89// Duration in milliseconds90FadeIn.duration(300);9192// Delay before starting93FadeIn.delay(100);9495// Spring physics96FadeIn.springify();97FadeIn.springify().damping(15).stiffness(100);9899// Easing curves100FadeIn.easing(Easing.bezier(0.25, 0.1, 0.25, 1));101102// Chaining103FadeInDown.duration(400).delay(200).springify();104```105106## Shared Value Animations107108For imperative control over animations:109110```tsx111import {112useSharedValue,113withSpring,114withTiming,115} from "react-native-reanimated";116117const offset = useSharedValue(0);118119// Spring animation120offset.value = withSpring(100);121122// Timing animation123offset.value = withTiming(100, { duration: 300 });124125// Use in styles126const style = useAnimatedStyle(() => ({127transform: [{ translateX: offset.value }],128}));129```130131## Gesture Animations132133Combine with React Native Gesture Handler:134135```tsx136import { Gesture, GestureDetector } from "react-native-gesture-handler";137import Animated, {138useSharedValue,139useAnimatedStyle,140withSpring,141} from "react-native-reanimated";142143function DraggableBox() {144const translateX = useSharedValue(0);145const translateY = useSharedValue(0);146147const gesture = Gesture.Pan()148.onUpdate((e) => {149translateX.value = e.translationX;150translateY.value = e.translationY;151})152.onEnd(() => {153translateX.value = withSpring(0);154translateY.value = withSpring(0);155});156157const style = useAnimatedStyle(() => ({158transform: [159{ translateX: translateX.value },160{ translateY: translateY.value },161],162}));163164return (165<GestureDetector gesture={gesture}>166<Animated.View style={[styles.box, style]} />167</GestureDetector>168);169}170```171172## Keyboard Animations173174Animate with keyboard height changes:175176```tsx177import Animated, {178useAnimatedKeyboard,179useAnimatedStyle,180} from "react-native-reanimated";181182function KeyboardAwareView() {183const keyboard = useAnimatedKeyboard();184185const style = useAnimatedStyle(() => ({186paddingBottom: keyboard.height.value,187}));188189return <Animated.View style={style}>{/* content */}</Animated.View>;190}191```192193## Staggered List Animations194195Animate list items with delays:196197```tsx198{199items.map((item, index) => (200<Animated.View201key={item.id}202entering={FadeInUp.delay(index * 50)}203exiting={FadeOutUp}204>205<ListItem item={item} />206</Animated.View>207));208}209```210211## Best Practices212213- Add entering and exiting animations for state changes214- Use layout animations when items are added/removed from lists215- Use `useAnimatedStyle` for scroll-driven animations216- Prefer `interpolate` with "clamp" for bounded values217- You can't pass PlatformColors to reanimated views or styles; use static colors instead218- Keep animations under 300ms for responsive feel219- Use spring animations for natural movement220- Avoid animating layout properties (width, height) when possible — prefer transforms221