$ git show shared-expand

Card to full screen

Advanced/anim shared-expand

A thumbnail expands into the detail screen with a shared element transition; drag down to shrink it back.

Inspired by SnapchatFrom William Candillon’s “Can it be done in React Native?” series. The code here is a simplified rewrite for Reanimated 4 and 3.
Main · New Architecture only · worklets live in react-native-worklets
sharedTransitionTagGesture.Pannative-stack
shared-expand.tsx · reanimated 4
import { scheduleOnRN } from 'react-native-worklets';

// List screen
<Pressable onPress={() => navigation.navigate('Story', { id })}>
  <Animated.Image sharedTransitionTag={'story-' + id} source={img} style={styles.thumb} />
</Pressable>
// Detail screen (@react-navigation/native-stack)
const ty = useSharedValue(0);
const pan = Gesture.Pan()
  .onUpdate(e => { ty.value = Math.max(0, e.translationY); })
  .onEnd(() => {
    if (ty.value > 150) scheduleOnRN(navigation.goBack);
    else ty.value = withSpring(0);
  });
const style = useAnimatedStyle(() => ({
  borderRadius: interpolate(ty.value, [0, 300], [0, 24], Extrapolation.CLAMP),
  transform: [{ translateY: ty.value }, { scale: interpolate(ty.value, [0, 300], [1, 0.75], Extrapolation.CLAMP) }],
}));
<GestureDetector gesture={pan}>
  <Animated.Image sharedTransitionTag={'story-' + id} source={img} style={[styles.full, style]} />
</GestureDetector>