About this animation
A React Native animated background can create atmosphere while still giving the user meaningful control. This airplane-window scene loops a cloud panorama through mirrored copies, adds gentle bob and bank, and includes pause, ambient-sound, and shade controls around the view. Use it for travel status, focus modes, meditation, waiting states, or a narrative screen that needs a calm sense of motion. Expo Image renders the panorama, and a Reanimated frame callback advances one shared offset on the UI thread without visible seams. Expo Linear Gradient adds the surrounding light treatment. The component measures its container, accepts your own landscape image, and exposes drift, turbulence, horizon, labels, values, colors, callbacks, and imperative pause and shade methods.
When to use it
- Create a calm travel or waiting scene.
- Add an ambient background to a focus mode.
- Display time and distance over a moving panorama.
- Let users pause motion or close the shade.
An airplane-window scene with drifting clouds and a sliding shade, with configurable sky image, metric labels, accent color, and fonts.
How it works
- Every window part is measured from the container via
onLayoutand sized off the glass width, so the whole assembly keeps its proportions in a modal, a card, or on a tablet. - Inside the glass, three copies of the panorama sit in a row — normal, mirrored, normal — so every seam shows the same edge pixels. A single
offsetshared value advances in auseFrameCallbackworklet and folds back every two panorama widths, which makes the drift endless and the wrap invisible. - Pausing eases a
speedFactorshared value between 1 and 0 over 700 ms; the drift, the bob, and the bank all read it, so the view decelerates without any jump in position. - The bob (
translateY) and the bank (rotate) ride on a glass-sized wrapper, keeping their pivot at the window center; the panorama is 18 % taller than the glass so the motion never exposes an edge. - The shade is a panel inside the glass whose
translateYfollows oneshadeshared value: 6 % of the glass at rest (just the grip lip), the full glass when closed. The same value dims the light halo and drives the shade icon in the button.
Install
npx expo install expo-image expo-linear-gradient react-native-reanimated react-native-workletsUsage
import WindowSeatClouds from './WindowSeatClouds';
export function FlightScreen() {
return <WindowSeatClouds skySource={require('./assets/cloud-sea.jpg')} />;
}Use the knobs, callbacks, and imperative controls to adapt the pattern:
import { useRef } from 'react';
import WindowSeatClouds, {
type WindowSeatCloudsRef,
} from './WindowSeatClouds';
export function FlightScreen() {
const windowRef = useRef<WindowSeatCloudsRef>(null);
return (
<WindowSeatClouds
ref={windowRef}
skySource={require('./assets/cloud-sea.jpg')}
horizonY={0.45}
glassHorizonY={0.52}
driftSpeed={0.03}
turbulence={0.6}
timeValue="40"
timeUnit="min"
distanceValue="205"
distanceUnit="mi"
accentColor="#C98B5A"
fontFamily="YourSansFont"
numberFontFamily="YourMonoFont"
onPausedChange={(paused) => trackPause(paused)}
onShadeChange={(closed) => trackShade(closed)}
onSoundChange={(on) => trackSound(on)}
/>
);
}The forwarded ref exposes pause(), resume(), togglePause(), closeShade(), openShade(), and toggleShade().
The panorama should be a landscape image around 1600×914; horizonY is measured on that image, and the strip renders it at its own aspect ratio with contentFit="cover".
Props
| Prop | Type | Default | Description |
|---|---|---|---|
skySource | ImageSourcePropType | Required | Landscape cloud panorama shown through the window. |
horizonY | number | 0.45 | Height (0–1) of the horizon inside skySource. |
glassHorizonY | number | 0.52 | Where the horizon sits inside the glass (0 = top, 1 = bottom). |
driftSpeed | number | 0.04 | Drift speed, in glass widths per second. |
turbulence | number | 1 | Gentle bob and bank of the view, 0 disables it. |
initiallyPaused | boolean | false | Starts paused. |
initiallyShadeClosed | boolean | false | Starts with the shade down. |
initialSoundOn | boolean | true | Ambient-sound toggle initial state. |
timeLabel | string | 'Time remaining' | Label above the time value. |
timeValue | string | '40' | Time value shown in the bottom-left corner. |
timeUnit | string | 'min' | Unit shown after the time value. |
distanceLabel | string | 'Distance remaining' | Label above the distance value. |
distanceValue | string | '205' | Distance value shown in the bottom-right corner. |
distanceUnit | string | 'mi' | Unit shown after the distance value. |
accentColor | string | '#C98B5A' | Hex accent of the active sound button. |
fontFamily | string | System font | Font family for labels and units. |
numberFontFamily | string | System font | Font family for the time and distance values. |
onPausedChange | (paused: boolean) => void | — | Called with the new paused state. |
onShadeChange | (closed: boolean) => void | — | Called with the new shade state; true means closed. |
onSoundChange | (on: boolean) => void | — | Called with the new ambient-sound state. |
pauseAccessibilityLabel | string | 'Pause drift' / 'Resume drift' | Label of the pause button. |
soundAccessibilityLabel | string | 'Ambient sound' | Label of the sound button. |
shadeAccessibilityLabel | string | 'Window shade' | Label of the shade button. |
style | StyleProp<ViewStyle> | — | Outer-container style. |
testID | string | — | Test identifier for the outer container. |
Compatibility
- Expo SDK 58
- React Native 0.88
- Reanimated 4.7
- iOS: supported
- Android: supported
- Web: supported
- Works in Expo Go because all native dependencies are included in the SDK
Accessibility
The three controls are labeled buttons; the pause button announces its state, and the sound and shade buttons report theirs as checked. Every label can be overridden. When reduced motion is enabled, the drift and the turbulence stop (the panorama sits still) and the shade switches with a 200 ms opacity fade instead of sliding.
FAQ
- Does the animated clouds background work in Expo Go?
- Yes. All dependencies are included with Expo SDK 58 and Expo SDK 57. Each published piece is reviewed on physical iPhone and Android devices with Expo Go before release.
- Can I use my own panorama and labels?
- Yes. Supply a landscape skySource and its horizon position, then tune drift, turbulence, glass alignment, copy, units, accent color, fonts, and callbacks.
- What happens with Reduce Motion enabled?
- Cloud drift and turbulence stop, leaving a still panorama. The shade uses a short opacity fade, and all labeled pause, sound, and shade controls remain available.




