Skip to main content

Animation Presets, Metrics, and Gestures

This guide documents the recommended animation presets in @digiwedge/gluestack-ui, where to use them, and how to monitor and extend animations safely.

Preset Selection (Use Case Map)

Use caseRecommended transitionNotes
Modaltransitions.modalBalanced fade + slide for dialogs/sheets
Bottom sheettransitions.sheetSlide up/down from bottom
Dropdown/menutransitions.dropdownSubtle fade down/up
Tooltip/Popovertransitions.overlaySimple fade for overlays
Toast/snackbartransitions.toastSlide in from right by default
Dialog/Alerttransitions.dialog or transitions.alertZoom for dialogs, bounce for alerts
List item entrytransitions.listItemUse with useStagger for lists
Drawertransitions.drawerLeft / transitions.drawerRightSide panels
Notificationstransitions.notificationSlide down/up
FAB emphasistransitions.fabBounce + zoom
Card revealtransitions.cardZoom in, fade out
Success statetransitions.successBouncy entry
Flip revealtransitions.flipY-axis flip
Page navigationtransitions.pageForward / transitions.pageBackForward/back navigation

Hooks vs Presets

  • Prefer hooks (useFade, useScale, useSlide, usePressAnimation) for components that need imperative control or state-driven animation.
  • Use presets for quick mount/unmount transitions, and always gate them with useMotionPresets() to respect reduced motion.
  • The repo includes a guardrail (pnpm run verify:reanimated-presets) to keep raw Reanimated presets out of app code.

Reduced Motion Gating

Use the shared helper so reduced motion disables transitions automatically:

import { useMotionPresets } from '@digiwedge/gluestack-ui';

const { entering, exiting } = useMotionPresets();

return (
<Animated.View entering={entering?.fadeUp} exiting={exiting?.fadeDown}>
...
</Animated.View>
);

Performance Monitoring (FPS)

Use the JS-frame monitor for diagnostics when animation smoothness is in question. Keep this dev-only.

import { useAnimationFrameRate } from '@digiwedge/gluestack-ui';

const { fps } = useAnimationFrameRate({ enabled: __DEV__ });

return <Text>FPS: {fps ?? '-'} </Text>;

Notes:

  • This measures JS frame rate, not the UI thread.
  • For UI-thread metrics, use RN/Expo performance overlays or native profiling.

Gesture-Driven Animations

Use SwipeableRow or wire useSwipe directly:

import { SwipeableRow } from '@digiwedge/gluestack-ui';

<SwipeableRow onSwipeLeft={() => dismiss()} onSwipeRight={() => archive()}>
<Card>Swipe me</Card>
</SwipeableRow>

If you need custom gesture control, call useSwipe and feed it PanResponder or gesture-handler events.