Betterflow’s animation system transforms static screenshots into polished motion graphics. A built-in keyframe timeline lets you scrub through time, apply preset animations from a gallery, and preview playback in real time — all before exporting to MP4, WebM, or GIF. The engine follows Emil Kowalski’s animation principles: snappy entrances, ease-out defaults, and minimum scale values that prevent jarring scale-from-zero effects.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/betterspacx/app/llms.txt
Use this file to discover all available pages before exploring further.
Animation Architecture
The animation system is built on three layers:Interpolation Engine
lib/animation/interpolation.ts handles keyframe lookup, easing application, and linear interpolation (lerp) between numeric property values.Preset Library
lib/animation/presets.ts defines 30+ named presets as arrays of AnimationTrack objects, each containing timed Keyframe entries.Timeline UI
components/timeline/ provides the visual editor: ruler, playhead, track rows, keyframe markers, playback controls, and the preset gallery.TypeScript Interfaces
The full type system for the animation engine:Easing Functions
Eight easing functions control how property values accelerate and decelerate between keyframes:| Function | Formula | Best For |
|---|---|---|
linear | t | Mechanical motion, turntables |
ease-in | t² | Exits, elements leaving the screen |
ease-out | 1 − (1−t)² | Default for entrances — feels natural |
ease-in-out | Quadratic S-curve | On-screen movement, ambient loops |
ease-in-cubic | t³ | Faster acceleration than quadratic |
ease-out-cubic | 1 − (1−t)³ | Snappier entrances — used by most presets |
ease-in-expo | 2^(10t−10) | Explosive exits |
ease-out-expo | 1 − 2^(−10t) | Very snappy, dramatic entrances |
Preset Gallery
33 presets are organized into 8 categories. Apply any preset from theAnimationPresetGallery component — it clones the preset’s tracks with fresh IDs and places them on the timeline.
- Reveal
- Slide
- Fade
- Flip
- Perspective
- Orbit
- Depth
- Ken Burns
3D entrance animations that land the screenshot into its final resting position.
| Preset | Duration | Key Motion |
|---|---|---|
| Hero Entrance | 1200ms | rotateX 25°→0°, scale 0.95→1, fade in at 600ms |
| Slide In 3D | 1000ms | rotateY 30°→0°, translateX 35→0, fade in at 500ms |
| Rise & Settle | 1000ms | translateY 25→0, rotateX –15°→0°, fade in at 500ms |
| Drop In | 1000ms | translateY –20→0, rotateX 12°→0°, fade in at 500ms |
Timeline Editor
TheTimelineEditor component provides a complete visual editing environment:
Playback Controls
The
TimelineControls component offers Play / Pause, Skip to Start, Skip to End, and a Loop toggle. When looping is enabled, the playhead wraps back to the start automatically using modulo math.Timeline Ruler
TimelineRuler renders tick marks at regular intervals across the timeline. The zoom level (TimelineState.zoom) scales the ruler so short animations can be edited with precision.Keyframe Markers
KeyframeMarker components appear at each keyframe position on their parent track. Click a marker to select it; drag it to shift its time. Selected markers show the keyframe’s easing and property values.Draggable Playhead
TimelinePlayhead is a vertical line you can drag to any point in time. When paused, scrubbing the playhead immediately applies the interpolated properties to the canvas for a live preview.Playback Engine
TheuseTimelinePlayback hook drives real-time preview via requestAnimationFrame:
- Each frame, it calculates elapsed time since playback started
- Calls
getClipInterpolatedProperties(clips, tracks, currentTime)to get the current property values - Writes the result directly into the Zustand store’s
perspective3DandimageOpacityfields - The canvas re-renders synchronously, producing smooth animation at the display’s native refresh rate
Multi-Slide Animations & Looping
Betterflow supports multi-slide presentations where each slide has its own image and animation. The playback engine handles automatic slide switching based on the playhead position — when the playhead crosses a slide boundary, the canvas swaps to the next slide’s image.Loop Mode
Enable Loop in the timeline controls to make the animation cycle indefinitely. The playhead wraps using
playhead % duration, ensuring seamless looping without gaps.Clip Time-Scaling
Clips can be stretched or compressed on the timeline.
originalDuration is stored on each track so the interpolation engine can time-scale keyframe positions correctly regardless of the clip’s displayed duration.The
snapToKeyframes option in TimelineState causes the playhead to snap to the nearest keyframe when scrubbing within a 50ms threshold. This makes it easy to inspect the exact values at each keyframe without overshooting.