Fling

Fling is one of the 16 effects of dissolve, an animation library for React Native. Follows the velocity of the swipe that threw it away. It runs with useDissolve from dissolve-ui.

Usage

Fling (React Native)
import { useDissolve } from 'dissolve-ui';

const { ref, dissolving, dissolve } = useDissolve();

<View ref={ref} collapsable={false} style={{ opacity: dissolving ? 0 : 1 }}>
  <Card />
</View>

await dissolve({
  preset: 'fling',
  grain: 3,
  duration: 1500,
  velocity: { x: 2600, y: -200 },
});

Options

OptionTypeDefaultDescription
presetVariantName'dust'Set it to 'fling'.
velocity{ x, y }noneRelease velocity of the pan gesture in pt/s (e.velocityX, e.velocityY). Sets direction and strength.
durationnumberautoFull effect length in ms. Without it, it follows the speed: clamp(1800 - speed * 0.4, 700, 1500).
grainnumber3Grain size in points. Raised automatically past about 6000 grains per burst.
origin'left' | 'right' | 'top' | 'bottom' | 'center' | { x, y }noneOverrides the default order (the leading edge of the swipe leaves first).
direction'out' | 'in''out''in' plays it backwards as an entrance. Use DissolveIn or useAppear for that.
hapticsbooleantrueSoft impact, then a few ticks while the wave sweeps the view.
field'cascade'noneReplaces the native delay with a diagonal wave, for lists and full screens.

Best practices

  • Use it at the end of a swipe gesture: dismiss a card, triage a mail, reject a match.
  • Pass the release velocity of the pan gesture, slow swipes drift, fast ones tear apart.
  • Leave duration out so it follows the speed (700 to 1500 ms).
  • Do not fling below about 300 pt/s, spring the card back instead.
  • Reduced motion is handled by the provider: the effect is skipped and the promise resolves at once, so keep your state update after the await.

Install

Install the package and its peers, then wrap the app once in <DissolveProvider>, above the navigator.

npx expo install dissolve-ui @shopify/react-native-skia react-native-reanimated react-native-worklets react-native-gesture-handler expo-haptics
app/_layout.tsx
import { Stack } from 'expo-router';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { DissolveProvider } from 'dissolve-ui';

export default function Layout() {
  return (
    <GestureHandlerRootView style={{ flex: 1 }}>
      <DissolveProvider>
        <Stack />
      </DissolveProvider>
    </GestureHandlerRootView>
  );
}

Previous: Snap · Next: Charge · All effects

dissolve is MIT licensed. Source on GitHub, package on npm. This page as markdown. For AI agents: llms.txt.